[WK2][EFL] Add an ACCELERATED_COMPOSITING implementation for Efl WebKit2
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2012 13:45:16 +0000 (13:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2012 13:45:16 +0000 (13:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91581

Patch by YoungTaeck Song <youngtaeck.song@samsung.com> on 2012-07-27
Reviewed by Noam Rosenthal.

Source/WebKit2:

This patch is a subset of Efl's UI_SIDE_COMPOSITING implementation.
When enter accelerated compositing mode, create evas_gl, evas_gl_context, and evas_gl_surface.

* PlatformEfl.cmake:
* Shared/LayerTreeContext.h:
(LayerTreeContext):
* UIProcess/API/efl/PageClientImpl.cpp:
(WebKit::PageClientImpl::viewSize):
(WebKit::PageClientImpl::enterAcceleratedCompositingMode):
(WebKit::PageClientImpl::exitAcceleratedCompositingMode):
* UIProcess/API/efl/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_Ewk_View_Private_Data::_Ewk_View_Private_Data):
(ewk_view_size_get):
(ewk_view_create_gl_surface):
(ewk_view_enter_accelerated_compositing_mode):
(ewk_view_exit_accelerated_compositing_mode):
(_ewk_view_smart_calculate):
* UIProcess/API/efl/ewk_view_private.h:

Tools:

Add a MiniBrowser's option for selecting evas engine.

* MiniBrowser/efl/main.c:
(browserCreate):
(main):

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

Source/WebKit2/ChangeLog
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/Shared/LayerTreeContext.h
Source/WebKit2/Shared/efl/LayerTreeContextEfl.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
Tools/ChangeLog
Tools/MiniBrowser/efl/main.c

index b8e2384..2190143 100644 (file)
@@ -1,3 +1,30 @@
+2012-07-27  YoungTaeck Song  <youngtaeck.song@samsung.com>
+
+        [WK2][EFL] Add an ACCELERATED_COMPOSITING implementation for Efl WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=91581
+
+        Reviewed by Noam Rosenthal.
+
+        This patch is a subset of Efl's UI_SIDE_COMPOSITING implementation.
+        When enter accelerated compositing mode, create evas_gl, evas_gl_context, and evas_gl_surface.
+
+        * PlatformEfl.cmake:
+        * Shared/LayerTreeContext.h:
+        (LayerTreeContext):
+        * UIProcess/API/efl/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::viewSize):
+        (WebKit::PageClientImpl::enterAcceleratedCompositingMode):
+        (WebKit::PageClientImpl::exitAcceleratedCompositingMode):
+        * UIProcess/API/efl/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_Ewk_View_Private_Data::_Ewk_View_Private_Data):
+        (ewk_view_size_get):
+        (ewk_view_create_gl_surface):
+        (ewk_view_enter_accelerated_compositing_mode):
+        (ewk_view_exit_accelerated_compositing_mode):
+        (_ewk_view_smart_calculate):
+        * UIProcess/API/efl/ewk_view_private.h:
+
 2012-07-27  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL][WK2] Add API to Ewk_Cookie_Manager to watch for cookie changes
index b4fa0ac..2327af5 100644 (file)
@@ -20,9 +20,9 @@ LIST(APPEND WebKit2_SOURCES
 
     Shared/API/c/gtk/WKGraphicsContextGtk.cpp
 
-    Shared/cairo/LayerTreeContextCairo.cpp
     Shared/cairo/ShareableBitmapCairo.cpp
 
+    Shared/efl/LayerTreeContextEfl.cpp
     Shared/efl/NativeWebKeyboardEventEfl.cpp
     Shared/efl/NativeWebWheelEventEfl.cpp
     Shared/efl/NativeWebMouseEventEfl.cpp
index 710d9da..388514d 100644 (file)
@@ -58,6 +58,8 @@ public:
     uint32_t webLayerID;
 #elif PLATFORM(GTK)
     uint64_t windowHandle;
+#elif PLATFORM(EFL)
+    uint32_t webLayerID;
 #endif
 };
 
diff --git a/Source/WebKit2/Shared/efl/LayerTreeContextEfl.cpp b/Source/WebKit2/Shared/efl/LayerTreeContextEfl.cpp
new file mode 100644 (file)
index 0000000..881d787
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LayerTreeContext.h"
+
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+
+namespace WebKit {
+
+LayerTreeContext::LayerTreeContext()
+    : webLayerID(0)
+{
+}
+
+LayerTreeContext::~LayerTreeContext()
+{
+}
+
+void LayerTreeContext::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(webLayerID);
+}
+
+bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder* decoder, LayerTreeContext& context)
+{
+    return decoder->decode(context.webLayerID);
+}
+
+bool LayerTreeContext::isEmpty() const
+{
+    return !webLayerID;
+}
+
+bool operator==(const LayerTreeContext& a, const LayerTreeContext& b)
+{
+    return a.webLayerID == b.webLayerID;
+}
+
+} // namespace WebKit
index 118edb1..a1f1ca4 100644 (file)
@@ -72,9 +72,7 @@ void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCor
 
 WebCore::IntSize PageClientImpl::viewSize()
 {
-    int width, height;
-    evas_object_geometry_get(m_viewWidget, 0, 0, &width, &height);
-    return IntSize(width, height);
+    return ewk_view_size_get(m_viewWidget);
 }
 
 bool PageClientImpl::isViewWindowActive()
