Title: [116472] trunk/Source
Revision
116472
Author
[email protected]
Date
2012-05-08 17:54:45 -0700 (Tue, 08 May 2012)

Log Message

[chromium] Reflections with masks should not occlude
https://bugs.webkit.org/show_bug.cgi?id=85927

Reviewed by James Robinson.

Source/WebCore:

When a surface does not have a mask, we make both it and its reflection
occlude the things below them. However, if the reflection has a mask
applied to it, then we should not consider it as occluding.

Adds replicaHasMask() to the render surface classes so we can test if
the mask is present.

Unit Tests: CCOcclusionTrackerTestReplicaWithMask

* platform/graphics/chromium/RenderSurfaceChromium.cpp:
(WebCore::RenderSurfaceChromium::hasMask):
This is unusued right now, but will allow us to remove a FIXME from
CCOcclusionTracker::finishedTargetRenderSurface().
(WebCore):
(WebCore::RenderSurfaceChromium::replicaHasMask):
* platform/graphics/chromium/RenderSurfaceChromium.h:
(RenderSurfaceChromium):
* platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
(WebCore::::leaveToTargetRenderSurface):
* platform/graphics/chromium/cc/CCRenderSurface.cpp:
(WebCore::CCRenderSurface::hasMask):
This is unusued right now, but will allow us to remove a FIXME from
CCOcclusionTracker::finishedTargetRenderSurface().
(WebCore):
(WebCore::CCRenderSurface::replicaHasMask):
* platform/graphics/chromium/cc/CCRenderSurface.h:
(CCRenderSurface):

Source/WebKit/chromium:

* tests/CCOcclusionTrackerTest.cpp:
(WebKitTests::CCOcclusionTrackerTest::TearDown):
(WebKitTests::CCOcclusionTrackerTest::createMaskLayer):
(CCOcclusionTrackerTest):
(WebKitTests::CCOcclusionTrackerTest::setMask):
(CCOcclusionTrackerTestReplicaWithMask):
(WebKitTests::CCOcclusionTrackerTestReplicaWithMask::runMyTest):
(WebKitTests):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116471 => 116472)


--- trunk/Source/WebCore/ChangeLog	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebCore/ChangeLog	2012-05-09 00:54:45 UTC (rev 116472)
@@ -1,3 +1,38 @@
+2012-05-08  Dana Jansens  <[email protected]>
+
+        [chromium] Reflections with masks should not occlude
+        https://bugs.webkit.org/show_bug.cgi?id=85927
+
+        Reviewed by James Robinson.
+
+        When a surface does not have a mask, we make both it and its reflection
+        occlude the things below them. However, if the reflection has a mask
+        applied to it, then we should not consider it as occluding.
+
+        Adds replicaHasMask() to the render surface classes so we can test if
+        the mask is present.
+
+        Unit Tests: CCOcclusionTrackerTestReplicaWithMask
+
+        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
+        (WebCore::RenderSurfaceChromium::hasMask):
+        This is unusued right now, but will allow us to remove a FIXME from
+        CCOcclusionTracker::finishedTargetRenderSurface().
+        (WebCore):
+        (WebCore::RenderSurfaceChromium::replicaHasMask):
+        * platform/graphics/chromium/RenderSurfaceChromium.h:
+        (RenderSurfaceChromium):
+        * platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
+        (WebCore::::leaveToTargetRenderSurface):
+        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
+        (WebCore::CCRenderSurface::hasMask):
+        This is unusued right now, but will allow us to remove a FIXME from
+        CCOcclusionTracker::finishedTargetRenderSurface().
+        (WebCore):
+        (WebCore::CCRenderSurface::replicaHasMask):
+        * platform/graphics/chromium/cc/CCRenderSurface.h:
+        (CCRenderSurface):
+
 2012-05-08  Eric Seidel  <[email protected]>
 
         Add stylesheet inheritance support to IFRAME_SEAMLESS

Modified: trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp (116471 => 116472)


--- trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp	2012-05-09 00:54:45 UTC (rev 116472)
@@ -69,5 +69,15 @@
     return m_owningLayer->replicaLayer();
 }
 
+bool RenderSurfaceChromium::hasMask() const
+{
+    return m_maskLayer;
 }
+
+bool RenderSurfaceChromium::replicaHasMask() const
+{
+    return hasReplica() && (m_maskLayer || m_owningLayer->replicaLayer()->maskLayer());
+}
+
+}
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h (116471 => 116472)


--- trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h	2012-05-09 00:54:45 UTC (rev 116472)
@@ -109,6 +109,9 @@
 
     bool hasReplica() const;
 
+    bool hasMask() const;
+    bool replicaHasMask() const;
+
 private:
     LayerChromium* m_owningLayer;
     LayerChromium* m_maskLayer;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp (116471 => 116472)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-05-09 00:54:45 UTC (rev 116472)
@@ -230,7 +230,7 @@
 
     const RenderSurfaceType* oldTarget = m_stack[lastIndex].surface;
     Region oldTargetOcclusionInNewTarget = transformSurfaceOpaqueRegion<RenderSurfaceType>(oldTarget, m_stack[lastIndex].occlusionInTarget, oldTarget->originTransform());
-    if (oldTarget->hasReplica())
+    if (oldTarget->hasReplica() && !oldTarget->replicaHasMask())
         oldTargetOcclusionInNewTarget.unite(transformSurfaceOpaqueRegion<RenderSurfaceType>(oldTarget, m_stack[lastIndex].occlusionInTarget, oldTarget->replicaOriginTransform()));
 
     IntRect unoccludedSurfaceRect;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp (116471 => 116472)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp	2012-05-09 00:54:45 UTC (rev 116472)
