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/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