[EFL][WK2] Extract the control of page background out of color_set
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Apr 2014 06:09:55 +0000 (06:09 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Apr 2014 06:09:55 +0000 (06:09 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166566 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/efl/WKViewEfl.cpp
Source/WebKit2/UIProcess/API/C/efl/WKViewEfl.h
Source/WebKit2/UIProcess/API/efl/EwkView.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.h
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp
Source/WebKit2/UIProcess/efl/WebViewEfl.cpp
Source/WebKit2/UIProcess/efl/WebViewEfl.h
Tools/ChangeLog
Tools/MiniBrowser/efl/main.c

index 267fceb..c205b9f 100644 (file)
@@ -1,3 +1,25 @@
+2014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [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.
+
+        * 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.
+
 2014-03-31  Byungseon Shin  <sun.shin@lge.com>
 
         [WebGL][OpenGLES] Enable MSAA support for WebGL Canvas
index 0b217ec..83fd568 100644 (file)
@@ -52,6 +52,7 @@ CoordinatedGraphicsScene::CoordinatedGraphicsScene(CoordinatedGraphicsSceneClien
     , m_isActive(false)
     , m_rootLayerID(InvalidCoordinatedLayerID)
     , m_backgroundColor(Color::white)
+    , m_viewBackgroundColor(Color::white)
     , m_setDrawsBackground(false)
 {
     ASSERT(isMainThread());
@@ -86,6 +87,10 @@ void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatri
             m_backgroundColor.green(), m_backgroundColor.blue(),
             m_backgroundColor.alpha() * opacity);
         m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba));
+    } else {
+        GraphicsContext3D* context = static_cast<TextureMapperGL*>(m_textureMapper.get())->graphicsContext3D();
+        context->clearColor(m_viewBackgroundColor.red() / 255.0f, m_viewBackgroundColor.green() / 255.0f, m_viewBackgroundColor.blue() / 255.0f, m_viewBackgroundColor.alpha() / 255.0f);
+        context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
     }
 
     if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
@@ -124,6 +129,8 @@ void CoordinatedGraphicsScene::paintToGraphicsContext(PlatformGraphicsContext* p
     IntRect clipRect = graphicsContext.clipBounds();
     if (m_setDrawsBackground)
         m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_backgroundColor);
+    else
+        m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_viewBackgroundColor);
 
     layer->paint();
     m_fpsCounter.updateFPSAndDisplay(m_textureMapper.get(), clipRect.location());
index b147de4..bdfaf0f 100644 (file)
@@ -83,6 +83,9 @@ public:
     void setBackgroundColor(const Color&);
     void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
 
+    void setViewBackgroundColor(const Color& color) { m_viewBackgroundColor = color; }
+    Color viewBackgroundColor() const { return m_viewBackgroundColor; }
+
 private:
     void setRootLayerID(CoordinatedLayerID);
     void createLayers(const Vector<CoordinatedLayerID>&);
@@ -182,6 +185,7 @@ private:
     FloatPoint m_scrollPosition;
     FloatPoint m_renderedContentsScrollPosition;
     Color m_backgroundColor;
+    Color m_viewBackgroundColor;
     bool m_setDrawsBackground;
 
     TextureMapperFPSCounter m_fpsCounter;
index 161f3fd..5013076 100644 (file)
@@ -304,13 +304,13 @@ void RenderLayerBacking::createPrimaryGraphicsLayer()
         m_graphicsLayer->addChild(m_childContainmentLayer.get());
     }
 
+#if !PLATFORM(IOS) && !PLATFORM(EFL)
     if (m_isMainFrameRenderViewLayer) {
-#if !PLATFORM(IOS)
         // Page scale is applied above the RenderView on iOS.
         m_graphicsLayer->setContentsOpaque(true);
         m_graphicsLayer->setAppliesPageScale();
-#endif
     }
+#endif
 
 #if PLATFORM(COCOA) && USE(CA)
     if (!compositor().acceleratedDrawingEnabled() && renderer().isCanvas()) {
index 76033bd..0f93ae7 100644 (file)
@@ -42,6 +42,7 @@
 #include "HitTestResult.h"
 #include "InspectorInstrumentation.h"
 #include "Logging.h"
+#include "MainFrame.h"
 #include "NodeList.h"
 #include "Page.h"
 #include "ProgressTracker.h"
@@ -3085,7 +3086,7 @@ void RenderLayerCompositor::ensureRootLayer()
         m_rootContentLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.maxY()));
         m_rootContentLayer->setPosition(FloatPoint());
 
