summaryrefslogtreecommitdiffstats
path: root/cc/test/layer_test_common.cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-13 23:40:36 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-13 23:40:36 +0000
commit30f0115492172f36a53d59c2571798129d63cb76 (patch)
tree36735cf5cebc0fba4bc04ab82e6101911711c4fe /cc/test/layer_test_common.cc
parent9846c37e9366cd87bc04275ce7af051364eaa24b (diff)
downloadchromium_src-30f0115492172f36a53d59c2571798129d63cb76.zip
chromium_src-30f0115492172f36a53d59c2571798129d63cb76.tar.gz
chromium_src-30f0115492172f36a53d59c2571798129d63cb76.tar.bz2
cc: Apply occlusion before creating quads in SolidColorLayerImpl.
This makes the AppendQuads method query occlusion directly and subtract it from the quads it would create before they are created, skipping quads that are completely occluded and avoiding a malloc/free for them. R=enne BUG=344962 Review URL: https://codereview.chromium.org/196523005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/layer_test_common.cc')
-rw-r--r--cc/test/layer_test_common.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc
index 0171999..66e49a8 100644
--- a/cc/test/layer_test_common.cc
+++ b/cc/test/layer_test_common.cc
@@ -55,4 +55,35 @@ void LayerTestCommon::VerifyQuadsExactlyCoverRect(const QuadList& quads,
EXPECT_TRUE(remaining.IsEmpty());
}
+// static
+void LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
+ const QuadList& quads,
+ const gfx::Rect& rect,
+ const gfx::Rect& occluded,
+ size_t* partially_occluded_count) {
+ // No quad should exist if it's fully occluded.
+ for (size_t i = 0; i < quads.size(); ++i) {
+ EXPECT_FALSE(occluded.Contains(quads[i]->visible_rect));
+ }
+
+ // Quads that are fully occluded on one axis only should be shrunken.
+ for (size_t i = 0; i < quads.size(); ++i) {
+ DrawQuad* quad = quads[i];
+ bool fully_occluded_horizontal = quad->rect.x() >= occluded.x() &&
+ quad->rect.right() <= occluded.right();
+ bool fully_occluded_vertical = quad->rect.y() >= occluded.y() &&
+ quad->rect.bottom() <= occluded.bottom();
+ bool should_be_occluded =
+ quad->rect.Intersects(occluded) &&
+ (fully_occluded_vertical || fully_occluded_horizontal);
+ if (!should_be_occluded) {
+ EXPECT_EQ(quad->rect.ToString(), quad->visible_rect.ToString());
+ } else {
+ EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString());
+ EXPECT_TRUE(quad->rect.Contains(quad->visible_rect));
+ ++(*partially_occluded_count);
+ }
+ }
+}
+
} // namespace cc