Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: cc/occlusion_tracker_unittest.cc

Issue 10915313: cc: Apply the layer's initial CSS scale to the contentsScale to render text at the right resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/math_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/occlusion_tracker_unittest.cc
diff --git a/cc/occlusion_tracker_unittest.cc b/cc/occlusion_tracker_unittest.cc
index d3385a3aa35ac9e1b36e4411016a65cc1cb392bd..ecf6be37dbe7db5a92f40d6a30fb1c67e9bba2f0 100644
--- a/cc/occlusion_tracker_unittest.cc
+++ b/cc/occlusion_tracker_unittest.cc
@@ -9,14 +9,14 @@
#include "CCAnimationTestCommon.h"
#include "CCGeometryTestUtils.h"
#include "CCLayerAnimationController.h"
-#include "CCLayerImpl.h"
#include "CCLayerTreeHostCommon.h"
#include "CCMathUtil.h"
#include "CCOcclusionTrackerTestCommon.h"
#include "CCOverdrawMetrics.h"
#include "CCSingleThreadProxy.h"
-#include "LayerChromium.h"
+#include "CCTiledLayerImpl.h"
#include "Region.h"
+#include "TiledLayerChromium.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebFilterOperation.h>
@@ -29,10 +29,10 @@ using namespace WebKitTests;
namespace {
-class TestContentLayerChromium : public LayerChromium {
+class TestContentLayerChromium : public TiledLayerChromium {
public:
TestContentLayerChromium()
- : LayerChromium()
+ : TiledLayerChromium()
, m_overrideOpaqueContentsRect(false)
{
}
@@ -50,6 +50,9 @@ public:
m_opaqueContentsRect = opaqueContentsRect;
}
+ virtual LayerTextureUpdater* textureUpdater() const OVERRIDE { return 0; }
+ virtual void createTextureUpdaterIfNeeded() OVERRIDE { }
+
private:
virtual ~TestContentLayerChromium()
{
@@ -59,10 +62,10 @@ private:
IntRect m_opaqueContentsRect;
};
-class TestContentLayerImpl : public CCLayerImpl {
+class TestContentLayerImpl : public CCTiledLayerImpl {
public:
TestContentLayerImpl(int id)
- : CCLayerImpl(id)
+ : CCTiledLayerImpl(id)
, m_overrideOpaqueContentsRect(false)
{
setDrawsContent(true);
@@ -270,7 +273,7 @@ protected:
ASSERT(!root->renderSurface());
- CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, &layerSorter, dummyMaxTextureSize, m_renderSurfaceLayerListImpl);
+ CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, 1, &layerSorter, dummyMaxTextureSize, m_renderSurfaceLayerListImpl);
m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_renderSurfaceLayerListImpl);
}
@@ -282,7 +285,7 @@ protected:
ASSERT(!root->renderSurface());
- CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, dummyMaxTextureSize, m_renderSurfaceLayerListChromium);
+ CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, 1, dummyMaxTextureSize, m_renderSurfaceLayerListChromium);
m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_renderSurfaceLayerListChromium);
}
@@ -430,14 +433,18 @@ private:
RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
#define MAIN_THREAD_TEST(ClassName) \
- RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName)
+ RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
+ RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName)
#define IMPL_THREAD_TEST(ClassName) \
- RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName)
+ RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
+ RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
#define MAIN_AND_IMPL_THREAD_TEST(ClassName) \
RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
- RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName)
+ RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \
+ RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
+ RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestIdentityTransforms : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -2201,7 +2208,7 @@ protected:
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));
+ surface->setOpaqueContentsRect(IntRect(0, 0, 400, 400));
surface2->setOpaqueContentsRect(IntRect(0, 0, 200, 200));
this->calcDrawEtc(parent);
@@ -2229,7 +2236,8 @@ protected:
}
};
-MAIN_AND_IMPL_THREAD_TEST(CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent);
+// Scale transforms require main thread+commit to get contentBounds right.
+MAIN_THREAD_TEST(CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -2571,15 +2579,15 @@ protected:
// Everything outside the surface/replica is occluded but the surface/replica itself is not.
this->enterLayer(filteredSurface, occlusion);
- EXPECT_RECT_EQ(IntRect(1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 100, 100)));
- EXPECT_RECT_EQ(IntRect(0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 100, 100)));
- EXPECT_RECT_EQ(IntRect(0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 100, 100)));
- EXPECT_RECT_EQ(IntRect(0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 100, 100)));
-
- EXPECT_RECT_EQ(IntRect(300 + 1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 1, 0, 100, 100)));
- EXPECT_RECT_EQ(IntRect(300 + 0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, 1, 100, 100)));
- EXPECT_RECT_EQ(IntRect(300 + 0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 - 1, 0, 100, 100)));
- EXPECT_RECT_EQ(IntRect(300 + 0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, -1, 100, 100)));
+ EXPECT_RECT_EQ(IntRect(1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 50, 50)));
+ EXPECT_RECT_EQ(IntRect(0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 50, 50)));
+ EXPECT_RECT_EQ(IntRect(0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 50, 50)));
+ EXPECT_RECT_EQ(IntRect(0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 50, 50)));
+
+ EXPECT_RECT_EQ(IntRect(150 + 1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 1, 0, 50, 50)));
+ EXPECT_RECT_EQ(IntRect(150 + 0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, 1, 50, 50)));
+ EXPECT_RECT_EQ(IntRect(150 + 0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 - 1, 0, 50, 50)));
+ EXPECT_RECT_EQ(IntRect(150 + 0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, -1, 50, 50)));
this->leaveLayer(filteredSurface, occlusion);
// The filtered layer/replica does not occlude.
@@ -2589,7 +2597,7 @@ protected:
EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
// The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels
- // it needs should be removed some the occluded area so that when we get to the parent they are drawn.
+ // it needs should be removed from the occluded area so that when we get to the parent they are drawn.
this->visitContributingSurface(filteredSurface, occlusion);
this->enterLayer(parent, occlusion);
@@ -2645,7 +2653,8 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter);
+// Scale transforms require main thread+commit to get contentBounds right.
+MAIN_THREAD_TEST(CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -2656,12 +2665,12 @@ protected:
scaleByHalf.scale(0.5);
// Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them.
- typename Types::ContentLayerType* root = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(75, 75));
- typename Types::LayerType* parent = this->createSurface(root, scaleByHalf, FloatPoint(0, 0), IntSize(150, 150));
+ typename Types::ContentLayerType* root = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(150, 150));
+ typename Types::LayerType* parent = this->createDrawingSurface(root, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false);
parent->setMasksToBounds(true);
- typename Types::LayerType* filteredSurface1 = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false);
- typename Types::LayerType* filteredSurface2 = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false);
- typename Types::LayerType* occludingLayerAbove = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(100, 100), IntSize(50, 50), true);
+ typename Types::LayerType* filteredSurface1 = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(0, 0), IntSize(600, 600), false);
+ typename Types::LayerType* filteredSurface2 = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(0, 0), IntSize(600, 600), false);
+ typename Types::LayerType* occludingLayerAbove = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(200, 200), IntSize(100, 100), true);
// Filters make the layers own surfaces.
WebFilterOperations filters;
@@ -2679,9 +2688,9 @@ protected:
occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(occludingLayerAbove, occlusion);
- EXPECT_RECT_EQ(IntRect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_RECT_EQ(IntRect(200 / 2, 200 / 2, 100 / 2, 100 / 2), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_RECT_EQ(IntRect(100, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_RECT_EQ(IntRect(200 / 2, 200 / 2, 100 / 2, 100 / 2), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(filteredSurface2, occlusion);
@@ -2692,22 +2701,18 @@ protected:
ASSERT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
ASSERT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
- // Test expectations in the target.
- IntRect expectedOcclusion = IntRect(100 + outsetRight * 2, 100 + outsetBottom * 2, 50 - (outsetLeft + outsetRight) * 2, 50 - (outsetTop + outsetBottom) * 2);
+ // Test expectations in the target. The target is scaled in half so the occlusion should be scaled within its contents as well.
+ IntRect expectedOcclusion = IntRect(200 / 2 + outsetRight * 2, 200 / 2 + outsetBottom * 2, 100 / 2 - (outsetLeft + outsetRight) * 2, 100 / 2 - (outsetTop + outsetBottom) * 2);
EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface().rects()[0]);
- // Test expectations in the screen. Take the ceiling of half of the outsets.
- outsetTop = (outsetTop + 1) / 2;
- outsetRight = (outsetRight + 1) / 2;
- outsetBottom = (outsetBottom + 1) / 2;
- outsetLeft = (outsetLeft + 1) / 2;
- expectedOcclusion = IntRect(100 / 2 + outsetRight * 2, 100 / 2 + outsetBottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 /2 - (outsetTop + outsetBottom) * 2);
-
+ // Test expectations in the screen. The parent is scaled in half so it will scale the occlusion to the screen as well.
+ expectedOcclusion = IntRect(200 / 2 + outsetRight * 2, 200 / 2 + outsetBottom * 2, 100 / 2 - (outsetLeft + outsetRight) * 2, 100 / 2 - (outsetTop + outsetBottom) * 2);
EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace().rects()[0]);
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice);
+// Scale transforms require main thread+commit to get contentBounds right.
+MAIN_THREAD_TEST(CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -2881,7 +2886,8 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter);
+// Scale transforms require main thread+commit to get contentBounds right.
+MAIN_THREAD_TEST(CCOcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -2929,7 +2935,8 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded);
+// Scale transforms require main thread+commit to get contentBounds right.
+MAIN_THREAD_TEST(CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -3001,7 +3008,8 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded);
+// Scale transforms require main thread+commit to get contentBounds right.
+MAIN_THREAD_TEST(CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestMinimumTrackingSize : public CCOcclusionTrackerTest<Types, opaqueLayers> {
« no previous file with comments | « cc/math_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698