Title: [111502] trunk/Source
Revision
111502
Author
[email protected]
Date
2012-03-20 22:29:01 -0700 (Tue, 20 Mar 2012)

Log Message

[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

Patch by Dana Jansens <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111501 => 111502)


--- trunk/Source/WebCore/ChangeLog	2012-03-21 05:26:02 UTC (rev 111501)
+++ trunk/Source/WebCore/ChangeLog	2012-03-21 05:29:01 UTC (rev 111502)
@@ -1,3 +1,16 @@
+2012-03-20  Dana Jansens  <[email protected]>
+
+        [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  <[email protected]>
 
         [Crash] RenderMenuList::addChild() in Shadow DOM.

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-03-21 05:26:02 UTC (rev 111501)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-03-21 05:29:01 UTC (rev 111502)
@@ -114,22 +114,15 @@
     // 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 @@
     // 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.

Modified: trunk/Source/WebKit/chromium/ChangeLog (111501 => 111502)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-21 05:26:02 UTC (rev 111501)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-21 05:29:01 UTC (rev 111502)
@@ -1,5 +1,17 @@
 2012-03-20  Dana Jansens  <[email protected]>
 
+        [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  <[email protected]>
+
         [chromium] Store origin/screen space transforms for surface and replica in the surface
         https://bugs.webkit.org/show_bug.cgi?id=81296
 

Modified: trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp (111501 => 111502)


--- trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp	2012-03-21 05:26:02 UTC (rev 111501)
+++ trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp	2012-03-21 05:29:01 UTC (rev 111502)
@@ -1878,4 +1878,55 @@
 
 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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to