-#if PLATFORM(IOS)
+#if PLATFORM(IOS) || PLATFORM(EFL)
         // Page scale is applied above this on iOS, so we'll just say that our root layer applies it.
         Frame& frame = m_renderView.frameView().frame();
         if (frame.isMainFrame())
index c4c59f8..9ad7b6c 100644 (file)
@@ -1,3 +1,36 @@
+2014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [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.
+
+        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:
+
 2014-03-31  Joonghun Park  <jh718.park@samsung.com>
 
         [EFL][WK2]Implement ewk APIs of web local storage which have deletion functions of the local storage entries
index 631e9e3..6f25c59 100644 (file)
@@ -84,3 +84,22 @@ void WKViewSendMouseMoveEvent(WKViewRef viewRef, Evas_Event_Mouse_Move* event)
 {
     static_cast<WebViewEfl*>(toImpl(viewRef))->sendMouseEvent(event);
 }
+
+void WKViewSetBackgroundColor(WKViewRef viewRef, int red, int green, int blue, int alpha)
+{
+    static_cast<WebViewEfl*>(toImpl(viewRef))->setViewBackgroundColor(WebCore::Color(red, green, blue, alpha));
+}
+
+void WKViewGetBackgroundColor(WKViewRef viewRef, int* red, int* green, int* blue, int* alpha)
+{
+    WebCore::Color backgroundColor = static_cast<WebViewEfl*>(toImpl(viewRef))->viewBackgroundColor();
+
+    if (red)
+        *red = backgroundColor.red();
+    if (green)
+        *green = backgroundColor.green();
+    if (blue)
+        *blue = backgroundColor.blue();
+    if (alpha)
+        *alpha = backgroundColor.alpha();
+}
index b97cdc7..505d1f2 100644 (file)
@@ -65,6 +65,9 @@ WK_EXPORT void WKViewSendMouseDownEvent(WKViewRef, Evas_Event_Mouse_Down*);
 WK_EXPORT void WKViewSendMouseUpEvent(WKViewRef, Evas_Event_Mouse_Up*);
 WK_EXPORT void WKViewSendMouseMoveEvent(WKViewRef, Evas_Event_Mouse_Move*);
 
+WK_EXPORT void WKViewSetBackgroundColor(WKViewRef, int red, int green, int blue, int alpha);
+WK_EXPORT void WKViewGetBackgroundColor(WKViewRef, int* red, int* green, int* blue, int* alpha);
+
 #ifdef __cplusplus
 }
 #endif
index 3b8b232..390b41a 100644 (file)
@@ -1258,18 +1258,7 @@ void EwkView::handleEvasObjectColorSet(Evas_Object* evasObject, int red, int gre
     Ewk_View_Smart_Data* smartData = toSmartData(evasObject);
     ASSERT(smartData);
 
-    EwkView* view = toEwkView(smartData);
-    ASSERT(view);
-
-    alpha = clampTo(alpha, 0, 255);
-    red = clampTo(red, 0, alpha);
-    green = clampTo(green, 0, alpha);
-    blue = clampTo(blue, 0, alpha);
-
     evas_object_image_alpha_set(smartData->image, alpha < 255);
-    WKViewSetDrawsBackground(view->wkView(), red || green || blue);
-    WKViewSetDrawsTransparentBackground(view->wkView(), alpha < 255);
-
     parentSmartClass.color_set(evasObject, red, green, blue, alpha);
 }
 
index 1bc41fc..abe01ad 100644 (file)
@@ -52,6 +52,7 @@
 #include <WebKit2/WKString.h>
 #include <WebKit2/WKURL.h>
 #include <WebKit2/WKView.h>
+#include <WebKit2/WKViewEfl.h>
 #include <wtf/text/CString.h>
 
 #if ENABLE(INSPECTOR)
@@ -589,13 +590,6 @@ Eina_Bool ewk_view_fullscreen_exit(Evas_Object* ewkView)
 #endif
 }
 
