Changeset 102448 in webkit


Ignore:
Timestamp:
Dec 9, 2011 1:40:49 AM (12 years ago)
Author:
joone.hur@collabora.co.uk
Message:

[GTK] Initial implementation of Accelerated Compositing using Clutter
https://bugs.webkit.org/show_bug.cgi?id=73319

.:

Reviewed by Gustavo Noronha Silva.

  • GNUmakefile.am: Export new compilation macros.
  • configure.ac: Add clutter backend for Accelerated Compositing.

Source/WebCore:

Reviewed by Gustavo Noronha Silva.

No new tests added as this feature will be able to reuse the existing
CSS3 transforms layout tests.

  • GNUmakefile.am: Include WebCore/platform/graphics/clutter path.
  • GNUmakefile.list.am: Add GraphicsLayerClutter.
  • platform/clutter/GRefPtrClutter.cpp: Added.

(WTF::adoptGRef):
(WTF::ClutterActor):

  • platform/clutter/GRefPtrClutter.h: Added.
  • platform/graphics/GraphicsLayer.h: Define PlatformLayer type, which represents ClutterActor.
  • platform/graphics/clutter/GraphicsLayerClutter.cpp: Boilerplate implementation.

(WebCore::GraphicsLayerClutter::GraphicsLayerClutter):
(WebCore::GraphicsLayerClutter::platformLayer):

  • platform/graphics/clutter/GraphicsLayerClutter.h: Boilerplate implementation.

Source/WebKit/gtk:

This patch allows to add a GtkClutterEmbed to embed Clutter Actors in WebKitWebView and
set the root GraphicsLayer to WebKitWebView when Accelerated Compositing needs to be enabled.

Reviewed by Gustavo Noronha Silva.

  • GNUmakefile.am:
  • WebCoreSupport/ChromeClientGtk.cpp:

(WebKit::ChromeClient::attachRootGraphicsLayer): Set the root GraphicsLayer to WebKitWebView.
(WebKit::ChromeClient::allowedCompositingTriggers): Allow to support CSS 3D Transforms only.

  • webkit/webkitglobals.cpp:

(webkitInit): Call gtk_clutter_init().

  • webkit/webkitwebview.cpp:

(webkit_web_view_size_allocate): Set the size of GtkClutterEmbed when the view is changed.
(webkit_web_view_init)
(webViewSetRootGraphicsLayer): Add the GtkClutterEmbed to the WebKitWebView as a child.
(webViewDetachRootGraphicsLayer): Remove the GtkClutterEmbed from the WebKitWebView.
(webViewSyncLayers): Commit layer changes.
(webViewMarkForSync): Set to call webViewSyncLayers using g_timeout_add.

  • webkit/webkitwebviewprivate.h:
