[chromium] Create GraphicsLayerChromiums using a factory
authorvollick@chromium.org <vollick@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2013 04:36:33 +0000 (04:36 +0000)
committervollick@chromium.org <vollick@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2013 04:36:33 +0000 (04:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103635

Reviewed by James Robinson.

Refactor graphics layer creation for chromium to go through a factory.

Source/WebCore:

No new tests, no change in functionality.

* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayer::create):

Source/WebKit/chromium:

* src/ChromeClientImpl.cpp:
(WebCore):
(GraphicsLayerFactoryChromium):
(WebCore::GraphicsLayerFactoryChromium::~GraphicsLayerFactoryChromium):
(WebKit::ChromeClientImpl::ChromeClientImpl):
(WebKit::ChromeClientImpl::graphicsLayerFactory):
(WebKit):
* src/ChromeClientImpl.h:
(WebCore):
(ChromeClientImpl):
* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::NonCompositedContentHost):
* src/NonCompositedContentHost.h:
(WebCore):
(WebKit::NonCompositedContentHost::create):
(NonCompositedContentHost):
* src/PageOverlay.cpp:
(WebKit::PageOverlay::update):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::graphicsLayerFactory):
(WebKit):
(WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
* src/WebViewImpl.h:
(WebCore):
(WebViewImpl):
* tests/GraphicsLayerChromiumTest.cpp:
(WebKit::GraphicsLayerChromiumTest::GraphicsLayerChromiumTest):
* tests/ImageLayerChromiumTest.cpp:
(WebCore::TEST):

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/ChromeClientImpl.cpp
Source/WebKit/chromium/src/ChromeClientImpl.h
Source/WebKit/chromium/src/NonCompositedContentHost.cpp
Source/WebKit/chromium/src/NonCompositedContentHost.h
Source/WebKit/chromium/src/PageOverlay.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp

index e83c46a..a481cf0 100644 (file)
@@ -1,3 +1,17 @@
+2013-01-15  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] Create GraphicsLayerChromiums using a factory
+        https://bugs.webkit.org/show_bug.cgi?id=103635
+
+        Reviewed by James Robinson.
+
+        Refactor graphics layer creation for chromium to go through a factory.
+
+        No new tests, no change in functionality.
+
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayer::create):
+
 2013-01-15  Charles Wei  <charles.wei@torchmobile.com.cn>
 
         [BlackBerry]  LayerRenderingResults doesn't need to maintain the hole punch rect
index 549afb5..25387a2 100644 (file)
@@ -84,15 +84,13 @@ namespace WebCore {
 
 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
 {
-    if (!factory)
-        return adoptPtr(new GraphicsLayerChromium(client));
-
     return factory->createGraphicsLayer(client);
 }
 
 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
 {
-    return adoptPtr(new GraphicsLayerChromium(client));
+    ASSERT_NOT_REACHED();
+    return nullptr;
 }
 
 GraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client)
index 04d9ed7..714a6c0 100644 (file)
@@ -1,3 +1,42 @@
+2013-01-15  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] Create GraphicsLayerChromiums using a factory
+        https://bugs.webkit.org/show_bug.cgi?id=103635
+
+        Reviewed by James Robinson.
+
+        Refactor graphics layer creation for chromium to go through a factory.
+
+        * src/ChromeClientImpl.cpp:
+        (WebCore):
+        (GraphicsLayerFactoryChromium):
+        (WebCore::GraphicsLayerFactoryChromium::~GraphicsLayerFactoryChromium):
+        (WebKit::ChromeClientImpl::ChromeClientImpl):
+        (WebKit::ChromeClientImpl::graphicsLayerFactory):
+        (WebKit):
+        * src/ChromeClientImpl.h:
+        (WebCore):
+        (ChromeClientImpl):
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::NonCompositedContentHost):
+        * src/NonCompositedContentHost.h:
+        (WebCore):
+        (WebKit::NonCompositedContentHost::create):
+        (NonCompositedContentHost):
+        * src/PageOverlay.cpp:
+        (WebKit::PageOverlay::update):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::graphicsLayerFactory):
+        (WebKit):
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        * src/WebViewImpl.h:
+        (WebCore):
+        (WebViewImpl):
+        * tests/GraphicsLayerChromiumTest.cpp:
+        (WebKit::GraphicsLayerChromiumTest::GraphicsLayerChromiumTest):
+        * tests/ImageLayerChromiumTest.cpp:
+        (WebCore::TEST):
+
 2013-01-15  Mark Pilgrim  <pilgrim@chromium.org>
 
         [Chromium] Move SocketStreamHandle and SocketStreamHandleInternal to WebCore/platform