-void ewk_view_draws_page_background_set(Evas_Object *ewkView, Eina_Bool enabled)
-{
-    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
-
-    WKViewSetDrawsBackground(impl->wkView(), enabled);
-}
-
 /// Creates a type name for Ewk_Page_Contents_Context.
 typedef struct Ewk_Page_Contents_Context Ewk_Page_Contents_Context;
 
@@ -721,3 +715,27 @@ Eina_Bool ewk_view_layout_fixed_get(const Evas_Object* ewkView)
 
     return WKPageUseFixedLayout(WKViewGetPage(impl->wkView()));
 }
+
+void ewk_view_bg_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
+{
+    if (EINA_UNLIKELY(alpha < 0 || alpha > 255)) {
+        EINA_LOG_CRIT("Alpha should be between 0 and 255");
+        return;
+    }
+
+    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
+
+    if (red == 255 && green == 255 && blue == 255 && alpha == 255)
+        WKViewSetDrawsBackground(impl->wkView(), true);
+    else
+        WKViewSetDrawsBackground(impl->wkView(), false);
+
+    WKViewSetBackgroundColor(impl->wkView(), red, green, blue, alpha);
+}
+
+void ewk_view_bg_color_get(const Evas_Object* ewkView, int* red, int* green, int* blue, int* alpha)
+{
+    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
+
+    WKViewGetBackgroundColor(impl->wkView(), red, green, blue, alpha);
+}
index 056c9b0..85c1109 100644 (file)
@@ -839,22 +839,6 @@ EAPI Ewk_Pagination_Mode ewk_view_pagination_mode_get(const Evas_Object *o);
 EAPI Eina_Bool ewk_view_fullscreen_exit(Evas_Object *o);
 
 /**
- * Sets whether the ewk_view background matches page background color.
- *
- * If enabled sets view background color close to page color on page load.
- * This helps to reduce flicker on page scrolling and repainting in places
- * where page content is not ready for painting.
- * View background color can interfere with semi-transparent pages and is
- * disabled by default.
- *
- * @param o view object to enable/disable background matching
- * @param enabled a state to set
- *
- * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
- */
-EAPI void ewk_view_draws_page_background_set(Evas_Object *o, Eina_Bool enabled);
-
-/**
  * Get contents of the current web page.
  *
  * @param o view object to get the page contents
@@ -903,6 +887,28 @@ EAPI Eina_Bool ewk_view_layout_fixed_set(Evas_Object *o, Eina_Bool enabled);
  */
 EAPI Eina_Bool ewk_view_layout_fixed_get(const Evas_Object *o);
 
+/**
+ * Sets the background color and transparency of the view.
+ *
+ * @param o view object to change the background color
+ * @param r red color component
+ * @param g green color component
+ * @param b blue color component
+ * @param a transparency
+ */
+EAPI void ewk_view_bg_color_set(Evas_Object *o, int r, int g, int b, int a);
+
+/**
+ * Gets the background color of the view.
+ *
+ * @param o view object to get the background color
+ * @param r the pointer to store red color component
+ * @param g the pointer to store green color component
+ * @param b the pointer to store blue color component
+ * @param a the pointer to store alpha value
+ */
+EAPI void ewk_view_bg_color_get(const Evas_Object *o, int *r, int *g, int *b, int *a);
+
 #ifdef __cplusplus
 }
 #endif
index 2dc565b..b5a1019 100644 (file)
@@ -1083,3 +1083,19 @@ TEST_F(EWK2ViewTest, ewk_view_layout_fixed)
     EXPECT_TRUE(ewk_view_layout_fixed_set(webView(), true));
     EXPECT_TRUE(ewk_view_layout_fixed_get(webView()));
 }
+
+TEST_F(EWK2ViewTest, ewk_view_bg_color)
+{
+    const char noBackgroundHTML[] = "<!doctype html><body></body>";
+
+    ewk_view_bg_color_set(webView(), 255, 0, 0, 255);
+    ewk_view_html_string_load(webView(), noBackgroundHTML, 0, 0);
+    ASSERT_TRUE(waitUntilLoadFinished());
+
+    int red, green, blue, alpha;
+    ewk_view_bg_color_get(webView(), &red, &green, &blue, &alpha);
+    ASSERT_EQ(255, red);
+    ASSERT_EQ(0, green);
+    ASSERT_EQ(0, blue);
+    ASSERT_EQ(255, red);
+}
index d3e39a5..6cc8c54 100644 (file)
@@ -147,6 +147,24 @@ void WebViewEfl::sendMouseEvent(const Evas_Event_Mouse_Move* event)
     m_page->handleMouseEvent(NativeWebMouseEvent(event, transformFromScene(), m_userViewportTransform.toAffineTransform()));
 }
 
