Changeset 166566 in webkit


Ignore:
Timestamp:
Mar 31, 2014 11:09:55 PM (10 years ago)
Author:
ryuan.choi@samsung.com
Message:

[EFL][WK2] Extract the control of page background out of color_set
https://bugs.webkit.org/show_bug.cgi?id=127539

Reviewed by Gyuyoung Kim.

Source/WebCore:

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:

Added m_viewBackgroundColor to clear when m_setDrawsBackground is false.
(WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene):
(WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext):
(WebCore::CoordinatedGraphicsScene::paintToGraphicsContext):

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:

(WebCore::CoordinatedGraphicsScene::setViewBackgroundColor):
(WebCore::CoordinatedGraphicsScene::viewBackgroundColor):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
Added EFL guard not to set opaque as a default for MainFrameRenderViewLayer.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::ensureRootLayer):
Added EFL guard to apply page scale on RenderView like IOS.

Source/WebKit2:

EFL have a way to change the color using evas_object_color_set and we used it to change background.
But, We should not use it because the alpha value of color_set is used
for the transparancy of object itself including background and contents.

This patch added ewk_view_bg_color_{get|set} to change the background color.

  • UIProcess/API/C/efl/WKViewEfl.cpp:

Extracted controls of page background out of color_set.
color_set will be only used for the opacity of whole contents.
(WKViewSetBackgroundColor): Added to share page background color.
(WKViewGetBackgroundColor):

  • UIProcess/API/C/efl/WKViewEfl.h:
  • UIProcess/API/efl/EwkView.cpp:

(EwkView::handleEvasObjectColorSet):

  • UIProcess/API/efl/ewk_view.cpp:

Removed ewk_view_draws_page_background_set which just control whether to draw background.
ewk_view_bg_color_set will conver it.
(ewk_view_bg_color_set):
(ewk_view_bg_color_get):

  • UIProcess/API/efl/ewk_view.h:
  • UIProcess/API/efl/tests/test_ewk2_view.cpp: Added simple test case.
  • UIProcess/efl/WebViewEfl.cpp:

(WebKit::WebViewEfl::setViewBackgroundColor):
(WebKit::WebViewEfl::viewBackgroundColor):

  • UIProcess/efl/WebViewEfl.h:

Tools:

Added an option(C) to change background color.

  • MiniBrowser/efl/main.c:

