[Chromium] Changing Canvas2DLayerBridge to use SkDeferredCanvas's notification client API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2012 20:11:48 +0000 (20:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2012 20:11:48 +0000 (20:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94234

Patch by Justin Novosad <junov@chromium.org> on 2012-08-16
Reviewed by James Robinson.

The existing DeviceContext API in skia's SkDeferredCanvas is being
deprecated in favor of the new NotificationClient interface, which is
designed to allow WebKit to control deferred canvas global memory
consumption.

No new tests: this patch does not fix any bug and does not add new
functionality. It is just a transition to a new skia interface.
Coverage is assured by existing tests.

* platform/graphics/chromium/Canvas2DLayerBridge.cpp:
(WebCore):
Removed the AcceleratedDeviceContext class completely and mixed it
into Canvas2DLayerBridge by inheriting
SkDeferredCanvas::NotificationClient
(WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::deferredCanvas):
(WebCore::Canvas2DLayerBridge::prepareForDraw):
(WebCore::Canvas2DLayerBridge::skCanvas):
* platform/graphics/chromium/Canvas2DLayerBridge.h:
(Canvas2DLayerBridge):
* platform/graphics/skia/ImageBufferSkia.cpp:
Cleaning up unnecessary include of SkDeferredCanvas.h

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp
Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

index 66ce9f8..191dff5 100644 (file)
@@ -1,3 +1,33 @@
+2012-08-16  Justin Novosad  <junov@chromium.org>
+
+        [Chromium] Changing Canvas2DLayerBridge to use SkDeferredCanvas's notification client API
+        https://bugs.webkit.org/show_bug.cgi?id=94234
+
+        Reviewed by James Robinson.
+
+        The existing DeviceContext API in skia's SkDeferredCanvas is being
+        deprecated in favor of the new NotificationClient interface, which is
+        designed to allow WebKit to control deferred canvas global memory
+        consumption.
+
+        No new tests: this patch does not fix any bug and does not add new
+        functionality. It is just a transition to a new skia interface.
+        Coverage is assured by existing tests.
+
+        * platform/graphics/chromium/Canvas2DLayerBridge.cpp:
+        (WebCore):
+        Removed the AcceleratedDeviceContext class completely and mixed it
+        into Canvas2DLayerBridge by inheriting
+        SkDeferredCanvas::NotificationClient
+        (WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
+        (WebCore::Canvas2DLayerBridge::deferredCanvas):
+        (WebCore::Canvas2DLayerBridge::prepareForDraw):
+        (WebCore::Canvas2DLayerBridge::skCanvas):
+        * platform/graphics/chromium/Canvas2DLayerBridge.h:
+        (Canvas2DLayerBridge):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        Cleaning up unnecessary include of SkDeferredCanvas.h
+
 2012-08-16  David Reveman  <reveman@chromium.org>
 
         [Chromium] Avoid aliasing global symbol monotonicallyIncreasingTime().
index 821e8ec..db517ca 100644 (file)
@@ -31,8 +31,6 @@
 #include "GraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "LayerRendererChromium.h" // For GLC() macro.
-#include "SkCanvas.h"
-#include "SkDeferredCanvas.h"
 #include "TraceEvent.h"
 #include <public/WebCompositor.h>
 #include <public/WebGraphicsContext3D.h>
@@ -43,31 +41,6 @@ using WebKit::WebTextureUpdater;
 
 namespace WebCore {
 
-class AcceleratedDeviceContext : public SkDeferredCanvas::DeviceContext {
-public:
-    AcceleratedDeviceContext(WebGraphicsContext3D* context, WebExternalTextureLayer layer, bool useDoubleBuffering)
-        : m_layer(layer)
-        , m_context()
-        , m_useDoubleBuffering(useDoubleBuffering)
-    {
-        ASSERT(context);
-        ASSERT(!layer.isNull());
-        m_context = context;
-    }
-
-    virtual void prepareForDraw()
-    {
-        if (!m_useDoubleBuffering)
-            m_layer.willModifyTexture();
-        m_context->makeContextCurrent();
-    }
-
-private:
-    WebExternalTextureLayer m_layer;
-    WebGraphicsContext3D* m_context;
-    bool m_useDoubleBuffering;
-};
-
 Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, unsigned textureId)
     : m_deferralMode(deferralMode)
     // FIXME: We currently turn off double buffering when canvas rendering is
@@ -101,9 +74,10 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context,
     m_layer.setRateLimitContext(!WebKit::WebCompositor::threadingEnabled() || m_useDoubleBuffering);
 }
 
