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

Unified Diff: cc/trees/occlusion_unittest.cc

Issue 2402583005: Split picture layer quads to allow removing more occluded area. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 3 years, 6 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/trees/occlusion.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/occlusion_unittest.cc
diff --git a/cc/trees/occlusion_unittest.cc b/cc/trees/occlusion_unittest.cc
index da2f6fd0b6ebece769eac89ba4e74ffdbc70d8bc..caaaa506c5b1275527c572d5207efd6d711deab7 100644
--- a/cc/trees/occlusion_unittest.cc
+++ b/cc/trees/occlusion_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include "cc/base/region.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@@ -270,5 +271,49 @@ TEST(OcclusionTest, GetUnoccludedContentRectTranslated) {
EXPECT_EQ(gfx::Rect(10, 0, 10, 10), half_query_result_down);
}
+TEST(OcclusionTest, OccludeContentRegionScaled) {
+ gfx::Transform half_scale;
+ half_scale.Scale(0.5, 0.5);
+
+ gfx::Transform double_scale;
+ double_scale.Scale(2, 2);
+
+ Occlusion some_occluded_half(half_scale, SimpleEnclosedRegion(5, 5),
+ SimpleEnclosedRegion(5, 5, 5, 5));
+ Occlusion some_occluded_double(double_scale, SimpleEnclosedRegion(20, 20),
+ SimpleEnclosedRegion(19, 20, 21, 20));
+
+ Region region_half(gfx::Rect(5, 0, 15, 20));
+ some_occluded_half.OccludeContentRegion(&region_half);
+
+ Region result_region;
+ // Top right and bottom left rectangles should remain.
+ result_region.Union(gfx::Rect(10, 0, 10, 10));
+ result_region.Union(gfx::Rect(5, 10, 5, 10));
+ EXPECT_EQ(result_region.ToString(), region_half.ToString());
+
+ // The result should be the same as above, as the additional half-pixel
+ // occlusion should be ignored.
+ Region region_double(gfx::Rect(5, 0, 15, 20));
+ some_occluded_double.OccludeContentRegion(&region_double);
+ EXPECT_EQ(result_region.ToString(), region_double.ToString());
+}
+
+TEST(OcclusionTest, OccludeContentRegionRotate) {
+ gfx::Transform rotate_transform;
+ // Extremely small rotation.
+ rotate_transform.Rotate(1);
+
+ Occlusion occlusion(rotate_transform, SimpleEnclosedRegion(10, 10),
+ SimpleEnclosedRegion(10, 10, 10, 10));
+
+ Region region(gfx::Rect(1, 1, 1, 1));
+ Region occluded_region(region);
+ occlusion.OccludeContentRegion(&occluded_region);
+
+ // Transform isn't axis-aligned, so no occlusion should be done.
+ EXPECT_EQ(region.ToString(), occluded_region.ToString());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/trees/occlusion.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698