Title: [120142] trunk/Source
Revision
120142
Author
[email protected]
Date
2012-06-12 17:10:03 -0700 (Tue, 12 Jun 2012)

Log Message

[chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
https://bugs.webkit.org/show_bug.cgi?id=88597

Patch by James Robinson <[email protected]> on 2012-06-12
Reviewed by Adrienne Walker.

Source/Platform:

This adds two new APIs to WebExternalTextureLayer that are used by the accelerated 2d canvas path:
- willModifyTexture() is called to indicate that a system outside the compositor's control is about to modify
the texture backing the WebExternalTextureLayer. This indicates to the compositor that it needs to avoid
producing more frames using this texture until it can do a full commit - either by double buffering or
appropriate flow control.

- setRateLimitContext() is called to enable rate limiting for this texture. The rate limiting logic blocks if
too many invalidate() or invalidateRect() calls are made on the texture outside of the context of a
WebLayerTreeViewClient::updateAnimations() call to prevent a non-vsynced producer from getting too far ahead of
the compositor.

* chromium/public/WebExternalTextureLayer.h:
(WebKit::WebExternalTextureLayer::WebExternalTextureLayer):
(WebExternalTextureLayer):

Source/WebCore:

This converts Canvas2DLayerBridge to using public WebLayer API types instead of LayerChromium types.

* platform/graphics/chromium/Canvas2DLayerBridge.cpp:
(WebCore::AcceleratedDeviceContext::AcceleratedDeviceContext):
(WebCore::AcceleratedDeviceContext::prepareForDraw):
(AcceleratedDeviceContext):
(WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::skCanvas):
(WebCore::Canvas2DLayerBridge::prepareTexture):
(WebCore::Canvas2DLayerBridge::context):
(WebCore::Canvas2DLayerBridge::layer):
(WebCore::Canvas2DLayerBridge::contextAcquired):
* platform/graphics/chromium/Canvas2DLayerBridge.h:
(WebCore):
(Canvas2DLayerBridge):

Source/WebKit/chromium:

Implementations for new WebExternalTextureLayer APIs, updates test.

* src/WebExternalTextureLayer.cpp:
(WebKit::WebExternalTextureLayer::willModifyTexture):
(WebKit):
(WebKit::WebExternalTextureLayer::setRateLimitContext):
* tests/Canvas2DLayerBridgeTest.cpp:
(Canvas2DLayerBridgeTest::fullLifecycleTest):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (120141 => 120142)


--- trunk/Source/Platform/ChangeLog	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/Platform/ChangeLog	2012-06-13 00:10:03 UTC (rev 120142)
@@ -1,3 +1,25 @@
+2012-06-12  James Robinson  <[email protected]>
+
+        [chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
+        https://bugs.webkit.org/show_bug.cgi?id=88597
+
+        Reviewed by Adrienne Walker.
+
+        This adds two new APIs to WebExternalTextureLayer that are used by the accelerated 2d canvas path:
+        - willModifyTexture() is called to indicate that a system outside the compositor's control is about to modify
+        the texture backing the WebExternalTextureLayer. This indicates to the compositor that it needs to avoid
+        producing more frames using this texture until it can do a full commit - either by double buffering or
+        appropriate flow control.
+
+        - setRateLimitContext() is called to enable rate limiting for this texture. The rate limiting logic blocks if
+        too many invalidate() or invalidateRect() calls are made on the texture outside of the context of a
+        WebLayerTreeViewClient::updateAnimations() call to prevent a non-vsynced producer from getting too far ahead of
+        the compositor.
+
+        * chromium/public/WebExternalTextureLayer.h:
+        (WebKit::WebExternalTextureLayer::WebExternalTextureLayer):
+        (WebExternalTextureLayer):
+
 2012-06-11  James Robinson  <[email protected]>
 
         [chromium] Port DrawingBufferChromium from TextureLayerChromium over to WebExternalTextureLayer

Modified: trunk/Source/Platform/chromium/public/WebExternalTextureLayer.h (120141 => 120142)


--- trunk/Source/Platform/chromium/public/WebExternalTextureLayer.h	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/Platform/chromium/public/WebExternalTextureLayer.h	2012-06-13 00:10:03 UTC (rev 120142)
@@ -76,6 +76,13 @@
     // Sets whether this layer's texture has premultiplied alpha or not. Defaults to true.
     WEBKIT_EXPORT void setPremultipliedAlpha(bool);
 
+    // Indicates that the most recently provided texture ID is about to be modified externally.
+    WEBKIT_EXPORT void willModifyTexture();
+
+    // Sets whether this context should be rate limited by the compositor. Rate limiting works by blocking
+    // invalidate() and invalidateRect() calls if the compositor is too many frames behind.
+    WEBKIT_EXPORT void setRateLimitContext(bool);
+
 private:
 #if WEBKIT_IMPLEMENTATION
     explicit WebExternalTextureLayer(PassRefPtr<WebCore::TextureLayerChromium>);

Modified: trunk/Source/WebCore/ChangeLog (120141 => 120142)


--- trunk/Source/WebCore/ChangeLog	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/WebCore/ChangeLog	2012-06-13 00:10:03 UTC (rev 120142)
@@ -1,3 +1,27 @@
+2012-06-12  James Robinson  <[email protected]>
+
+        [chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
+        https://bugs.webkit.org/show_bug.cgi?id=88597
+
+        Reviewed by Adrienne Walker.
+
+        This converts Canvas2DLayerBridge to using public WebLayer API types instead of LayerChromium types.
+
+        * platform/graphics/chromium/Canvas2DLayerBridge.cpp:
+        (WebCore::AcceleratedDeviceContext::AcceleratedDeviceContext):
+        (WebCore::AcceleratedDeviceContext::prepareForDraw):
+        (AcceleratedDeviceContext):
+        (WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
+        (WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
+        (WebCore::Canvas2DLayerBridge::skCanvas):
+        (WebCore::Canvas2DLayerBridge::prepareTexture):
+        (WebCore::Canvas2DLayerBridge::context):
+        (WebCore::Canvas2DLayerBridge::layer):
+        (WebCore::Canvas2DLayerBridge::contextAcquired):
+        * platform/graphics/chromium/Canvas2DLayerBridge.h:
+        (WebCore):
+        (Canvas2DLayerBridge):
+
 2012-06-12  Alexis Menard  <[email protected]>
 
         Fix packing in StyleBoxData for Windows.

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


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp	2012-06-13 00:10:03 UTC (rev 120142)
@@ -33,34 +33,38 @@
 #include "LayerRendererChromium.h" // For GLC() macro.
 #include "SkCanvas.h"
 #include "SkDeferredCanvas.h"
-#include "TextureLayerChromium.h"
 #include "cc/CCProxy.h"
 #include "cc/CCTextureUpdater.h"
+#include <public/WebGraphicsContext3D.h>
 
+using WebKit::WebExternalTextureLayer;
+using WebKit::WebGraphicsContext3D;
+using WebKit::WebTextureUpdater;
+
 namespace WebCore {
 
 class AcceleratedDeviceContext : public SkDeferredCanvas::DeviceContext {
 public:
-    AcceleratedDeviceContext(GraphicsContext3D* context, TextureLayerChromium* layer, bool useDoubleBuffering)
+    AcceleratedDeviceContext(WebGraphicsContext3D* context, WebExternalTextureLayer layer, bool useDoubleBuffering)
         : m_layer(layer)
         , m_context()
         , m_useDoubleBuffering(useDoubleBuffering)
     {
         ASSERT(context);
-        ASSERT(layer);
+        ASSERT(!layer.isNull());
         m_context = context;
     }
 
     virtual void prepareForDraw()
     {
         if (!m_useDoubleBuffering)
-            m_layer->willModifyTexture();
+            m_layer.willModifyTexture();
         m_context->makeContextCurrent();
     }
 
 private:
-    TextureLayerChromium* m_layer;
-    GraphicsContext3D* m_context;
+    WebExternalTextureLayer m_layer;
+    WebGraphicsContext3D* m_context;
     bool m_useDoubleBuffering;
 };
 
@@ -92,27 +96,27 @@
             grContext->resetContext();
     }
 
-    m_layer = TextureLayerChromium::create(this);
-    m_layer->setTextureId(textureId);
-    m_layer->setRateLimitContext(!CCProxy::hasImplThread() || m_useDoubleBuffering);
+    m_layer = WebExternalTextureLayer::create(this);
+    m_layer.setTextureId(textureId);
+    m_layer.setRateLimitContext(!CCProxy::hasImplThread() || m_useDoubleBuffering);
 }
 
 
 Canvas2DLayerBridge::~Canvas2DLayerBridge()
 {
-    m_layer->setTextureId(0);
+    m_layer.setTextureId(0);
     if (m_useDoubleBuffering) {
         m_context->makeContextCurrent();
         GLC(m_context.get(), m_context->deleteTexture(m_frontBufferTexture));
         m_context->flush();
     }
-    m_layer->clearClient();
+    m_layer.clearClient();
 }
 
 SkCanvas* Canvas2DLayerBridge::skCanvas(SkDevice* device)
 {
     if (m_deferralMode == Deferred) {
-        SkAutoTUnref<AcceleratedDeviceContext> deviceContext(new AcceleratedDeviceContext(m_context.get(), m_layer.get(), m_useDoubleBuffering));
+        SkAutoTUnref<AcceleratedDeviceContext> deviceContext(new AcceleratedDeviceContext(context(), m_layer, m_useDoubleBuffering));
         m_canvas = new SkDeferredCanvas(device, deviceContext.get());
     } else
         m_canvas = new SkCanvas(device);
@@ -121,7 +125,7 @@
 }
 
 
-unsigned Canvas2DLayerBridge::prepareTexture(CCTextureUpdater& updater)
+unsigned Canvas2DLayerBridge::prepareTexture(WebTextureUpdater& updater)
 {
     m_context->makeContextCurrent();
 
@@ -140,20 +144,20 @@
     return m_backBufferTexture;
 }
 
-WebKit::WebGraphicsContext3D* Canvas2DLayerBridge::context()
+WebGraphicsContext3D* Canvas2DLayerBridge::context()
 {
     return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_context.get());
 }
 
 LayerChromium* Canvas2DLayerBridge::layer() const
 {
-    return m_layer.get();
+    return m_layer.unwrap<LayerChromium>();
 }
 
 void Canvas2DLayerBridge::contextAcquired()
 {
     if (m_deferralMode == NonDeferred && !m_useDoubleBuffering)
-        m_layer->willModifyTexture();
+        m_layer.willModifyTexture();
 }
 
 }

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


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h	2012-06-13 00:10:03 UTC (rev 120142)
@@ -28,7 +28,8 @@
 
 #include "ImageBuffer.h" // For DeferralMode enum.
 #include "IntSize.h"
-#include "TextureLayerChromium.h"
+#include <public/WebExternalTextureLayer.h>
+#include <public/WebExternalTextureLayerClient.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
 
@@ -42,9 +43,8 @@
 namespace WebCore {
 
 class LayerChromium;
-class TextureLayerChromium;
 
-class Canvas2DLayerBridge : public TextureLayerChromiumClient {
+class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient {
     WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
 public:
     static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, unsigned textureId)
@@ -54,8 +54,8 @@
 
     virtual ~Canvas2DLayerBridge();
 
-    // TextureLayerChromiumClient implementation.
-    virtual unsigned prepareTexture(CCTextureUpdater&) OVERRIDE;
+    // WebKit::WebExternalTextureLayerClient implementation.
+    virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE;
     virtual WebKit::WebGraphicsContext3D* context() OVERRIDE;
 
     SkCanvas* skCanvas(SkDevice*);
@@ -71,7 +71,7 @@
     unsigned m_backBufferTexture;
     IntSize m_size;
     SkCanvas* m_canvas;
-    RefPtr<TextureLayerChromium> m_layer;
+    WebKit::WebExternalTextureLayer m_layer;
     RefPtr<GraphicsContext3D> m_context;
 };
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (120141 => 120142)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-13 00:10:03 UTC (rev 120142)
@@ -1,3 +1,19 @@
+2012-06-12  James Robinson  <[email protected]>
+
+        [chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
+        https://bugs.webkit.org/show_bug.cgi?id=88597
+
+        Reviewed by Adrienne Walker.
+
+        Implementations for new WebExternalTextureLayer APIs, updates test.
+
+        * src/WebExternalTextureLayer.cpp:
+        (WebKit::WebExternalTextureLayer::willModifyTexture):
+        (WebKit):
+        (WebKit::WebExternalTextureLayer::setRateLimitContext):
+        * tests/Canvas2DLayerBridgeTest.cpp:
+        (Canvas2DLayerBridgeTest::fullLifecycleTest):
+
 2012-06-12  Adrienne Walker  <[email protected]>
 
         [chromium] Paint scrollbars on WebKit thread and composite those textures

Modified: trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp (120141 => 120142)


--- trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp	2012-06-13 00:10:03 UTC (rev 120142)
@@ -112,6 +112,16 @@
     unwrap<TextureLayerChromium>()->setPremultipliedAlpha(premultipliedAlpha);
 }
 
+void WebExternalTextureLayer::willModifyTexture()
+{
+    unwrap<TextureLayerChromium>()->willModifyTexture();
+}
+
+void WebExternalTextureLayer::setRateLimitContext(bool rateLimit)
+{
+    unwrap<TextureLayerChromium>()->setRateLimitContext(rateLimit);
+}
+
 WebExternalTextureLayer::WebExternalTextureLayer(PassRefPtr<TextureLayerChromium> layer)
     : WebLayer(layer)
 {

Modified: trunk/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp (120141 => 120142)


--- trunk/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp	2012-06-13 00:04:10 UTC (rev 120141)
+++ trunk/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp	2012-06-13 00:10:03 UTC (rev 120142)
@@ -29,7 +29,7 @@
 #include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "ImageBuffer.h"
-#include "TextureCopier.h"
+#include "LayerChromium.h"
 #include "TextureManager.h"
 #include "WebCompositor.h"
 #include "WebKit.h"
@@ -59,9 +59,9 @@
     virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return 0; }
 };
 
-class MockTextureCopier : public TextureCopier {
+class MockWebTextureUpdater : public WebTextureUpdater {
 public:
-    MOCK_METHOD4(copyTexture, void(CCGraphicsContext*, unsigned, unsigned, const IntSize&));
+    MOCK_METHOD3(appendCopy, void(unsigned, unsigned, WebSize));
 };
 
 } // namespace
@@ -84,8 +84,7 @@
         MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get()));
         MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get()));
 