(window_create):
(elm_main):

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166563 r166566  
     12014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
     2
     3        [EFL][WK2] Extract the control of page background out of color_set
     4        https://bugs.webkit.org/show_bug.cgi?id=127539
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
     9        Added m_viewBackgroundColor to clear when m_setDrawsBackground is false.
     10        (WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene):
     11        (WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext):
     12        (WebCore::CoordinatedGraphicsScene::paintToGraphicsContext):
     13        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
     14        (WebCore::CoordinatedGraphicsScene::setViewBackgroundColor):
     15        (WebCore::CoordinatedGraphicsScene::viewBackgroundColor):
     16        * rendering/RenderLayerBacking.cpp:
     17        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
     18        Added EFL guard not to set opaque as a default for MainFrameRenderViewLayer.
     19        * rendering/RenderLayerCompositor.cpp:
     20        (WebCore::RenderLayerCompositor::ensureRootLayer):
     21        Added EFL guard to apply page scale on RenderView like IOS.
     22
    1232014-03-31  Byungseon Shin  <sun.shin@lge.com>
    224
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp

    r163972 r166566  
    5353    , m_rootLayerID(InvalidCoordinatedLayerID)
    5454    , m_backgroundColor(Color::white)
     55    , m_viewBackgroundColor(Color::white)
    5556    , m_setDrawsBackground(false)
    5657{
     
    8788            m_backgroundColor.alpha() * opacity);
    8889        m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba));
     90    } else {
     91        GraphicsContext3D* context = static_cast<TextureMapperGL*>(m_textureMapper.get())->graphicsContext3D();
     92        context->clearColor(m_viewBackgroundColor.red() / 255.0f, m_viewBackgroundColor.green() / 255.0f, m_viewBackgroundColor.blue() / 255.0f, m_viewBackgroundColor.alpha() / 255.0f);
     93        context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
    8994    }
    9095
     
    125130    if (m_setDrawsBackground)
    126131        m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_backgroundColor);
     132    else
     133        m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_viewBackgroundColor);
    127134
    128135    layer->paint();
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h

    r163972 r166566  
    8484    void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
    8585
     86    void setViewBackgroundColor(const Color& color) { m_viewBackgroundColor = color; }
     87    Color viewBackgroundColor() const { return m_viewBackgroundColor; }
     88
    8689private:
    8790    void setRootLayerID(CoordinatedLayerID);
     
    183186    FloatPoint m_renderedContentsScrollPosition;
    184187    Color m_backgroundColor;
     188    Color m_viewBackgroundColor;
    185189    bool m_setDrawsBackground;
    186190
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r166526 r166566  
    305305    }
    306306
     307#if !PLATFORM(IOS) && !PLATFORM(EFL)
    307308    if (m_isMainFrameRenderViewLayer) {
    308 #if !PLATFORM(IOS)
    309309        // Page scale is applied above the RenderView on iOS.
    310310        m_graphicsLayer->setContentsOpaque(true);
    311311        m_graphicsLayer->setAppliesPageScale();
    312 #endif
    313     }
     312    }
     313#endif
    314314
    315315#if PLATFORM(COCOA) && USE(CA)
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r166531 r166566  
    4343#include "InspectorInstrumentation.h"
    4444#include "Logging.h"
     45#include "MainFrame.h"
    4546#include "NodeList.h"
    4647#include "Page.h"
     
    30863087        m_rootContentLayer->setPosition(FloatPoint());
    30873088
    3088 #if PLATFORM(IOS)
     3089#if PLATFORM(IOS) || PLATFORM(EFL)
    30893090        // Page scale is applied above this on iOS, so we'll just say that our root layer applies it.
    30903091        Frame& frame = m_renderView.frameView().frame();
  • trunk/Source/WebKit2/ChangeLog

    r166565 r166566  
     12014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
     2
     3        [EFL][WK2] Extract the control of page background out of color_set
     4        https://bugs.webkit.org/show_bug.cgi?id=127539
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        EFL have a way to change the color using evas_object_color_set and we used it to change background.
     9        But, We should not use it because the alpha value of color_set is used
     10        for the transparancy of object itself including background and contents.
     11
     12        This patch added ewk_view_bg_color_{get|set} to change the background color.
     13
     14        * UIProcess/API/C/efl/WKViewEfl.cpp:
     15        Extracted controls of page background out of color_set.
     16        color_set will be only used for the opacity of whole contents.
     17        (WKViewSetBackgroundColor): Added to share page background color.
     18        (WKViewGetBackgroundColor):
     19        * UIProcess/API/C/efl/WKViewEfl.h:
     20        * UIProcess/API/efl/EwkView.cpp:
     21        (EwkView::handleEvasObjectColorSet):
     22        * UIProcess/API/efl/ewk_view.cpp:
     23        Removed ewk_view_draws_page_background_set which just control whether to draw background.
     24        ewk_view_bg_color_set will conver it.
     25        (ewk_view_bg_color_set):
     26        (ewk_view_bg_color_get):
     27        * UIProcess/API/efl/ewk_view.h:
     28        * UIProcess/API/efl/tests/test_ewk2_view.cpp: Added simple test case.
     29        * UIProcess/efl/WebViewEfl.cpp:
     30        (WebKit::WebViewEfl::setViewBackgroundColor):
     31        (WebKit::WebViewEfl::viewBackgroundColor):
     32        * UIProcess/efl/WebViewEfl.h:
     33
    1342014-03-31  Joonghun Park  <jh718.park@samsung.com>
    235
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKViewEfl.cpp

    r164271 r166566  
    8585    static_cast<WebViewEfl*>(toImpl(viewRef))->sendMouseEvent(event);
    8686}
     87
     88void WKViewSetBackgroundColor(WKViewRef viewRef, int red, int green, int blue, int alpha)
     89{
     90    static_cast<WebViewEfl*>(toImpl(viewRef))->setViewBackgroundColor(WebCore::Color(red, green, blue, alpha));
     91}
     92
     93void WKViewGetBackgroundColor(WKViewRef viewRef, int* red, int* green, int* blue, int* alpha)
     94{
     95    WebCore::Color backgroundColor = static_cast<WebViewEfl*>(toImpl(viewRef))->viewBackgroundColor();
     96
     97    if (red)
     98        *red = backgroundColor.red();
     99    if (green)
     100        *green = backgroundColor.green();
     101    if (blue)
     102        *blue = backgroundColor.blue();
     103    if (alpha)
     104        *alpha = backgroundColor.alpha();
     105}
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKViewEfl.h

    r164271 r166566  
    6666WK_EXPORT void WKViewSendMouseMoveEvent(WKViewRef, Evas_Event_Mouse_Move*);
    6767
     68WK_EXPORT void WKViewSetBackgroundColor(WKViewRef, int red, int green, int blue, int alpha);
     69WK_EXPORT void WKViewGetBackgroundColor(WKViewRef, int* red, int* green, int* blue, int* alpha);
     70
    6871#ifdef __cplusplus
    6972}
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp

    r166159 r166566  
    12591259    ASSERT(smartData);
    12601260
    1261     EwkView* view = toEwkView(smartData);
    1262     ASSERT(view);
    1263 
    1264     alpha = clampTo(alpha, 0, 255);
    1265     red = clampTo(red, 0, alpha);
    1266     green = clampTo(green, 0, alpha);
    1267     blue = clampTo(blue, 0, alpha);
    1268 
    12691261    evas_object_image_alpha_set(smartData->image, alpha < 255);
    1270     WKViewSetDrawsBackground(view->wkView(), red || green || blue);
    1271     WKViewSetDrawsTransparentBackground(view->wkView(), alpha < 255);
    1272 
    12731262    parentSmartClass.color_set(evasObject, red, green, blue, alpha);
    12741263}
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

    r164266 r166566  
    5353#include <WebKit2/WKURL.h>
    5454#include <WebKit2/WKView.h>
     55#include <WebKit2/WKViewEfl.h>
    5556#include <wtf/text/CString.h>
    5657
     
    590591}
    591592
    592 void ewk_view_draws_page_background_set(Evas_Object *ewkView, Eina_Bool enabled)
    593 {
    594     EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
    595 
    596     WKViewSetDrawsBackground(impl->wkView(), enabled);
    597 }
    598 
    599593/// Creates a type name for Ewk_Page_Contents_Context.
    600594typedef struct Ewk_Page_Contents_Context Ewk_Page_Contents_Context;
     
    722716    return WKPageUseFixedLayout(WKViewGetPage(impl->wkView()));
    723717}
     718
     719void ewk_view_bg_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
     720{
     721    if (EINA_UNLIKELY(alpha < 0 || alpha > 255)) {
     722        EINA_LOG_CRIT("Alpha should be between 0 and 255");
     723        return;
     724    }
     725
     726    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
     727
     728    if (red == 255 && green == 255 && blue == 255 && alpha == 255)
     729        WKViewSetDrawsBackground(impl->wkView(), true);
     730    else
     731        WKViewSetDrawsBackground(impl->wkView(), false);
     732
     733    WKViewSetBackgroundColor(impl->wkView(), red, green, blue, alpha);
     734}
     735
     736void ewk_view_bg_color_get(const Evas_Object* ewkView, int* red, int* green, int* blue, int* alpha)
     737{
     738    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
     739
     740    WKViewGetBackgroundColor(impl->wkView(), red, green, blue, alpha);
     741}
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h

    r166399 r166566  
    840840
    841841/**
    842  * Sets whether the ewk_view background matches page background color.
    843  *
    844  * If enabled sets view background color close to page color on page load.
    845  * This helps to reduce flicker on page scrolling and repainting in places
    846  * where page content is not ready for painting.
    847  * View background color can interfere with semi-transparent pages and is
    848  * disabled by default.
    849  *
    850  * @param o view object to enable/disable background matching
    851  * @param enabled a state to set
    852  *
    853  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
    854  */
    855 EAPI void ewk_view_draws_page_background_set(Evas_Object *o, Eina_Bool enabled);
    856 
    857 /**
    858842 * Get contents of the current web page.
    859843 *
     
    904888EAPI Eina_Bool ewk_view_layout_fixed_get(const Evas_Object *o);
    905889
     890/**
     891 * Sets the background color and transparency of the view.
     892 *
     893 * @param o view object to change the background color
     894 * @param r red color component
     895 * @param g green color component
     896 * @param b blue color component
     897 * @param a transparency
     898 */
     899EAPI void ewk_view_bg_color_set(Evas_Object *o, int r, int g, int b, int a);
     900
     901/**
     902 * Gets the background color of the view.
     903 *
     904 * @param o view object to get the background color
     905 * @param r the pointer to store red color component
     906 * @param g the pointer to store green color component
     907 * @param b the pointer to store blue color component
     908 * @param a the pointer to store alpha value
     909 */
     910EAPI void ewk_view_bg_color_get(const Evas_Object *o, int *r, int *g, int *b, int *a);
     911
    906912#ifdef __cplusplus
    907913}
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

    r165598 r166566  
    10841084    EXPECT_TRUE(ewk_view_layout_fixed_get(webView()));
    10851085}
     1086
     1087TEST_F(EWK2ViewTest, ewk_view_bg_color)
     1088{
     1089    const char noBackgroundHTML[] = "<!doctype html><body></body>";
     1090
     1091    ewk_view_bg_color_set(webView(), 255, 0, 0, 255);
     1092    ewk_view_html_string_load(webView(), noBackgroundHTML, 0, 0);
     1093    ASSERT_TRUE(waitUntilLoadFinished());
     1094
     1095    int red, green, blue, alpha;
     1096    ewk_view_bg_color_get(webView(), &red, &green, &blue, &alpha);
     1097    ASSERT_EQ(255, red);
     1098    ASSERT_EQ(0, green);
     1099    ASSERT_EQ(0, blue);
     1100    ASSERT_EQ(255, red);
     1101}
  • trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.cpp

    r165313 r166566  
    148148}
    149149
     150void WebViewEfl::setViewBackgroundColor(const WebCore::Color& color)
     151{
     152    CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
     153    if (!scene)
     154        return;
     155
     156    scene->setViewBackgroundColor(color);
     157}
     158
     159WebCore::Color WebViewEfl::viewBackgroundColor()
     160{
     161    CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
     162    if (!scene)
     163        return Color();
     164
     165    return scene->viewBackgroundColor();
     166}
     167
    150168#if ENABLE(FULLSCREEN_API)
    151169
  • trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.h

    r165313 r166566  
    6161#endif
    6262
     63    void setViewBackgroundColor(const WebCore::Color&);
     64    WebCore::Color viewBackgroundColor();
    6365private:
    6466    WebViewEfl(WebContext*, WebPageGroup*);
  • trunk/Tools/ChangeLog

    r166564 r166566  
     12014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
     2
     3        [EFL][WK2] Extract the control of page background out of color_set
     4        https://bugs.webkit.org/show_bug.cgi?id=127539
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        Added an option(C) to change background color.
     9
     10        * MiniBrowser/efl/main.c:
     11        (window_create):
     12        (elm_main):
     13
    1142014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
    215
  • trunk/Tools/MiniBrowser/efl/main.c

    r165610 r166566  
    4848static char *evas_engine_name = NULL;
    4949static char *user_agent_string = NULL;
     50static char *background_color_string = NULL;
    5051static Eina_Bool encoding_detector_enabled = EINA_FALSE;
    5152static Eina_Bool frame_flattening_enabled = EINA_FALSE;
     
    160161        ECORE_GETOPT_STORE_DEF_BOOL
    161162            ('c', "encoding-detector", "Enable/disable encoding detector.", EINA_FALSE),
     163        ECORE_GETOPT_STORE_STR
     164            ('C', "background-color", "Background color of page. ex) -C=255:255:255:255"),
    162165        ECORE_GETOPT_STORE_DEF_BOOL
    163166            ('f', "flattening", "Enable/disable frame flattening.", EINA_FALSE),
     
    18361839    }
    18371840
     1841    if (background_color_string) {
     1842        int red, green, blue, alpha;
     1843
     1844        if (sscanf(background_color_string, "%d:%d:%d:%d", &red, &green, &blue, &alpha))
     1845            ewk_view_bg_color_set(window->ewk_view, red, green, blue, alpha);
     1846    }
     1847
    18381848    /* Set the zoom level to default */
    18391849    window->current_zoom_level = DEFAULT_ZOOM_LEVEL;
     
    19401950        ECORE_GETOPT_VALUE_BOOL(quitOption),
    19411951        ECORE_GETOPT_VALUE_BOOL(encoding_detector_enabled),
     1952        ECORE_GETOPT_VALUE_STR(background_color_string),
    19421953        ECORE_GETOPT_VALUE_BOOL(frame_flattening_enabled),
    19431954        ECORE_GETOPT_VALUE_BOOL(local_storage_enabled),
Note: See TracChangeset for help on using the changeset viewer.