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