-        MockTextureCopier copierMock;
-        CCTextureUpdater updater;
+        MockWebTextureUpdater updater;
 
         const IntSize size(300, 150);
 
@@ -109,17 +108,13 @@
         ::testing::Mock::VerifyAndClearExpectations(&mainMock);
 
         EXPECT_CALL(mainMock, flush());
+        if (threadMode == Threaded && deferralMode == NonDeferred)
+            EXPECT_CALL(updater, appendCopy(backTextureId, frontTextureId, WebSize(300, 150)));
         EXPECT_EQ(frontTextureId, bridge->prepareTexture(updater));
         ::testing::Mock::VerifyAndClearExpectations(&mainMock);
+        ::testing::Mock::VerifyAndClearExpectations(&updater);
 
         if (threadMode == Threaded && deferralMode == NonDeferred) {
-            EXPECT_CALL(copierMock, copyTexture(ccImplContext.get(), backTextureId, frontTextureId, size));
-            EXPECT_CALL(implMock, flush());
-        }
-        updater.update(ccImplContext.get(), 0, &copierMock, 0, 100);
-        ::testing::Mock::VerifyAndClearExpectations(&implMock);
-
-        if (threadMode == Threaded && deferralMode == NonDeferred) {
             EXPECT_CALL(mainMock, deleteTexture(frontTextureId));
             EXPECT_CALL(mainMock, flush());
         }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to