Title: [110753] trunk/Source
Revision
110753
Author
[email protected]
Date
2012-03-14 14:27:48 -0700 (Wed, 14 Mar 2012)

Log Message

[chromium] Fix accelerated Canvas2D with threaded compositing.
https://bugs.webkit.org/show_bug.cgi?id=80998

Reviewed by James Robinson.

Source/WebCore: 

Covered by unit tests Canvas2DLayerChromiumTest and
TreeSynchronizerTest.

* platform/graphics/chromium/Canvas2DLayerChromium.cpp:
(WebCore::Canvas2DLayerChromium::paintContentsIfDirty):
(WebCore):
Delay creation of the front texture for double-buffering until the
first call to paintContentsIfDirty().
* platform/graphics/chromium/Canvas2DLayerChromium.h:
(Canvas2DLayerChromium):
Remove setTextureManager() and setLayerTreeHost(), since their job
has been subsumed by paintContentsIfDirty().
* platform/graphics/chromium/TreeSynchronizer.cpp:
(WebCore::TreeSynchronizer::updateScrollbarLayerPointersRecursive):
Perform an early-out if the passed-in layer is NULL.

Source/WebKit/chromium: 

* tests/Canvas2DLayerChromiumTest.cpp:
Instantiate a CCLayerTreeHost, so that Canvas2DLayerChromium can
retrieve its texture manager.  Also move the test into the unnamed
namespace -- since it's already using WebCore, there's little reason for
it to also be in the namespace.
* tests/TreeSynchronizerTest.cpp:
(WebKitTests):
(WebKitTests::TEST):
Add a new test for trying to synchronize NULL tree.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110752 => 110753)


--- trunk/Source/WebCore/ChangeLog	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebCore/ChangeLog	2012-03-14 21:27:48 UTC (rev 110753)
@@ -1,3 +1,26 @@
+2012-03-14  Stephen White  <[email protected]>
+
+        [chromium] Fix accelerated Canvas2D with threaded compositing.
+        https://bugs.webkit.org/show_bug.cgi?id=80998
+
+        Reviewed by James Robinson.
+
+        Covered by unit tests Canvas2DLayerChromiumTest and
+        TreeSynchronizerTest.
+
+        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
+        (WebCore::Canvas2DLayerChromium::paintContentsIfDirty):
+        (WebCore):
+        Delay creation of the front texture for double-buffering until the
+        first call to paintContentsIfDirty().
+        * platform/graphics/chromium/Canvas2DLayerChromium.h:
+        (Canvas2DLayerChromium):
+        Remove setTextureManager() and setLayerTreeHost(), since their job
+        has been subsumed by paintContentsIfDirty().
+        * platform/graphics/chromium/TreeSynchronizer.cpp:
+        (WebCore::TreeSynchronizer::updateScrollbarLayerPointersRecursive):
+        Perform an early-out if the passed-in layer is NULL.
+
 2012-03-14  Mark Pilgrim  <[email protected]>
 
         Move EntriesCallback to Modules/filesystem/

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp (110752 => 110753)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2012-03-14 21:27:48 UTC (rev 110753)
@@ -103,8 +103,14 @@
     if (!drawsContent())
         return;
 
-    if (m_useDoubleBuffering)
+    if (m_useDoubleBuffering && layerTreeHost()) {
+        TextureManager* textureManager = layerTreeHost()->contentsTextureManager();
+        if (m_frontTexture)
+            m_frontTexture->setTextureManager(textureManager);
+        else
+            m_frontTexture = ManagedTexture::create(textureManager);
         m_frontTexture->reserve(m_size, GraphicsContext3D::RGBA);
+    }
 
     if (!needsDisplay())
         return;
@@ -127,22 +133,6 @@
     m_context->flush();
 }
 