index f4c8f52..227fee7 100644 (file)
@@ -57,7 +57,8 @@
 #include "FrameLoadRequest.h"
 #include "FrameView.h"
 #include "Geolocation.h"
-#include "GraphicsLayer.h"
+#include "GraphicsLayerChromium.h"
+#include "GraphicsLayerFactory.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
 
 using namespace WebCore;
 
+namespace {
+
+class GraphicsLayerFactoryChromium : public GraphicsLayerFactory {
+public:
+    virtual ~GraphicsLayerFactoryChromium() { }
+
+    virtual PassOwnPtr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient* client) OVERRIDE
+    {
+        return adoptPtr(new GraphicsLayerChromium(client));
+    }
+};
+
+} // namespace
+
 namespace WebKit {
 
 // Converts a WebCore::PopupContainerType to a WebKit::WebPopupType.
@@ -145,6 +160,9 @@ ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
 #if ENABLE(PAGE_POPUP)
     , m_pagePopupDriver(webView)
 #endif
+#if USE(ACCELERATED_COMPOSITING)
+    , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium))
+#endif
 {
 }
 
@@ -932,6 +950,11 @@ bool ChromeClientImpl::paintCustomOverhangArea(GraphicsContext* context, const I
 }
 
 #if USE(ACCELERATED_COMPOSITING)
