OLD | NEW |
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 "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/quads/draw_quad.h" | 10 #include "cc/quads/draw_quad.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 size_t* partially_occluded_count) { | 68 size_t* partially_occluded_count) { |
69 // No quad should exist if it's fully occluded. | 69 // No quad should exist if it's fully occluded. |
70 for (const auto& quad : quads) { | 70 for (const auto& quad : quads) { |
71 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( | 71 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( |
72 quad->quadTransform(), quad->visible_rect); | 72 quad->quadTransform(), quad->visible_rect); |
73 EXPECT_FALSE(occluded.Contains(target_visible_rect)); | 73 EXPECT_FALSE(occluded.Contains(target_visible_rect)); |
74 } | 74 } |
75 | 75 |
76 // Quads that are fully occluded on one axis only should be shrunken. | 76 // Quads that are fully occluded on one axis only should be shrunken. |
77 for (const auto& quad : quads) { | 77 for (const auto& quad : quads) { |
| 78 DCHECK(quad->quadTransform().IsIdentityOrIntegerTranslation()); |
78 gfx::Rect target_rect = | 79 gfx::Rect target_rect = |
79 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect); | 80 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect); |
80 if (!quad->quadTransform().IsIdentityOrIntegerTranslation()) { | |
81 DCHECK(quad->quadTransform().IsPositiveScaleOrTranslation()) | |
82 << quad->quadTransform().ToString(); | |
83 gfx::RectF target_rectf = | |
84 MathUtil::MapClippedRect(quad->quadTransform(), quad->rect); | |
85 // Scale transforms allowed, as long as the final transformed rect | |
86 // ends up on integer boundaries for ease of testing. | |
87 DCHECK_EQ(target_rectf.ToString(), gfx::RectF(target_rect).ToString()); | |
88 } | |
89 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( | 81 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( |
90 quad->quadTransform(), quad->visible_rect); | 82 quad->quadTransform(), quad->visible_rect); |
91 | 83 |
92 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && | 84 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && |
93 target_rect.right() <= occluded.right(); | 85 target_rect.right() <= occluded.right(); |
94 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && | 86 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && |
95 target_rect.bottom() <= occluded.bottom(); | 87 target_rect.bottom() <= occluded.bottom(); |
96 bool should_be_occluded = | 88 bool should_be_occluded = |
97 target_rect.Intersects(occluded) && | 89 target_rect.Intersects(occluded) && |
98 (fully_occluded_vertical || fully_occluded_horizontal); | 90 (fully_occluded_vertical || fully_occluded_horizontal); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 render_pass_->shared_quad_state_list.clear(); | 162 render_pass_->shared_quad_state_list.clear(); |
171 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( | 163 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( |
172 occluded); | 164 occluded); |
173 bool for_replica = false; | 165 bool for_replica = false; |
174 RenderPassId id(1, 1); | 166 RenderPassId id(1, 1); |
175 surface_impl->AppendQuads( | 167 surface_impl->AppendQuads( |
176 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); | 168 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); |
177 } | 169 } |
178 | 170 |
179 } // namespace cc | 171 } // namespace cc |
OLD | NEW |