@@ -221,12 +219,12 @@ void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
 #if USE(ACCELERATED_COMPOSITING)
 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
 {
-    notImplemented();
+    ewk_view_accelerated_compositing_mode_enter(m_viewWidget);
 }
 
 void PageClientImpl::exitAcceleratedCompositingMode()
 {
-    notImplemented();
+    ewk_view_accelerated_compositing_mode_exit(m_viewWidget);
 }
 
 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
index b295307..27d40c1 100644 (file)
 #include <WebCore/EflScreenUtilities.h>
 #include <wtf/text/CString.h>
 
+#if USE(ACCELERATED_COMPOSITING)
+#include <Evas_GL.h>
+#endif
+
 using namespace WebKit;
 using namespace WebCore;
 
@@ -68,6 +72,12 @@ struct _Ewk_View_Private_Data {
     bool isUsingEcoreX;
 #endif
 
+#if USE(ACCELERATED_COMPOSITING)
+    Evas_GL* evasGl;
+    Evas_GL_Context* evasGlContext;
+    Evas_GL_Surface* evasGlSurface;
+#endif
+
     _Ewk_View_Private_Data()
         : uri(0)
         , title(0)
@@ -78,6 +88,11 @@ struct _Ewk_View_Private_Data {
 #ifdef HAVE_ECORE_X
         , isUsingEcoreX(false)
 #endif
+#if USE(ACCELERATED_COMPOSITING)
+        , evasGl(0)
+        , evasGlContext(0)
+        , evasGlSurface(0)
+#endif
     { }
 
     ~_Ewk_View_Private_Data()
@@ -407,6 +422,94 @@ static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord
     _ewk_view_smart_changed(smartData);
 }
 
+IntSize ewk_view_size_get(const Evas_Object* ewkView)
+{
+    int width, height;
+    evas_object_geometry_get(ewkView, 0, 0, &width, &height);
+    return IntSize(width, height);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+    Evas_GL_Config evasGlConfig = {
+        EVAS_GL_RGBA_8888,
+        EVAS_GL_DEPTH_BIT_8,
+        EVAS_GL_STENCIL_NONE,
+        EVAS_GL_OPTIONS_NONE,
+        EVAS_GL_MULTISAMPLE_NONE
+    };
+
+    ASSERT(!priv->evasGlSurface);
+    priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
+    if (!priv->evasGlSurface)
+        return false;
+
+    Evas_Native_Surface nativeSurface;
+    evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
+    evas_object_image_native_surface_set(smartData->image, &nativeSurface);
+
+    return true;
+}
+
+bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+    EINA_SAFETY_ON_NULL_RETURN_VAL(!priv->evasGl, false);
+
+    Evas* evas = evas_object_evas_get(ewkView);
+    priv->evasGl = evas_gl_new(evas);
+    if (!priv->evasGl)
+        return false;
+
+    priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
+    if (!priv->evasGlContext) {
+        evas_gl_free(priv->evasGl);
+        priv->evasGl = 0;
+        return false;
+    }
+
+    if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
+        evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
+        priv->evasGlContext = 0;
+
+        evas_gl_free(priv->evasGl);
+        priv->evasGl = 0;
+        return false;
+    }
+
+    return true;
+}
+
+bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+    EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
+
+    if (priv->evasGlSurface) {
+        evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
+        priv->evasGlSurface = 0;
+    }
+
+    if (priv->evasGlContext) {
+        evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
+        priv->evasGlContext = 0;
+    }
+
+    evas_gl_free(priv->evasGl);
+    priv->evasGl = 0;
+
+    return true;
+}
+#endif
+
 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
@@ -420,6 +523,16 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView)
     if (smartData->changed.size) {
         if (priv->pageClient->page()->drawingArea())
             priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
+
+#if USE(ACCELERATED_COMPOSITING)
+        if (!priv->evasGlSurface)
+            return;
+        evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
+        priv->evasGlSurface = 0;
+        ewk_view_create_gl_surface(ewkView, IntSize(width, height));
+        ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
+#endif
+
         smartData->view.w = width;
         smartData->view.h = height;
         smartData->changed.size = false;
index 43127cf..875f83a 100644 (file)
@@ -73,5 +73,11 @@ void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Ser
 #endif
 
 WebKit::WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView);
