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

Side by Side Diff: cc/test/layer_test_common.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/test/layer_test_common.h ('k') | cc/trees/occlusion.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/test/layer_test_common.h" 5 #include "cc/test/layer_test_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/animation/animation_host.h" 9 #include "cc/animation/animation_host.h"
10 #include "cc/animation/animation_id_provider.h" 10 #include "cc/animation/animation_id_provider.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 << " quad: " << quad_rect.ToString(); 79 << " quad: " << quad_rect.ToString();
80 remaining.Subtract(quad_rect); 80 remaining.Subtract(quad_rect);
81 } 81 }
82 82
83 EXPECT_TRUE(remaining.IsEmpty()); 83 EXPECT_TRUE(remaining.IsEmpty());
84 } 84 }
85 85
86 // static 86 // static
87 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads, 87 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads,
88 const gfx::Rect& occluded, 88 const gfx::Rect& occluded,
89 bool split_quads,
89 size_t* partially_occluded_count) { 90 size_t* partially_occluded_count) {
90 // No quad should exist if it's fully occluded. 91 // No quad should exist if it's fully occluded.
91 for (auto* quad : quads) { 92 for (auto* quad : quads) {
92 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( 93 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect(
93 quad->shared_quad_state->quad_to_target_transform, quad->visible_rect); 94 quad->shared_quad_state->quad_to_target_transform, quad->visible_rect);
94 EXPECT_FALSE(occluded.Contains(target_visible_rect)); 95 EXPECT_FALSE(occluded.Contains(target_visible_rect));
95 } 96 }
96 97
97 // Quads that are fully occluded on one axis only should be shrunken. 98 // Quads that are fully occluded on one axis only should be shrunken.
98 for (auto* quad : quads) { 99 for (auto* quad : quads) {
99 gfx::Rect target_rect = MathUtil::MapEnclosingClippedRect( 100 gfx::Rect target_rect = MathUtil::MapEnclosingClippedRect(
100 quad->shared_quad_state->quad_to_target_transform, quad->rect); 101 quad->shared_quad_state->quad_to_target_transform, quad->rect);
101 if (!quad->shared_quad_state->quad_to_target_transform 102 if (!quad->shared_quad_state->quad_to_target_transform
102 .IsIdentityOrIntegerTranslation()) { 103 .IsIdentityOrIntegerTranslation()) {
103 DCHECK(quad->shared_quad_state->quad_to_target_transform 104 DCHECK(quad->shared_quad_state->quad_to_target_transform
104 .IsPositiveScaleOrTranslation()) 105 .IsPositiveScaleOrTranslation())
105 << quad->shared_quad_state->quad_to_target_transform.ToString(); 106 << quad->shared_quad_state->quad_to_target_transform.ToString();
106 gfx::RectF target_rectf = MathUtil::MapClippedRect( 107 gfx::RectF target_rectf = MathUtil::MapClippedRect(
107 quad->shared_quad_state->quad_to_target_transform, 108 quad->shared_quad_state->quad_to_target_transform,
108 gfx::RectF(quad->rect)); 109 gfx::RectF(quad->rect));
109 // Scale transforms allowed, as long as the final transformed rect 110 // Scale transforms allowed, as long as the final transformed rect
110 // ends up on integer boundaries for ease of testing. 111 // ends up on integer boundaries for ease of testing.
111 ASSERT_EQ(target_rectf, gfx::RectF(target_rect)); 112 ASSERT_EQ(target_rectf, gfx::RectF(target_rect));
112 } 113 }
113 114
114 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && 115 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() &&
115 target_rect.right() <= occluded.right(); 116 target_rect.right() <= occluded.right();
116 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && 117 bool fully_occluded_vertical = target_rect.y() >= occluded.y() &&
117 target_rect.bottom() <= occluded.bottom(); 118 target_rect.bottom() <= occluded.bottom();
118 bool should_be_occluded = 119 bool should_be_occluded = target_rect.Intersects(occluded);
119 target_rect.Intersects(occluded) && 120 if (!split_quads && !(fully_occluded_vertical || fully_occluded_horizontal))
120 (fully_occluded_vertical || fully_occluded_horizontal); 121 should_be_occluded = false;
121 if (!should_be_occluded) { 122 if (!should_be_occluded) {
122 EXPECT_EQ(quad->rect.ToString(), quad->visible_rect.ToString()); 123 EXPECT_EQ(quad->rect.ToString(), quad->visible_rect.ToString());
123 } else { 124 } else {
124 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString()); 125 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString());
125 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect)); 126 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect));
126 ++(*partially_occluded_count); 127 ++(*partially_occluded_count);
127 } 128 }
128 } 129 }
129 } 130 }
130 131
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 230 }
230 231
231 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 232 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
232 233
233 void LayerTestCommon::LayerImplTest::RequestCopyOfOutput() { 234 void LayerTestCommon::LayerImplTest::RequestCopyOfOutput() {
234 root_layer_for_testing()->test_properties()->copy_requests.push_back( 235 root_layer_for_testing()->test_properties()->copy_requests.push_back(
235 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 236 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
236 } 237 }
237 238
238 } // namespace cc 239 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_test_common.h ('k') | cc/trees/occlusion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698