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 22 matching lines...) Expand all Loading... |
33 gfx::ToFlooredSize(r.size()) == r.size()) | 33 gfx::ToFlooredSize(r.size()) == r.size()) |
34 return true; | 34 return true; |
35 | 35 |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 void LayerTestCommon::VerifyQuadsExactlyCoverRect(const QuadList& quads, | 39 void LayerTestCommon::VerifyQuadsExactlyCoverRect(const QuadList& quads, |
40 const gfx::Rect& rect) { | 40 const gfx::Rect& rect) { |
41 Region remaining = rect; | 41 Region remaining = rect; |
42 | 42 |
43 for (size_t i = 0; i < quads.size(); ++i) { | 43 size_t i = 0; |
44 DrawQuad* quad = quads[i]; | 44 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end(); |
| 45 ++iter) { |
| 46 const DrawQuad* quad = &*iter; |
45 gfx::RectF quad_rectf = | 47 gfx::RectF quad_rectf = |
46 MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect)); | 48 MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect)); |
47 | 49 |
48 // Before testing for exact coverage in the integer world, assert that | 50 // Before testing for exact coverage in the integer world, assert that |
49 // rounding will not round the rect incorrectly. | 51 // rounding will not round the rect incorrectly. |
50 ASSERT_TRUE(CanRectFBeSafelyRoundedToRect(quad_rectf)); | 52 ASSERT_TRUE(CanRectFBeSafelyRoundedToRect(quad_rectf)); |
51 | 53 |
52 gfx::Rect quad_rect = gfx::ToEnclosingRect(quad_rectf); | 54 gfx::Rect quad_rect = gfx::ToEnclosingRect(quad_rectf); |
53 | 55 |
54 EXPECT_TRUE(rect.Contains(quad_rect)) << quad_string << i | 56 EXPECT_TRUE(rect.Contains(quad_rect)) << quad_string << i |
55 << " rect: " << rect.ToString() | 57 << " rect: " << rect.ToString() |
56 << " quad: " << quad_rect.ToString(); | 58 << " quad: " << quad_rect.ToString(); |
57 EXPECT_TRUE(remaining.Contains(quad_rect)) | 59 EXPECT_TRUE(remaining.Contains(quad_rect)) |
58 << quad_string << i << " remaining: " << remaining.ToString() | 60 << quad_string << i << " remaining: " << remaining.ToString() |
59 << " quad: " << quad_rect.ToString(); | 61 << " quad: " << quad_rect.ToString(); |
60 remaining.Subtract(quad_rect); | 62 remaining.Subtract(quad_rect); |
| 63 |
| 64 ++i; |
61 } | 65 } |
62 | 66 |
63 EXPECT_TRUE(remaining.IsEmpty()); | 67 EXPECT_TRUE(remaining.IsEmpty()); |
64 } | 68 } |
65 | 69 |
66 // static | 70 // static |
67 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads, | 71 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads, |
68 const gfx::Rect& occluded, | 72 const gfx::Rect& occluded, |
69 size_t* partially_occluded_count) { | 73 size_t* partially_occluded_count) { |
70 // No quad should exist if it's fully occluded. | 74 // No quad should exist if it's fully occluded. |
71 for (size_t i = 0; i < quads.size(); ++i) { | 75 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end(); |
| 76 ++iter) { |
72 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( | 77 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( |
73 quads[i]->quadTransform(), quads[i]->visible_rect); | 78 iter->quadTransform(), iter->visible_rect); |
74 EXPECT_FALSE(occluded.Contains(target_visible_rect)); | 79 EXPECT_FALSE(occluded.Contains(target_visible_rect)); |
75 } | 80 } |
76 | 81 |
77 // Quads that are fully occluded on one axis only should be shrunken. | 82 // Quads that are fully occluded on one axis only should be shrunken. |
78 for (size_t i = 0; i < quads.size(); ++i) { | 83 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end(); |
79 DrawQuad* quad = quads[i]; | 84 ++iter) { |
| 85 const DrawQuad* quad = &*iter; |
80 DCHECK(quad->quadTransform().IsIdentityOrIntegerTranslation()); | 86 DCHECK(quad->quadTransform().IsIdentityOrIntegerTranslation()); |
81 gfx::Rect target_rect = | 87 gfx::Rect target_rect = |
82 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect); | 88 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect); |
83 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( | 89 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( |
84 quad->quadTransform(), quad->visible_rect); | 90 quad->quadTransform(), quad->visible_rect); |
85 | 91 |
86 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && | 92 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && |
87 target_rect.right() <= occluded.right(); | 93 target_rect.right() <= occluded.right(); |
88 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && | 94 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && |
89 target_rect.bottom() <= occluded.bottom(); | 95 target_rect.bottom() <= occluded.bottom(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 render_pass_->shared_quad_state_list.clear(); | 162 render_pass_->shared_quad_state_list.clear(); |
157 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( | 163 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( |
158 occluded); | 164 occluded); |
159 bool for_replica = false; | 165 bool for_replica = false; |
160 RenderPassId id(1, 1); | 166 RenderPassId id(1, 1); |
161 surface_impl->AppendQuads( | 167 surface_impl->AppendQuads( |
162 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); | 168 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); |
163 } | 169 } |
164 | 170 |
165 } // namespace cc | 171 } // namespace cc |
OLD | NEW |