Location:
trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r102324 r102448  
     12011-12-09  Joone Hur  <joone.hur@collabora.co.uk>
     2
     3        [GTK] Initial implementation of Accelerated Compositing using Clutter
     4        https://bugs.webkit.org/show_bug.cgi?id=73319
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        * GNUmakefile.am: Export new compilation macros.
     9        * configure.ac: Add clutter backend for Accelerated Compositing.
     10
    1112011-12-08  Sheriff Bot  <webkit.review.bot@gmail.com>
    212
  • trunk/GNUmakefile.am

    r101869 r102448  
    181181endif
    182182
     183if USE_CLUTTER
     184global_cppflags += \
     185        -DWTF_USE_CLUTTER=1
     186endif
     187
    183188# ----
    184189# GTK+ 2.x/3.x support
  • trunk/Source/WebCore/ChangeLog

    r102447 r102448  
     12011-12-09  Joone Hur  <joone.hur@collabora.co.uk>, Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        [GTK] Initial implementation of Accelerated Compositing using Clutter
     4        https://bugs.webkit.org/show_bug.cgi?id=73319
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        No new tests added as this feature will be able to reuse the existing
     9        CSS3 transforms layout tests.
     10
     11        * GNUmakefile.am: Include WebCore/platform/graphics/clutter path.
     12        * GNUmakefile.list.am: Add GraphicsLayerClutter.
     13        * platform/clutter/GRefPtrClutter.cpp: Added.
     14        (WTF::adoptGRef):
     15        (WTF::ClutterActor):
     16        * platform/clutter/GRefPtrClutter.h: Added.
     17        * platform/graphics/GraphicsLayer.h: Define PlatformLayer type, which represents ClutterActor.
     18        * platform/graphics/clutter/GraphicsLayerClutter.cpp: Boilerplate implementation.
     19        (WebCore::GraphicsLayerClutter::GraphicsLayerClutter):
     20        (WebCore::GraphicsLayerClutter::platformLayer):
     21        * platform/graphics/clutter/GraphicsLayerClutter.h: Boilerplate implementation.
     22
    1232011-12-08  Vsevolod Vlasov  <vsevik@chromium.org>
    224
  • trunk/Source/WebCore/GNUmakefile.am

    r101920 r102448  
    576576endif  # END USETEXTURE_MAPPER_GL
    577577
     578if USE_CLUTTER
     579webcore_cppflags += \
     580        -I$(srcdir)/Source/WebCore/platform/clutter \
     581        -I$(srcdir)/Source/WebCore/platform/graphics/clutter
     582endif  # END USE_CLUTTER
     583
    578584# ---
    579585# MHTML support
     
    802808        -fno-strict-aliasing \
    803809        $(CAIRO_CFLAGS) \
     810        $(CLUTTER_CFLAGS) \
    804811        $(COVERAGE_CFLAGS) \
    805812        $(ENCHANT_CFLAGS) \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r102430 r102448  
    50765076# ---
    50775077if USE_ACCELERATED_COMPOSITING
     5078if USE_CLUTTER
     5079webcore_sources += \
     5080        Source/WebCore/platform/clutter/GRefPtrClutter.cpp \
     5081        Source/WebCore/platform/clutter/GRefPtrClutter.h \
     5082        Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp \
     5083        Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h
     5084endif  # END USE_CLUTTER
     5085
     5086if USE_TEXTURE_MAPPER_CAIRO
    50785087webcore_sources += \
    50795088        Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp \
     
    50835092        Source/WebCore/platform/graphics/texmap/TextureMapperNode.h \
    50845093        Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
    5085 if USE_TEXTURE_MAPPER_CAIRO
    50865094webcoregtk_sources += \
    50875095        Source/WebCore/platform/graphics/cairo/TextureMapperCairo.cpp \
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r102092 r102448  
    7575typedef TextureMapperPlatformLayer PlatformLayer;
    7676};
     77#elif USE(CLUTTER)
     78typedef struct _ClutterActor ClutterActor;
     79namespace WebCore {
     80typedef ClutterActor PlatformLayer;
     81};
    7782#endif
    7883#else
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp

    r95901 r102448  
    4242    : GraphicsLayer(client)
    4343{
     44    // ClutterRectangle will be used to show the debug border.
     45    m_layer = adoptGRef(clutter_rectangle_new());
    4446}
    4547
    4648GraphicsLayerClutter::~GraphicsLayerClutter()
    4749{
     50}
     51
     52ClutterActor* GraphicsLayerClutter::platformLayer() const
     53{
     54    return m_layer.get();
    4855}
    4956
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h

    r95901 r102448  
    3030#if USE(ACCELERATED_COMPOSITING)
    3131
     32#include "GRefPtrClutter.h"
    3233#include "GraphicsLayer.h"
     34
     35#include <clutter/clutter.h>
    3336
    3437namespace WebCore {
     
    3942    virtual ~GraphicsLayerClutter();
    4043
     44    virtual ClutterActor* platformLayer() const;
    4145    virtual void setNeedsDisplay();
    4246    virtual void setNeedsDisplayInRect(const FloatRect&);
     47
     48private:
     49    GRefPtr<ClutterActor> m_layer;
    4350};
    4451
  • trunk/Source/WebKit/gtk/ChangeLog

    r102235 r102448  
     12011-12-09  Joone Hur  <joone.hur@collabora.co.uk>
     2
     3        [GTK] Initial implementation of Accelerated Compositing using Clutter
     4        https://bugs.webkit.org/show_bug.cgi?id=73319
     5
     6        This patch allows to add a GtkClutterEmbed to embed Clutter Actors in WebKitWebView and
     7        set the root GraphicsLayer to WebKitWebView when Accelerated Compositing needs to be enabled.
     8
     9        Reviewed by Gustavo Noronha Silva.
     10
     11        * GNUmakefile.am:
     12        * WebCoreSupport/ChromeClientGtk.cpp:
     13        (WebKit::ChromeClient::attachRootGraphicsLayer): Set the root GraphicsLayer to WebKitWebView.
     14        (WebKit::ChromeClient::allowedCompositingTriggers): Allow to support CSS 3D Transforms only.
     15        * webkit/webkitglobals.cpp:
     16        (webkitInit): Call gtk_clutter_init().
     17        * webkit/webkitwebview.cpp:
     18        (webkit_web_view_size_allocate): Set the size of GtkClutterEmbed when the view is changed.
     19        (webkit_web_view_init)
     20        (webViewSetRootGraphicsLayer): Add the GtkClutterEmbed to the WebKitWebView as a child.
     21        (webViewDetachRootGraphicsLayer): Remove the GtkClutterEmbed from the WebKitWebView.
     22        (webViewSyncLayers): Commit layer changes.
     23        (webViewMarkForSync): Set to call webViewSyncLayers using g_timeout_add.
     24        * webkit/webkitwebviewprivate.h:
     25
    1262011-12-07  Mary Wu  <mary.wu@torchmobile.com.cn>
    227
  • trunk/Source/WebKit/gtk/GNUmakefile.am

    r101174 r102448  
    5959        -fno-strict-aliasing \
    6060        $(HILDON_CPPFLAGS) \
     61        $(CLUTTER_CFLAGS) \
     62        $(CLUTTER_GTK_CFLAGS) \
    6163        $(COVERAGE_CFLAGS) \
    6264        $(ENCHANT_CFLAGS) \
     
    8890        $(webcore_ldflags) \
    8991        $(CAIRO_LIBS) \
     92        $(CLUTTER_LIBS) \
     93        $(CLUTTER_GTK_LIBS) \
    9094        $(COVERAGE_LDFLAGS) \
    9195        $(ENCHANT_LIBS) \
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r101920 r102448  
    913913void ChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* rootLayer)
    914914{
    915     webViewSetRootGraphicsLayer(m_webView, rootLayer);
     915    if (rootLayer)
     916        webViewSetRootGraphicsLayer(m_webView, rootLayer);
     917    else
     918        webViewDetachRootGraphicsLayer(m_webView);
    916919}
    917920
     
    928931ChromeClient::CompositingTriggerFlags ChromeClient::allowedCompositingTriggers() const
    929932{
     933     if (!platformPageClient())
     934        return false;
     935#if USE(CLUTTER)
     936    // Currently, we only support CSS 3D Transforms.
     937    return ThreeDTransformTrigger;
     938#else
    930939    return AllTriggers;
    931 }
    932940#endif
    933 
    934 }
     941}
     942#endif
     943
     944}
  • trunk/Source/WebKit/gtk/webkit/webkitglobals.cpp

    r102235 r102448  
    5353#include <wtf/MainThread.h>
    5454
     55#if USE(CLUTTER)
     56#include <clutter-gtk/clutter-gtk.h>
     57#endif
     58
    5559static WebKitCacheModel cacheModel = WEBKIT_CACHE_MODEL_DEFAULT;
    5660
     
    341345    soup_session_add_feature_by_type(session, SOUP_TYPE_CONTENT_DECODER);
    342346
     347#if USE(CLUTTER)
     348    gtk_clutter_init(0, 0);
     349#endif
     350
    343351    atexit(webkitExit);
    344352}
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r101641 r102448  
    857857    chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
    858858    chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars();
     859
     860#if USE(ACCELERATED_COMPOSITING) && USE(CLUTTER)
     861    if (webView->priv->rootLayerEmbedder) {
     862        allocation->x = 0;
     863        allocation->y = 0;
     864        gtk_widget_size_allocate(GTK_WIDGET(webView->priv->rootLayerEmbedder), allocation);
     865    }
     866#endif
    859867}
    860868
     
    48864894void webViewSetRootGraphicsLayer(WebKitWebView* webView, GraphicsLayer* graphicsLayer)
    48874895{
     4896#if USE(CLUTTER)
     4897    WebKitWebViewPrivate* priv = webView->priv;
     4898
     4899    // Create an instance of GtkClutterEmbed to host actors as web layers.
     4900    if (!priv->rootLayerEmbedder) {
     4901        priv->rootLayerEmbedder = gtk_clutter_embed_new();
     4902        gtk_container_add(GTK_CONTAINER(webView), priv->rootLayerEmbedder);
     4903        gtk_widget_show(priv->rootLayerEmbedder);
     4904    }
     4905
     4906    // Add a root layer to the stage.
     4907    if (graphicsLayer) {
     4908        priv->rootGraphicsLayer = graphicsLayer;
     4909        // set white background
     4910        ClutterColor stageColor = { 0xFF, 0xFF, 0xFF, 0xFF };
     4911        ClutterActor* stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->rootLayerEmbedder));
     4912        clutter_stage_set_color(CLUTTER_STAGE (stage), &stageColor);
     4913        clutter_container_add_actor(CLUTTER_CONTAINER(stage), priv->rootGraphicsLayer->platformLayer());
     4914        clutter_actor_show_all(stage);
     4915    }
     4916#else
    48884917    notImplemented();
    4889 }
     4918#endif
     4919}
     4920
     4921void webViewDetachRootGraphicsLayer(WebKitWebView* webView)
     4922{
     4923#if USE(CLUTTER)
     4924    WebKitWebViewPrivate* priv = webView->priv;
     4925    // Detach the root layer from the hosting view.
     4926    gtk_container_remove(GTK_CONTAINER(webView), priv->rootLayerEmbedder);
     4927    priv->rootLayerEmbedder = 0;
     4928    priv->rootGraphicsLayer = 0;
     4929#else
     4930    notImplemented();
     4931#endif
     4932}
     4933
     4934#if USE(CLUTTER)
     4935static gboolean webViewSyncLayers(gpointer data)
     4936{
     4937    WebKitWebView* webView = WEBKIT_WEB_VIEW(data);
     4938    core(webView)->mainFrame()->view()->syncCompositingStateIncludingSubframes();
     4939
     4940    return FALSE;
     4941}
     4942#endif
    48904943
    48914944void webViewMarkForSync(WebKitWebView* webView, gboolean scheduleSync)
    48924945{
     4946#if USE(CLUTTER)
     4947    g_timeout_add(0, webViewSyncLayers, webView);
     4948#else
    48934949    notImplemented();
    4894 }
     4950#endif
     4951}
     4952
    48954953#endif
    48964954
  • trunk/Source/WebKit/gtk/webkit/webkitwebviewprivate.h

    r101548 r102448  
    3232#include "WidgetBackingStore.h"
    3333#include <webkit/webkitwebview.h>
     34
     35#if USE(ACCELERATED_COMPOSITING) && USE(CLUTTER)
     36#include <clutter-gtk/clutter-gtk.h>
     37#include <clutter/clutter.h>
     38#endif
    3439
    3540namespace WebKit {
     
    9398    WebCore::GtkDragAndDropHelper dragAndDropHelper;
    9499    bool selfScrolling;
     100#if USE(ACCELERATED_COMPOSITING) && USE(CLUTTER)
     101    WebCore::GraphicsLayer* rootGraphicsLayer;
     102    GtkWidget* rootLayerEmbedder;
     103#endif
    95104};
    96105
     
    115124#if USE(ACCELERATED_COMPOSITING)
    116125void webViewSetRootGraphicsLayer(WebKitWebView*, WebCore::GraphicsLayer*);
     126void webViewDetachRootGraphicsLayer(WebKitWebView*);
    117127void webViewMarkForSync(WebKitWebView*, gboolean);
    118128#endif
  • trunk/configure.ac

    r101917 r102448  
    287287ENCHANT_REQUIRED_VERSION=0.22
    288288LIBFFTW_REQUIRED_VERSION=3.2.2
     289CLUTTER_REQUIRED_VERSION=1.8.2
     290CLUTTER_GTK_REQUIRED_VERSION=1.0.2
    289291
    290292# Available modules
     
    398400AC_MSG_CHECKING([whether to enable accelerated compositing support])
    399401AC_ARG_WITH(accelerated_compositing,
    400             AC_HELP_STRING([--with-accelerated-compositing=@<:@no/opengl/cairo@:>@],
     402            AC_HELP_STRING([--with-accelerated-compositing=@<:@no/opengl/cairo/clutter@:>@],
    401403                           [use accelerated compositing (experimental) [default=no]]),
    402404            [], [with_accelerated_compositing="no"])
     
    10831085fi
    10841086
     1087if test "$with_accelerated_compositing" = "clutter"; then
     1088   PKG_CHECK_MODULES(CLUTTER, clutter-1.0 >= $CLUTTER_REQUIRED_VERSION)
     1089   PKG_CHECK_MODULES([CLUTTER_GTK],
     1090                     [clutter-gtk-1.0 >= $CLUTTER_GTK_REQUIRED_VERSION])
     1091
     1092   AC_SUBST(CLUTTER_CFLAGS)
     1093   AC_SUBST(CLUTTER_LIBS)
     1094   AC_SUBST(CLUTTER_GTK_CFLAGS)
     1095   AC_SUBST(CLUTTER_GTK_LIBS)
     1096fi
     1097
    10851098# check for code coverage support
    10861099if test "$enable_coverage" = "yes"; then
     
    11571170
    11581171# Accelerated compositing conditional
    1159 AM_CONDITIONAL([USE_ACCELERATED_COMPOSITING], [test "$with_accelerated_compositing" = "cairo" || test "$with_accelerated_compositing" = "opengl"])
     1172AM_CONDITIONAL([USE_ACCELERATED_COMPOSITING], [test "$with_accelerated_compositing" = "cairo" || test "$with_accelerated_compositing" = "opengl" || test "$with_accelerated_compositing" = "clutter"])
    11601173AM_CONDITIONAL([USE_TEXTURE_MAPPER_CAIRO], [test "$with_accelerated_compositing" = "cairo"])
    11611174AM_CONDITIONAL([USE_TEXTURE_MAPPER_GL], [test "$with_accelerated_compositing" = "opengl"])
     1175AM_CONDITIONAL([USE_CLUTTER], [test "$with_accelerated_compositing" = "clutter"])
    11621176
    11631177# WebKit feature conditionals
Note: See TracChangeset for help on using the changeset viewer.