[chromium] Use origin transform to transform occlusion from surface content space...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2012 05:29:01 +0000 (05:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2012 05:29:01 +0000 (05:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81730

Patch by Dana Jansens <danakj@chromium.org> on 2012-03-20
Reviewed by Adrienne Walker.

Source/WebCore:

Unit test: CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent

* platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
(WebCore::transformSurfaceOpaqueRegion):
(WebCore::::leaveToTargetRenderSurface):

Source/WebKit/chromium:

* tests/CCOcclusionTrackerTest.cpp:
(WebCore):
(CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent):
(WebCore::CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent::runMyTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111502 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp

index 5a0d5ee778c0be8a65067d1cd9cd92f3e395b650..fe2b698d6b66ec3d5c469645fe1e7d3b661f49c2 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-20  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Use origin transform to transform occlusion from surface content space to its target content space
+        https://bugs.webkit.org/show_bug.cgi?id=81730
+
+        Reviewed by Adrienne Walker.
+
+        Unit test: CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent
+
+        * platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
+        (WebCore::transformSurfaceOpaqueRegion):
+        (WebCore::::leaveToTargetRenderSurface):
+
 2012-03-19  Shinya Kawanaka  <shinyak@chromium.org>
 
         [Crash] RenderMenuList::addChild() in Shadow DOM.
index 971494b9089d5cf902458ea9ae9e3a5367b8e5d6..c4082fe96ae1a013ee46070d890d28ca9e67b977 100644 (file)
@@ -114,22 +114,15 @@ static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surfa
     // Verify that rects within the |surface| will remain rects in its target surface after applying |transform|. If this is true, then
     // apply |transform| to each rect within |region| in order to transform the entire Region.
 
-    IntRect bounds = region.bounds();
-    FloatRect centeredBounds(-bounds.width() / 2.0, -bounds.height() / 2.0, bounds.width(), bounds.height());
-    FloatQuad transformedBoundsQuad = transform.mapQuad(FloatQuad(centeredBounds));
+    FloatQuad transformedBoundsQuad = transform.mapQuad(FloatQuad(region.bounds()));
     if (!transformedBoundsQuad.isRectilinear())
         return Region();
 
     Region transformedRegion;
 
-    IntRect surfaceBounds = surface->contentRect();
     Vector<IntRect> rects = region.rects();
-    Vector<IntRect>::const_iterator end = rects.end();
-    for (Vector<IntRect>::const_iterator i = rects.begin(); i != end; ++i) {
-        FloatRect centeredOriginRect(-i->width() / 2.0 + i->x() - surfaceBounds.x(), -i->height() / 2.0 + i->y() - surfaceBounds.y(), i->width(), i->height());
-        FloatRect transformedRect = transform.mapRect(FloatRect(centeredOriginRect));
-        transformedRegion.unite(enclosedIntRect(transformedRect));
-    }
+    for (size_t i = 0; i < rects.size(); ++i)
+        transformedRegion.unite(enclosedIntRect(transform.mapRect(FloatRect(rects[i]))));
     return transformedRegion;
 }
 
@@ -143,7 +136,7 @@ void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToTargetRenderSu
     // The target occlusion can be merged out as well but needs to be transformed to the new target.
 
     const RenderSurfaceType* oldTarget = m_stack[lastIndex].surface;
-    Region oldTargetOcclusionInNewTarget = transformSurfaceOpaqueRegion<RenderSurfaceType>(oldTarget, m_stack[lastIndex].occlusionInTarget, oldTarget->drawTransform());
+    Region oldTargetOcclusionInNewTarget = transformSurfaceOpaqueRegion<RenderSurfaceType>(oldTarget, m_stack[lastIndex].occlusionInTarget, oldTarget->originTransform());
 
     if (surfaceWillBeAtTopAfterPop) {
         // Merge the top of the stack down.
index e7701847b4f48192b48d27e1755020b3652777e2..6cedca60ebdf6e82b13bb89e01545d30e91cd85f 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-20  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Use origin transform to transform occlusion from surface content space to its target content space
+        https://bugs.webkit.org/show_bug.cgi?id=81730
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCOcclusionTrackerTest.cpp:
+        (WebCore):
+        (CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent):
+        (WebCore::CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent::runMyTest):
+
 2012-03-20  Dana Jansens  <danakj@chromium.org>
 
         [chromium] Store origin/screen space transforms for surface and replica in the surface
index 1e9d8d283e1bb244af448c86f1587d324719a655..e78f25af979c4264892e6ee86a78bb6e52d61549 100644 (file)
@@ -1878,4 +1878,55 @@ protected:
 
 MAIN_THREAD_TEST(CCOcclusionTrackerTestAnimationTranslateOnMainThread);
 
+template<class Types, bool opaqueLayers>
+class CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+protected:
+    void runMyTest()
+    {
+        TransformationMatrix surfaceTransform;
+        surfaceTransform.translate(300, 300);
+        surfaceTransform.scale(2);
+        surfaceTransform.translate(-150, -150);
+
+        typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(500, 500));
+        typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, surfaceTransform, FloatPoint(0, 0), IntSize(300, 300), false);
+        typename Types::ContentLayerType* surface2 = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(50, 50), IntSize(300, 300), false);
+        surface->setOpaqueContentsRect(IntRect(0, 0, 200, 200));
+        surface2->setOpaqueContentsRect(IntRect(0, 0, 200, 200));
+        this->calcDrawEtc(parent);
+
+        TestCCOcclusionTrackerBase<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+
+        occlusion.enterTargetRenderSurface(surface2->renderSurface());
+        occlusion.markOccludedBehindLayer(surface2);
+        occlusion.finishedTargetRenderSurface(surface2, surface2->renderSurface());
+        occlusion.leaveToTargetRenderSurface(parent->renderSurface());
+
+        EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.occlusionInScreenSpace().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
+        EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.occlusionInTargetSurface().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
+
+        // Clear any stored occlusion.
+        occlusion.setOcclusionInScreenSpace(Region());
+        occlusion.setOcclusionInTargetSurface(Region());
+
+        occlusion.enterTargetRenderSurface(surface->renderSurface());
+        occlusion.markOccludedBehindLayer(surface);
+        occlusion.finishedTargetRenderSurface(surface, surface->renderSurface());
+        occlusion.leaveToTargetRenderSurface(parent->renderSurface());
+
+        EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), occlusion.occlusionInScreenSpace().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
+        EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), occlusion.occlusionInTargetSurface().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
+
+        EXPECT_EQ_RECT(occlusion.occlusionInScreenSpace().bounds(), occlusion.occlusionInTargetSurface().bounds());
+        EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
+        EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
+    }
+};
+
+MAIN_AND_IMPL_THREAD_TEST(CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent);
+
 } // namespace