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 size_t i = 0; | |
44 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end(); | 43 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end(); |
45 ++iter) { | 44 ++iter) { |
46 const DrawQuad* quad = &*iter; | 45 const DrawQuad* quad = &*iter; |
47 gfx::RectF quad_rectf = | 46 gfx::RectF quad_rectf = |
48 MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect)); | 47 MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect)); |
49 | 48 |
50 // Before testing for exact coverage in the integer world, assert that | 49 // Before testing for exact coverage in the integer world, assert that |
51 // rounding will not round the rect incorrectly. | 50 // rounding will not round the rect incorrectly. |
52 ASSERT_TRUE(CanRectFBeSafelyRoundedToRect(quad_rectf)); | 51 ASSERT_TRUE(CanRectFBeSafelyRoundedToRect(quad_rectf)); |
53 | 52 |
54 gfx::Rect quad_rect = gfx::ToEnclosingRect(quad_rectf); | 53 gfx::Rect quad_rect = gfx::ToEnclosingRect(quad_rectf); |
55 | 54 |
56 EXPECT_TRUE(rect.Contains(quad_rect)) << quad_string << i | 55 EXPECT_TRUE(rect.Contains(quad_rect)) << quad_string << iter.index() |
57 << " rect: " << rect.ToString() | 56 << " rect: " << rect.ToString() |
58 << " quad: " << quad_rect.ToString(); | 57 << " quad: " << quad_rect.ToString(); |
59 EXPECT_TRUE(remaining.Contains(quad_rect)) | 58 EXPECT_TRUE(remaining.Contains(quad_rect)) |
60 << quad_string << i << " remaining: " << remaining.ToString() | 59 << quad_string << iter.index() << " remaining: " << remaining.ToString() |
61 << " quad: " << quad_rect.ToString(); | 60 << " quad: " << quad_rect.ToString(); |
62 remaining.Subtract(quad_rect); | 61 remaining.Subtract(quad_rect); |
63 | |
64 ++i; | |
65 } | 62 } |
66 | 63 |
67 EXPECT_TRUE(remaining.IsEmpty()); | 64 EXPECT_TRUE(remaining.IsEmpty()); |
68 } | 65 } |
69 | 66 |
70 // static | 67 // static |
71 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads, | 68 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads, |
72 const gfx::Rect& occluded, | 69 const gfx::Rect& occluded, |
73 size_t* partially_occluded_count) { | 70 size_t* partially_occluded_count) { |
74 // No quad should exist if it's fully occluded. | 71 // No quad should exist if it's fully occluded. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 render_pass_->shared_quad_state_list.clear(); | 158 render_pass_->shared_quad_state_list.clear(); |
162 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( | 159 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( |
163 occluded); | 160 occluded); |
164 bool for_replica = false; | 161 bool for_replica = false; |
165 RenderPassId id(1, 1); | 162 RenderPassId id(1, 1); |
166 surface_impl->AppendQuads( | 163 surface_impl->AppendQuads( |
167 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); | 164 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); |
168 } | 165 } |
169 | 166 |
170 } // namespace cc | 167 } // namespace cc |
OLD | NEW |