Title: [124511] trunk/Source
Revision
124511
Author
e...@google.com
Date
2012-08-02 15:29:38 -0700 (Thu, 02 Aug 2012)

Log Message

[chromium] Make CCScrollbarLayerImpl handle lost contexts properly
https://bugs.webkit.org/show_bug.cgi?id=93021

Reviewed by James Robinson.

Source/WebCore:

The resource ids that CCScrollbarLayerImpl holds onto need to be
discarded during a lost context as the resource provider they came
from is also destroyed.

Make a scrollbarGeometry function that wraps all uses of the
m_geometry member to make it possible to test CCScrollbarLayerImpl
without depending on WebCore.

Test: CCLayerTreeHostImplTest.dontUseOldResourcesAfterLostContext

* platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
(WebCore::CCScrollbarLayerImpl::scrollbarGeometry):
(WebCore):
(WebCore::CCScrollbarLayerImpl::appendQuads):
(WebCore::CCScrollbarLayerImpl::didLoseContext):
* platform/graphics/chromium/cc/CCScrollbarLayerImpl.h:
(CCScrollbarLayerImpl):

Source/WebKit/chromium:

Add CCScrollbarLayerImpl to the dontUseOldResourceAfterLostContext
test. Additionally, modify this test so that stale resource ids
properly point at invalid texture ids so that the test actually tests
what it is supposed to be testing.

* tests/CCLayerTreeHostImplTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124510 => 124511)


--- trunk/Source/WebCore/ChangeLog	2012-08-02 22:24:08 UTC (rev 124510)
+++ trunk/Source/WebCore/ChangeLog	2012-08-02 22:29:38 UTC (rev 124511)
@@ -1,3 +1,28 @@
+2012-08-02  Adrienne Walker  <e...@google.com>
+
+        [chromium] Make CCScrollbarLayerImpl handle lost contexts properly
+        https://bugs.webkit.org/show_bug.cgi?id=93021
+
+        Reviewed by James Robinson.
+
+        The resource ids that CCScrollbarLayerImpl holds onto need to be
+        discarded during a lost context as the resource provider they came
+        from is also destroyed.
+
+        Make a scrollbarGeometry function that wraps all uses of the
+        m_geometry member to make it possible to test CCScrollbarLayerImpl
+        without depending on WebCore.
+
+        Test: CCLayerTreeHostImplTest.dontUseOldResourcesAfterLostContext
+
+        * platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
+        (WebCore::CCScrollbarLayerImpl::scrollbarGeometry):
+        (WebCore):
+        (WebCore::CCScrollbarLayerImpl::appendQuads):
+        (WebCore::CCScrollbarLayerImpl::didLoseContext):
+        * platform/graphics/chromium/cc/CCScrollbarLayerImpl.h:
+        (CCScrollbarLayerImpl):
+
 2012-08-02  Oliver Hunt  <oli...@apple.com>
 
         A few objects aren't being safely protected from GC in all cases

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp (124510 => 124511)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp	2012-08-02 22:24:08 UTC (rev 124510)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp	2012-08-02 22:29:38 UTC (rev 124511)
@@ -86,6 +86,13 @@
                      static_cast<float>(r.width) / bounds.width, static_cast<float>(r.height) / bounds.height);
 }
 
+void CCScrollbarLayerImpl::scrollbarGeometry(WebRect& thumbRect, WebRect& backTrackRect, WebRect& foreTrackRect)
+{
+    m_geometry.splitTrack(&m_scrollbar, m_geometry.trackRect(&m_scrollbar), backTrackRect, thumbRect, foreTrackRect);
+    if (!m_geometry.hasThumb(&m_scrollbar))
+        thumbRect = WebRect();
+}
+
 void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&)
 {
     bool premultipledAlpha = false;
@@ -94,9 +101,9 @@
     IntRect boundsRect(IntPoint(), contentBounds());
 
     WebRect thumbRect, backTrackRect, foreTrackRect;
-    m_geometry.splitTrack(&m_scrollbar, m_geometry.trackRect(&m_scrollbar), backTrackRect, thumbRect, foreTrackRect);
+    scrollbarGeometry(thumbRect, backTrackRect, foreTrackRect);
 
-    if (m_thumbResourceId && m_geometry.hasThumb(&m_scrollbar) && !thumbRect.isEmpty()) {
+    if (m_thumbResourceId && !thumbRect.isEmpty()) {
         OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadState, IntRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvRect, flipped);
         quad->setNeedsBlending();
         quadList.append(quad.release());
@@ -115,6 +122,13 @@
         quadList.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(boundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped));
 }
 