+WebCore::IntSize ewk_view_size_get(const Evas_Object* ewkView);
+
+#if USE(ACCELERATED_COMPOSITING)
+bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView);
+bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView);
+#endif
 
 #endif // ewk_view_private_h
index 46e0b28..5053867 100644 (file)
@@ -1,3 +1,16 @@
+2012-07-27  YoungTaeck Song  <youngtaeck.song@samsung.com>
+
+        [WK2][EFL] Add an ACCELERATED_COMPOSITING implementation for Efl WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=91581
+
+        Reviewed by Noam Rosenthal.
+
+        Add a MiniBrowser's option for selecting evas engine.
+
+        * MiniBrowser/efl/main.c:
+        (browserCreate):
+        (main):
+
 2012-07-27  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r123869.
index 17c4300..02630f1 100644 (file)
@@ -43,6 +43,29 @@ typedef struct _MiniBrowser {
     Evas_Object *browser;
 } MiniBrowser;
 
+static const Ecore_Getopt options = {
+    "MiniBrowser",
+    "%prog [options] [url]",
+    "0.0.1",
+    "(C)2012 Samsung Electronics\n",
+    "",
+    "Test Web Browser using the Enlightenment Foundation Libraries of WebKit2",
+    EINA_TRUE, {
+        ECORE_GETOPT_STORE_STR
+            ('e', "engine", "ecore-evas engine to use."),
+        ECORE_GETOPT_CALLBACK_NOARGS
+            ('E', "list-engines", "list ecore-evas engines.",
+             ecore_getopt_callback_ecore_evas_list_engines, NULL),
+        ECORE_GETOPT_VERSION
+            ('V', "version"),
+        ECORE_GETOPT_COPYRIGHT
+            ('R', "copyright"),
+        ECORE_GETOPT_HELP
+            ('h', "help"),
+        ECORE_GETOPT_SENTINEL
+    }
+};
+
 static Eina_Bool main_signal_exit(void *data, int ev_type, void *ev)
 {
     ecore_main_loop_quit();
@@ -154,11 +177,27 @@ on_error(void *user_data, Evas_Object *webview, void *event_info)
     eina_strbuf_free(buffer);
 }
 
-static MiniBrowser *browserCreate(const char *url)
+static int
+quit(Eina_Bool success, const char *msg)
+{
+    ewk_shutdown();
+
+    if (msg)
+        fputs(msg, (success) ? stdout : stderr);
+
+    if (!success)
+        return EXIT_FAILURE;
+
+    return EXIT_SUCCESS;
+}
+
+static MiniBrowser *browserCreate(const char *url, const char *engine)
 {
     MiniBrowser *app = malloc(sizeof(MiniBrowser));
 
-    app->ee = ecore_evas_new(0, 0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 0);
+    app->ee = ecore_evas_new(engine, 0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 0);
+    if (!app->ee)
+        return 0;
 
     ecore_evas_title_set(app->ee, APP_NAME);
     ecore_evas_callback_resize_set(app->ee, on_ecore_evas_resize);
@@ -202,16 +241,38 @@ int main(int argc, char *argv[])
 {
     const char *url;
     int args = 1;
+    char *engine = NULL;
+    unsigned char quitOption = 0;
+
+    Ecore_Getopt_Value values[] = {
+        ECORE_GETOPT_VALUE_STR(engine),
+        ECORE_GETOPT_VALUE_BOOL(quitOption),
+        ECORE_GETOPT_VALUE_BOOL(quitOption),
+        ECORE_GETOPT_VALUE_BOOL(quitOption),
+        ECORE_GETOPT_VALUE_BOOL(quitOption),
+        ECORE_GETOPT_VALUE_NONE
+    };
 
     if (!ewk_init())
         return EXIT_FAILURE;
 
+    ecore_app_args_set(argc, (const char **) argv);
+    args = ecore_getopt_parse(&options, values, argc, argv);
+
+    if (args < 0)
+        return quit(EINA_FALSE, "ERROR: could not parse options.\n");
+
+    if (quitOption)
+        return quit(EINA_TRUE, NULL);
+
     if (args < argc)
         url = argv[args];
     else
         url = DEFAULT_URL;
 
-    MiniBrowser *browser = browserCreate(url);
+    MiniBrowser *browser = browserCreate(url, engine);
+    if (!browser)
+        return quit(EINA_FALSE, "ERROR: could not create browser.\n");
 
     Ecore_Event_Handler *handle = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, 0);
 
@@ -221,7 +282,5 @@ int main(int argc, char *argv[])
     ecore_evas_free(browser->ee);
     free(browser);
 
-    ewk_shutdown();
-
-    return 0;
+    return quit(EINA_TRUE, NULL);
 }