-void Canvas2DLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
-{
-    CanvasLayerChromium::setLayerTreeHost(host);
-
-    if (m_useDoubleBuffering && host)
-        setTextureManager(host->contentsTextureManager());
-}
-
-void Canvas2DLayerChromium::setTextureManager(TextureManager* textureManager)
-{
-    if (m_frontTexture)
-        m_frontTexture->setTextureManager(textureManager);
-    else
-        m_frontTexture = ManagedTexture::create(textureManager);
-}
-
 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
 {
     if (!m_backTextureId || !m_frontTexture || !m_frontTexture->isValid(m_size, GraphicsContext3D::RGBA))

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h (110752 => 110753)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h	2012-03-14 21:27:48 UTC (rev 110753)
@@ -57,7 +57,6 @@
     virtual bool drawsContent() const;
     virtual void paintContentsIfDirty(const Region& occludedScreenSpace);
 
-    virtual void setLayerTreeHost(CCLayerTreeHost*);
     virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
     virtual void pushPropertiesTo(CCLayerImpl*);
     virtual void unreserveContentsTexture();
@@ -68,7 +67,6 @@
     Canvas2DLayerChromium(PassRefPtr<GraphicsContext3D>, const IntSize&);
 
     friend class Canvas2DLayerChromiumTest;
-    void setTextureManager(TextureManager*);
 
     RefPtr<GraphicsContext3D> m_context;
     bool m_contextLost;

Modified: trunk/Source/WebCore/platform/graphics/chromium/TreeSynchronizer.cpp (110752 => 110753)


--- trunk/Source/WebCore/platform/graphics/chromium/TreeSynchronizer.cpp	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebCore/platform/graphics/chromium/TreeSynchronizer.cpp	2012-03-14 21:27:48 UTC (rev 110753)
@@ -99,6 +99,9 @@
 
 void TreeSynchronizer::updateScrollbarLayerPointersRecursive(const RawPtrCCLayerImplMap& newLayers, LayerChromium* layer)
 {
+    if (!layer)
+        return;
+
     const Vector<RefPtr<LayerChromium> >& children = layer->children();
     for (size_t i = 0; i < children.size(); ++i)
         updateScrollbarLayerPointersRecursive(newLayers, children[i].get());

Modified: trunk/Source/WebKit/chromium/ChangeLog (110752 => 110753)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-14 21:27:48 UTC (rev 110753)
@@ -1,3 +1,20 @@
+2012-03-14  Stephen White  <[email protected]>
+
+        [chromium] Fix accelerated Canvas2D with threaded compositing.
+        https://bugs.webkit.org/show_bug.cgi?id=80998
+
+        Reviewed by James Robinson.
+
+        * tests/Canvas2DLayerChromiumTest.cpp:
+        Instantiate a CCLayerTreeHost, so that Canvas2DLayerChromium can
+        retrieve its texture manager.  Also move the test into the unnamed
+        namespace -- since it's already using WebCore, there's little reason for
+        it to also be in the namespace.
+        * tests/TreeSynchronizerTest.cpp:
+        (WebKitTests):
+        (WebKitTests::TEST):
+        Add a new test for trying to synchronize NULL tree.
+
 2012-03-14  James Robinson  <[email protected]>
 
         [chromium] Provide explicit polling API to check if the platform is capable of accelerated 2d canvas

Modified: trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp (110752 => 110753)


--- trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp	2012-03-14 21:27:48 UTC (rev 110753)
@@ -27,13 +27,18 @@
 #include "Canvas2DLayerChromium.h"
 
 #include "CCSchedulerTestCommon.h"
+#include "FakeCCLayerTreeHostClient.h"
 #include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "Region.h"
 #include "TextureManager.h"
+#include "WebCompositor.h"
+#include "WebKit.h"
 #include "cc/CCCanvasLayerImpl.h"
 #include "cc/CCSingleThreadProxy.h"
 #include "cc/CCTextureUpdater.h"
+#include "platform/WebKitPlatformSupport.h"
+#include "platform/WebThread.h"
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
@@ -48,6 +53,24 @@
 
 namespace {
 
+class FakeCCLayerTreeHost : public CCLayerTreeHost {
+public:
+    static PassRefPtr<FakeCCLayerTreeHost> create()
+    {
+        RefPtr<FakeCCLayerTreeHost> host = adoptRef(new FakeCCLayerTreeHost);
+        host->initialize();
+        return host.release();
+    }
+
+private:
+    FakeCCLayerTreeHost()
+        : CCLayerTreeHost(&m_client, CCSettings())
+    {
+    }
+
+    FakeCCLayerTreeHostClient m_client;
+};
+
 class MockCanvasContext : public FakeWebGraphicsContext3D {
 public:
     MOCK_METHOD0(createFramebuffer, WebGLId());
@@ -69,10 +92,6 @@
     MOCK_METHOD3(deleteTexture, void(unsigned, const IntSize&, GC3Denum));
 };
 
-} // namespace
-
-namespace WebCore {
-
 class Canvas2DLayerChromiumTest : public Test {
 protected:
     void fullLifecycleTest(bool threaded)
@@ -89,12 +108,16 @@
         CCTextureUpdater updater(&allocatorMock);
 
         const IntSize size(300, 150);
-        const size_t maxTextureSize = size.width() * size.height() * 4;
-        OwnPtr<TextureManager> textureManager = TextureManager::create(maxTextureSize, maxTextureSize, maxTextureSize);
 
+        OwnPtr<WebThread> thread;
         if (threaded)
-            CCProxy::setImplThread(new FakeCCThread);
+           thread = adoptPtr(webKitPlatformSupport()->createThread("Canvas2DLayerChromiumTest"));
+        WebCompositor::initialize(thread.get());
 
+        RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create();
+        // Force an update, so that we get a valid TextureManager.
+        layerTreeHost->updateLayers();
+
         const WebGLId backTextureId = 1;
         const WebGLId frontTextureId = 2;
         const WebGLId fboId = 3;
@@ -127,7 +150,7 @@
 
         RefPtr<Canvas2DLayerChromium> canvas = Canvas2DLayerChromium::create(mainContext.get(), size);
         canvas->setIsDrawable(true);
-        canvas->setTextureManager(textureManager.get());
+        canvas->setLayerTreeHost(layerTreeHost.get());
         canvas->setBounds(IntSize(600, 300));
         canvas->setTextureId(backTextureId);
 
@@ -151,8 +174,10 @@
                 EXPECT_EQ(backTextureId, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId());
         }
         canvas.clear();
-        textureManager->reduceMemoryToLimit(0);
-        textureManager->deleteEvictedTextures(&allocatorMock);
+        layerTreeHost->contentsTextureManager()->reduceMemoryToLimit(0);
+        layerTreeHost->contentsTextureManager()->deleteEvictedTextures(&allocatorMock);
+        layerTreeHost.clear();
+        WebCompositor::shutdown();
     }
 };
 
@@ -166,4 +191,4 @@
     fullLifecycleTest(true);
 }
 
-} // namespace webcore
+} // namespace

Modified: trunk/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp (110752 => 110753)


--- trunk/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp	2012-03-14 21:24:44 UTC (rev 110752)
+++ trunk/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp	2012-03-14 21:27:48 UTC (rev 110753)
@@ -142,6 +142,17 @@
         expectTreesAreIdentical(layerChildren[i].get(), ccLayerChildren[i].get());
 }
 
+// Attempts to synchronizes a null tree. This should not crash, and should
+// return a null tree.
+TEST(TreeSynchronizerTest, syncNullTree)
+{
+    DebugScopedSetImplThread impl;
+
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(0, nullptr);
+
+    EXPECT_TRUE(!ccLayerTreeRoot.get());
+}
+
 // Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers.
 TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to