+void CCScrollbarLayerImpl::didLoseContext()
+{
+    m_backTrackResourceId = 0;
+    m_foreTrackResourceId = 0;
+    m_thumbResourceId = 0;
+}
+
 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const
 {
     return m_owner->m_isOverlayScrollbar;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h (124510 => 124511)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h	2012-08-02 22:24:08 UTC (rev 124510)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h	2012-08-02 22:29:38 UTC (rev 124511)
@@ -53,9 +53,13 @@
 
     virtual void appendQuads(CCQuadSink&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
 
+    void didLoseContext() OVERRIDE;
+
 protected:
     explicit CCScrollbarLayerImpl(int id);
 
+    virtual void scrollbarGeometry(WebKit::WebRect& thumbRect, WebKit::WebRect& backTrackRect, WebKit::WebRect& foreTrackRect);
+
 private:
     CCLayerImpl* m_scrollLayer;
 
@@ -86,6 +90,7 @@
         CCScrollbarLayerImpl* m_owner;
 
     };
+
     CCScrollbar m_scrollbar;
 
     CCResourceProvider::ResourceId m_backTrackResourceId;

Modified: trunk/Source/WebKit/chromium/ChangeLog (124510 => 124511)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-08-02 22:24:08 UTC (rev 124510)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-08-02 22:29:38 UTC (rev 124511)
@@ -1,3 +1,17 @@
+2012-08-02  Adrienne Walker  <e...@google.com>
+
+        [chromium] Make CCScrollbarLayerImpl handle lost contexts properly
+        https://bugs.webkit.org/show_bug.cgi?id=93021
+
+        Reviewed by James Robinson.
+
+        Add CCScrollbarLayerImpl to the dontUseOldResourceAfterLostContext
+        test. Additionally, modify this test so that stale resource ids
+        properly point at invalid texture ids so that the test actually tests
+        what it is supposed to be testing.
+
+        * tests/CCLayerTreeHostImplTest.cpp:
+
 2012-08-02  Adam Barth  <aba...@webkit.org>
 
         The generic bindings shouldn't use templates

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (124510 => 124511)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-08-02 22:24:08 UTC (rev 124510)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-08-02 22:29:38 UTC (rev 124511)
@@ -2123,16 +2123,6 @@
     m_hostImpl->finishAllRendering();
 }
 
-class ScrollbarLayerFakePaint : public CCScrollbarLayerImpl {
-public:
-    static PassOwnPtr<ScrollbarLayerFakePaint> create(int id) { return adoptPtr(new ScrollbarLayerFakePaint(id)); }
-
-    virtual void paint(GraphicsContext*) { }
-
-private:
-    ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { }
-};
-
 // Fake WebGraphicsContext3D that will cause a failure if trying to use a
 // resource that wasn't created by it (resources created by
 // FakeWebGraphicsContext3D have an id of 1).
@@ -2292,6 +2282,40 @@
     }
 };
 
+class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl {
+public:
+    static PassOwnPtr<FakeScrollbarLayerImpl> create(int id)
+    {
+        return adoptPtr(new FakeScrollbarLayerImpl(id));
+    }
+
+    void createResources(CCResourceProvider* provider)
+    {
+        ASSERT(provider);
+        int pool = 0;
+        IntSize size(10, 10);
+        GC3Denum format = GraphicsContext3D::RGBA;
+        CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureUsageAny;
+
+        setBackTrackResourceId(provider->createResource(pool, size, format, hint));
+        setForeTrackResourceId(provider->createResource(pool, size, format, hint));
+        setThumbResourceId(provider->createResource(pool, size, format, hint));
+    }
+
+protected:
+    explicit FakeScrollbarLayerImpl(int id)
+        : CCScrollbarLayerImpl(id)
+    {
+    }
+
+    virtual void scrollbarGeometry(WebRect& thumbRect, WebRect& backTrackRect, WebRect& foreTrackRect) OVERRIDE
+    {
+        thumbRect = WebRect(0, 5, 5, 2);
+        backTrackRect = WebRect(0, 5, 0, 5);
+        foreTrackRect = WebRect(0, 0, 0, 5);
+    }
+};
+
 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
 {
     OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
@@ -2344,6 +2368,15 @@
     hudLayer->setLayerTreeHostImpl(m_hostImpl.get());
     rootLayer->addChild(hudLayer.release());
 
+    OwnPtr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::create(7));
+    scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get());
+    scrollbarLayer->setBounds(IntSize(10, 10));
+    scrollbarLayer->setContentBounds(IntSize(10, 10));
+    scrollbarLayer->setDrawsContent(true);
+    scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get());
+    scrollbarLayer->createResources(m_hostImpl->resourceProvider());
+    rootLayer->addChild(scrollbarLayer.release());
+
     // Use a context that supports IOSurfaces
     m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
 
@@ -2355,9 +2388,17 @@
     m_hostImpl->didDrawAllLayers(frame);
     m_hostImpl->swapBuffers();
 
+    unsigned numResources = m_hostImpl->resourceProvider()->numResources();
+
     // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
     // that will warn if any resource from the previous context gets used.
     m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
+
+    // Create dummy resources so that looking up an old resource will get an
+    // invalid texture id mapping.
+    for (unsigned i = 0; i < numResources; ++i)
+        m_hostImpl->resourceProvider()->createResourceFromExternalTexture(1);
+
     EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     m_hostImpl->drawLayers(frame);
     m_hostImpl->didDrawAllLayers(frame);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to