@@ -396,6 +396,16 @@
     return m_owningLayer->replicaLayer();
 }
 
+bool CCRenderSurface::hasMask() const
+{
+    return m_maskLayer;
+}
+
+bool CCRenderSurface::replicaHasMask() const
+{
+    return hasReplica() && (m_maskLayer || m_owningLayer->replicaLayer()->maskLayer());
+}
+
 void CCRenderSurface::setClipRect(const IntRect& clipRect)
 {
     if (m_clipRect == clipRect)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h (116471 => 116472)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h	2012-05-09 00:54:45 UTC (rev 116472)
@@ -141,6 +141,9 @@
 
     bool hasReplica() const;
 
+    bool hasMask() const;
+    bool replicaHasMask() const;
+
     void resetPropertyChangedFlag() { m_surfacePropertyChanged = false; }
     bool surfacePropertyChanged() const;
     bool surfacePropertyChangedOnlyFromDescendant() const;

Modified: trunk/Source/WebKit/chromium/ChangeLog (116471 => 116472)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-09 00:54:45 UTC (rev 116472)
@@ -1,5 +1,21 @@
 2012-05-08  Dana Jansens  <[email protected]>
 
+        [chromium] Reflections with masks should not occlude
+        https://bugs.webkit.org/show_bug.cgi?id=85927
+
+        Reviewed by James Robinson.
+
+        * tests/CCOcclusionTrackerTest.cpp:
+        (WebKitTests::CCOcclusionTrackerTest::TearDown):
+        (WebKitTests::CCOcclusionTrackerTest::createMaskLayer):
+        (CCOcclusionTrackerTest):
+        (WebKitTests::CCOcclusionTrackerTest::setMask):
+        (CCOcclusionTrackerTestReplicaWithMask):
+        (WebKitTests::CCOcclusionTrackerTestReplicaWithMask::runMyTest):
+        (WebKitTests):
+
+2012-05-08  Dana Jansens  <[email protected]>
+
         Region reads past end of spans
         https://bugs.webkit.org/show_bug.cgi?id=85909
 

Modified: trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp (116471 => 116472)


--- trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp	2012-05-09 00:52:08 UTC (rev 116471)
+++ trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp	2012-05-09 00:54:45 UTC (rev 116472)
@@ -172,6 +172,7 @@
         m_renderSurfaceLayerListChromium.clear();
         m_renderSurfaceLayerListImpl.clear();
         m_replicaLayers.clear();
+        m_maskLayers.clear();
         CCLayerTreeHost::setNeedsFilterContext(false);
     }
 
@@ -233,6 +234,15 @@
         return layerPtr;
     }
 
+    typename Types::LayerType* createMaskLayer(typename Types::LayerType* owningLayer, const IntSize& bounds)
+    {
+        typename Types::ContentLayerPtrType layer(Types::createContentLayer());
+        typename Types::ContentLayerType* layerPtr = layer.get();
+        setProperties(layerPtr, identityMatrix, FloatPoint(), bounds);
+        setMask(owningLayer, layer.release());
+        return layerPtr;
+    }
+
     typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque)
     {
         typename Types::ContentLayerType* layer = createDrawingLayer(parent, transform, position, bounds, opaque);
@@ -360,6 +370,17 @@
         owningLayer->setReplicaLayer(layer);
     }
 
+    void setMask(LayerChromium* owningLayer, PassRefPtr<LayerChromium> layer)
+    {
+        owningLayer->setMaskLayer(layer.get());
+        m_maskLayers.append(layer);
+    }
+
+    void setMask(CCLayerImpl* owningLayer, PassOwnPtr<CCLayerImpl> layer)
+    {
+        owningLayer->setMaskLayer(layer);
+    }
+
     // These hold ownership of the layers for the duration of the test.
     typename Types::LayerPtrType m_root;
     Vector<RefPtr<LayerChromium> > m_renderSurfaceLayerListChromium;
@@ -368,6 +389,7 @@
     typename Types::LayerIterator m_layerIterator;
     typename Types::LayerType* m_lastLayerVisited;
     Vector<RefPtr<LayerChromium> > m_replicaLayers;
+    Vector<RefPtr<LayerChromium> > m_maskLayers;
 };
 
 #define RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
@@ -1330,6 +1352,38 @@
 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestReplicaWithClipping);
 
 template<class Types, bool opaqueLayers>
+class CCOcclusionTrackerTestReplicaWithMask : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+protected:
+    void runMyTest()
+    {
+        typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200));
+        typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(50, 50), true);
+        typename Types::LayerType* replica = this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(50, 50), IntSize());
+        this->createMaskLayer(replica, IntSize(10, 10));
+        this->calcDrawEtc(parent);
+
+        TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+        occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+
+        this->visitLayer(surface, occlusion);
+
+        EXPECT_EQ_RECT(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
+        EXPECT_EQ_RECT(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
+
+        this->visitContributingSurface(surface, occlusion);
+        this->enterLayer(parent, occlusion);
+
+        // The replica should not be occluding the parent, since it has a mask applied to it.
+        EXPECT_EQ_RECT(IntRect(0, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
+    }
+};
+
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestReplicaWithMask);
+
+template<class Types, bool opaqueLayers>
 class CCOcclusionTrackerTestLayerScissorRectOutsideChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
 protected:
     void runMyTest()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to