+void WebViewEfl::setViewBackgroundColor(const WebCore::Color& color)
+{
+    CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
+    if (!scene)
+        return;
+
+    scene->setViewBackgroundColor(color);
+}
+
+WebCore::Color WebViewEfl::viewBackgroundColor()
+{
+    CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
+    if (!scene)
+        return Color();
+
+    return scene->viewBackgroundColor();
+}
+
 #if ENABLE(FULLSCREEN_API)
 
 // WebFullScreenManagerProxyClient
index cac4f34..5d9cdd9 100644 (file)
@@ -60,6 +60,8 @@ public:
     virtual PassRefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) override;
 #endif
 
+    void setViewBackgroundColor(const WebCore::Color&);
+    WebCore::Color viewBackgroundColor();
 private:
     WebViewEfl(WebContext*, WebPageGroup*);
 
index 68b00ac..420171a 100644 (file)
@@ -1,5 +1,18 @@
 2014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
 
+        [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.
+
+        Added an option(C) to change background color.
+
+        * MiniBrowser/efl/main.c:
+        (window_create):
+        (elm_main):
+
+2014-03-31  Ryuan Choi  <ryuan.choi@samsung.com>
+
         Unreviewed build fix on the EFL port with latest EFL libraries since r166149
 
         * ImageDiff/PlatformEfl.cmake: Added ECORE_IMF_INCLUDE_DIRS to include dirs
index 5dce08c..11ab1e1 100644 (file)
@@ -47,6 +47,7 @@ static int verbose = 1;
 static Eina_List *windows = NULL;
 static char *evas_engine_name = NULL;
 static char *user_agent_string = NULL;
+static char *background_color_string = NULL;
 static Eina_Bool encoding_detector_enabled = EINA_FALSE;
 static Eina_Bool frame_flattening_enabled = EINA_FALSE;
 static Eina_Bool local_storage_enabled = EINA_TRUE;
@@ -159,6 +160,8 @@ static const Ecore_Getopt options = {
              ecore_getopt_callback_ecore_evas_list_engines, NULL),
         ECORE_GETOPT_STORE_DEF_BOOL
             ('c', "encoding-detector", "Enable/disable encoding detector.", EINA_FALSE),
+        ECORE_GETOPT_STORE_STR
+            ('C', "background-color", "Background color of page. ex) -C=255:255:255:255"),
         ECORE_GETOPT_STORE_DEF_BOOL
             ('f', "flattening", "Enable/disable frame flattening.", EINA_FALSE),
         ECORE_GETOPT_STORE_DEF_BOOL
@@ -1835,6 +1838,13 @@ static Browser_Window *window_create(Evas_Object *opener, int width, int height)
         ewk_view_mouse_events_enabled_set(window->ewk_view, EINA_FALSE);
     }
 
+    if (background_color_string) {
+        int red, green, blue, alpha;
+
+        if (sscanf(background_color_string, "%d:%d:%d:%d", &red, &green, &blue, &alpha))
+            ewk_view_bg_color_set(window->ewk_view, red, green, blue, alpha);
+    }
+
     /* Set the zoom level to default */
     window->current_zoom_level = DEFAULT_ZOOM_LEVEL;
 
@@ -1939,6 +1949,7 @@ elm_main(int argc, char *argv[])
         ECORE_GETOPT_VALUE_DOUBLE(device_pixel_ratio),
         ECORE_GETOPT_VALUE_BOOL(quitOption),
         ECORE_GETOPT_VALUE_BOOL(encoding_detector_enabled),
+        ECORE_GETOPT_VALUE_STR(background_color_string),
         ECORE_GETOPT_VALUE_BOOL(frame_flattening_enabled),
         ECORE_GETOPT_VALUE_BOOL(local_storage_enabled),
         ECORE_GETOPT_VALUE_BOOL(fullscreen_enabled),