Title: [125804] trunk/Source/WebCore
Revision
125804
Author
[email protected]
Date
2012-08-16 13:11:48 -0700 (Thu, 16 Aug 2012)

Log Message

[Chromium] Changing Canvas2DLayerBridge to use SkDeferredCanvas's notification client API
https://bugs.webkit.org/show_bug.cgi?id=94234

Patch by Justin Novosad <[email protected]> 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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125803 => 125804)


--- trunk/Source/WebCore/ChangeLog	2012-08-16 19:55:52 UTC (rev 125803)
+++ trunk/Source/WebCore/ChangeLog	2012-08-16 20:11:48 UTC (rev 125804)
@@ -1,3 +1,33 @@
+2012-08-16  Justin Novosad  <[email protected]>
+
+        [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  <[email protected]>
 
         [Chromium] Avoid aliasing global symbol monotonicallyIncreasingTime().

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp (125803 => 125804)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp	2012-08-16 19:55:52 UTC (rev 125803)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp	2012-08-16 20:11:48 UTC (rev 125804)
@@ -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 @@
 
 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 @@
     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 @@
     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);
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h (125803 => 125804)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h	2012-08-16 19:55:52 UTC (rev 125803)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h	2012-08-16 20:11:48 UTC (rev 125804)
@@ -29,14 +29,12 @@
 #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 @@
 
 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 @@
     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 @@
 
 private:
     Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, unsigned textureId);
+    SkDeferredCanvas* deferredCanvas();
 
     DeferralMode m_deferralMode;
     bool m_useDoubleBuffering;

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (125803 => 125804)


--- trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-08-16 19:55:52 UTC (rev 125803)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-08-16 20:11:48 UTC (rev 125804)
@@ -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"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to