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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/trees/occlusion.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/occlusion.h" 5 #include "cc/trees/occlusion.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/base/region.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace cc { 12 namespace cc {
12 namespace { 13 namespace {
13 14
14 TEST(OcclusionTest, HasOcclusion) { 15 TEST(OcclusionTest, HasOcclusion) {
15 Occlusion empty; 16 Occlusion empty;
16 EXPECT_FALSE(empty.HasOcclusion()); 17 EXPECT_FALSE(empty.HasOcclusion());
17 18
18 empty = Occlusion( 19 empty = Occlusion(
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_EQ(gfx::Rect(20, 20), full_query_result_down); 264 EXPECT_EQ(gfx::Rect(20, 20), full_query_result_down);
264 265
265 gfx::Rect half_query_result_left = 266 gfx::Rect half_query_result_left =
266 some_occluded_left.GetUnoccludedContentRect(gfx::Rect(10, 0, 10, 20)); 267 some_occluded_left.GetUnoccludedContentRect(gfx::Rect(10, 0, 10, 20));
267 gfx::Rect half_query_result_down = 268 gfx::Rect half_query_result_down =
268 some_occluded_down.GetUnoccludedContentRect(gfx::Rect(10, 0, 10, 20)); 269 some_occluded_down.GetUnoccludedContentRect(gfx::Rect(10, 0, 10, 20));
269 EXPECT_EQ(gfx::Rect(10, 0, 10, 10), half_query_result_left); 270 EXPECT_EQ(gfx::Rect(10, 0, 10, 10), half_query_result_left);
270 EXPECT_EQ(gfx::Rect(10, 0, 10, 10), half_query_result_down); 271 EXPECT_EQ(gfx::Rect(10, 0, 10, 10), half_query_result_down);
271 } 272 }
272 273
274 TEST(OcclusionTest, OccludeContentRegionScaled) {
275 gfx::Transform half_scale;
276 half_scale.Scale(0.5, 0.5);
277
278 gfx::Transform double_scale;
279 double_scale.Scale(2, 2);
280
281 Occlusion some_occluded_half(half_scale, SimpleEnclosedRegion(5, 5),
282 SimpleEnclosedRegion(5, 5, 5, 5));
283 Occlusion some_occluded_double(double_scale, SimpleEnclosedRegion(20, 20),
284 SimpleEnclosedRegion(19, 20, 21, 20));
285
286 Region region_half(gfx::Rect(5, 0, 15, 20));
287 some_occluded_half.OccludeContentRegion(&region_half);
288
289 Region result_region;
290 // Top right and bottom left rectangles should remain.
291 result_region.Union(gfx::Rect(10, 0, 10, 10));
292 result_region.Union(gfx::Rect(5, 10, 5, 10));
293 EXPECT_EQ(result_region.ToString(), region_half.ToString());
294
295 // The result should be the same as above, as the additional half-pixel
296 // occlusion should be ignored.
297 Region region_double(gfx::Rect(5, 0, 15, 20));
298 some_occluded_double.OccludeContentRegion(&region_double);
299 EXPECT_EQ(result_region.ToString(), region_double.ToString());
300 }
301
302 TEST(OcclusionTest, OccludeContentRegionRotate) {
303 gfx::Transform rotate_transform;
304 // Extremely small rotation.
305 rotate_transform.Rotate(1);
306
307 Occlusion occlusion(rotate_transform, SimpleEnclosedRegion(10, 10),
308 SimpleEnclosedRegion(10, 10, 10, 10));
309
310 Region region(gfx::Rect(1, 1, 1, 1));
311 Region occluded_region(region);
312 occlusion.OccludeContentRegion(&occluded_region);
313
314 // Transform isn't axis-aligned, so no occlusion should be done.
315 EXPECT_EQ(region.ToString(), occluded_region.ToString());
316 }
317
273 } // namespace 318 } // namespace
274 } // namespace cc 319 } // namespace cc
OLDNEW
« 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