+GraphicsLayerFactory* ChromeClientImpl::graphicsLayerFactory() const
+{
+    return m_graphicsLayerFactory.get();
+}
+
 void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
 {
     m_webView->setRootGraphicsLayer(graphicsLayer);
index a697d4c..d2ad111 100644 (file)
@@ -38,6 +38,7 @@
 #include "SearchPopupMenu.h"
 #include "WebNavigationPolicy.h"
 #include <public/WebColor.h>
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -46,6 +47,7 @@ class ColorChooser;
 class ColorChooserClient;
 class Element;
 class FileChooser;
+class GraphicsLayerFactory;
 class PopupContainer;
 class PopupMenuClient;
 class RenderBox;
@@ -163,6 +165,8 @@ public:
 #endif
 
 #if USE(ACCELERATED_COMPOSITING)
+    virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE;
+
     // Pass 0 as the GraphicsLayer to detatch the root layer.
     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
 
@@ -244,6 +248,10 @@ private:
 #if ENABLE(PAGE_POPUP)
     WebCore::PagePopupDriver* m_pagePopupDriver;
 #endif
+
+#if USE(ACCELERATED_COMPOSITING)
+    OwnPtr<WebCore::GraphicsLayerFactory> m_graphicsLayerFactory;
+#endif
 };
 
 class NavigatorContentUtilsClientImpl : public WebCore::NavigatorContentUtilsClient {
index 48e2fc1..9d07b44 100644 (file)
 
 namespace WebKit {
 
-NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView)
+NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView, WebCore::GraphicsLayerFactory* graphicsLayerFactory)
     : m_webView(webView)
     , m_showDebugBorders(false)
 {
-    m_graphicsLayer = WebCore::GraphicsLayer::create(0, this);
+    m_graphicsLayer = WebCore::GraphicsLayer::create(graphicsLayerFactory, this);
 #ifndef NDEBUG
     m_graphicsLayer->setName("non-composited content");
 #endif
index 609538a..6467cc4 100644 (file)
@@ -37,6 +37,7 @@
 namespace WebCore {
 class Color;
 class GraphicsLayer;
+class GraphicsLayerFactory;
 class GraphicsContext;
 class IntPoint;
 class IntRect;
@@ -48,9 +49,9 @@ class WebViewImpl;
 class NonCompositedContentHost : public WebCore::GraphicsLayerClient {
 WTF_MAKE_NONCOPYABLE(NonCompositedContentHost);
 public:
-    static PassOwnPtr<NonCompositedContentHost> create(WebViewImpl* webView)
+    static PassOwnPtr<NonCompositedContentHost> create(WebViewImpl* webView, WebCore::GraphicsLayerFactory* graphicsLayerFactory)
     {
-        return adoptPtr(new NonCompositedContentHost(webView));
+        return adoptPtr(new NonCompositedContentHost(webView, graphicsLayerFactory));
     }
     virtual ~NonCompositedContentHost();
 
@@ -64,7 +65,7 @@ public:
     void setShowDebugBorders(bool);
 
 protected:
-    explicit NonCompositedContentHost(WebViewImpl*);
+    NonCompositedContentHost(WebViewImpl*, WebCore::GraphicsLayerFactory*);
 
 private:
     // GraphicsLayerClient
index c95687a..9823abb 100644 (file)
@@ -126,7 +126,7 @@ void PageOverlay::update()
 #if USE(ACCELERATED_COMPOSITING)
     if (!m_layer) {
         m_layerClient = OverlayGraphicsLayerClientImpl::create(m_viewImpl, m_overlay);
-        m_layer = GraphicsLayer::create(m_layerClient.get());
+        m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_layerClient.get());
         m_layer->setName("WebViewImpl page overlay content");
         m_layer->setDrawsContent(true);
     }
index dbb8c81..b6c4d8d 100644 (file)
@@ -3947,6 +3947,11 @@ void WebViewImpl::setBackgroundColor(const WebCore::Color& color)
     m_layerTreeView->setBackgroundColor(webDocumentBackgroundColor);
 }
 
+WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const
+{
+    return m_chromeClientImpl.graphicsLayerFactory();
+}
+
 WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer()
 {
     return m_rootGraphicsLayer;
@@ -4030,7 +4035,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
         layerTreeViewSettings.defaultTileSize = settingsImpl()->defaultTileSize();
         layerTreeViewSettings.maxUntiledLayerSize = settingsImpl()->maxUntiledLayerSize();
 
-        m_nonCompositedContentHost = NonCompositedContentHost::create(this);
+        m_nonCompositedContentHost = NonCompositedContentHost::create(this, graphicsLayerFactory());
         m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders());
         m_nonCompositedContentHost->setOpaque(!isTransparent());
 
index cea5748..41549a8 100644 (file)
@@ -68,6 +68,7 @@ class DocumentLoader;
 class FloatSize;
 class Frame;
 class GraphicsContext3D;
+class GraphicsLayerFactory;
 class HistoryItem;
 class HitTestResult;
 class KeyboardEvent;
@@ -543,6 +544,7 @@ public:
     void paintRootLayer(WebCore::GraphicsContext&, const WebCore::IntRect& contentRect);
     NonCompositedContentHost* nonCompositedContentHost();
     void setBackgroundColor(const WebCore::Color&);
+    WebCore::GraphicsLayerFactory* graphicsLayerFactory() const;
 #endif
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     void scheduleAnimation();
index 7d9c2ec..44af5f5 100644 (file)
@@ -60,7 +60,7 @@ public:
     GraphicsLayerChromiumTest()
     {
         Platform::current()->compositorSupport()->initialize(0);
-        m_graphicsLayer = static_pointer_cast<GraphicsLayerChromium>(GraphicsLayer::create(&m_client));
+        m_graphicsLayer = adoptPtr(new GraphicsLayerChromium(&m_client));
         m_platformLayer = m_graphicsLayer->platformLayer();
         m_layerTreeView = adoptPtr(Platform::current()->compositorSupport()->createLayerTreeView(&m_layerTreeViewClient, *m_platformLayer, WebLayerTreeView::Settings()));
         m_layerTreeView->setViewportSize(WebSize(1, 1), WebSize(1, 1));
index 1a6f909..c87b7ac 100644 (file)
@@ -110,7 +110,7 @@ private:
 TEST(ImageLayerChromiumTest, opaqueImages)
 {
     MockGraphicsLayerClient client;
-    OwnPtr<GraphicsLayerChromium> graphicsLayer = static_pointer_cast<GraphicsLayerChromium>(GraphicsLayer::create(&client));
+    OwnPtr<GraphicsLayerChromium> graphicsLayer = adoptPtr(new GraphicsLayerChromium(&client));
     ASSERT_TRUE(graphicsLayer.get());
 
     RefPtr<Image> opaqueImage = TestImage::create(IntSize(100, 100), true);