-
 Canvas2DLayerBridge::~Canvas2DLayerBridge()
 {
+    if (SkDeferredCanvas* deferred = deferredCanvas())
+        deferred->setNotificationClient(0);
     m_layer.setTextureId(0);
     if (m_useDoubleBuffering) {
         m_context->makeContextCurrent();
@@ -113,11 +87,28 @@ Canvas2DLayerBridge::~Canvas2DLayerBridge()
     m_layer.clearClient();
 }
 
+SkDeferredCanvas* Canvas2DLayerBridge::deferredCanvas()
+{
+    if (m_deferralMode == Deferred)
+        return static_cast<SkDeferredCanvas*>(m_canvas);
+    return 0;
+}
+
+void Canvas2DLayerBridge::prepareForDraw()
+{
+    ASSERT(deferredCanvas());
+    if (!m_useDoubleBuffering)
+        m_layer.willModifyTexture();
+    m_context->makeContextCurrent();
+}
+
 SkCanvas* Canvas2DLayerBridge::skCanvas(SkDevice* device)
 {
+    ASSERT(!m_canvas);
     if (m_deferralMode == Deferred) {
-        SkAutoTUnref<AcceleratedDeviceContext> deviceContext(new AcceleratedDeviceContext(context(), m_layer, m_useDoubleBuffering));
-        m_canvas = new SkDeferredCanvas(device, deviceContext.get());
+        SkDeferredCanvas* deferred = new SkDeferredCanvas(device);
+        deferred->setNotificationClient(this);
+        m_canvas = deferred;
     } else
         m_canvas = new SkCanvas(device);
 
index 08f401c..409d207 100644 (file)
 #include "GraphicsContext3D.h"
 #include "ImageBuffer.h" // For DeferralMode enum.
 #include "IntSize.h"
+#include "SkDeferredCanvas.h"
 #include <public/WebExternalTextureLayer.h>
 #include <public/WebExternalTextureLayerClient.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
 
-class SkCanvas;
-class SkDevice;
-
 namespace WebKit {
 class WebGraphicsContext3D;
 }
@@ -45,7 +43,7 @@ namespace WebCore {
 
 class LayerChromium;
 
-class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient {
+class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient {
     WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
 public:
     static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, unsigned textureId)
@@ -59,6 +57,9 @@ public:
     virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE;
     virtual WebKit::WebGraphicsContext3D* context() OVERRIDE;
 
+    // SkDeferredCanvas::NotificationClient implementation
+    virtual void prepareForDraw();
+
     SkCanvas* skCanvas(SkDevice*);
     WebKit::WebLayer* layer();
     void contextAcquired();
@@ -67,6 +68,7 @@ public:
 
 private:
     Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, unsigned textureId);
+    SkDeferredCanvas* deferredCanvas();
 
     DeferralMode m_deferralMode;
     bool m_useDoubleBuffering;
index 0d156c9..02b19ee 100644 (file)
@@ -46,7 +46,6 @@
 #include "PlatformContextSkia.h"
 #include "SharedGraphicsContext3D.h"
 #include "SkColorPriv.h"
-#include "SkDeferredCanvas.h"
 #include "SkGpuDevice.h"
 #include "SkiaUtils.h"
 #include "WEBPImageEncoder.h"