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

Side by Side Diff: cc/quads/render_pass_unittest.cc

Issue 208213003: Plumb overlay processing into DirectRenderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Exporting resources Created 6 years, 9 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 | Annotate | Revision Log
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/quads/render_pass.h" 5 #include "cc/quads/render_pass.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/base/scoped_ptr_vector.h" 8 #include "cc/base/scoped_ptr_vector.h"
9 #include "cc/output/copy_output_request.h" 9 #include "cc/output/copy_output_request.h"
10 #include "cc/quads/checkerboard_draw_quad.h" 10 #include "cc/quads/checkerboard_draw_quad.h"
(...skipping 13 matching lines...) Expand all
24 // If you add a new field to this class, make sure to add it to the 24 // If you add a new field to this class, make sure to add it to the
25 // Copy() tests. 25 // Copy() tests.
26 RenderPass::Id id; 26 RenderPass::Id id;
27 QuadList quad_list; 27 QuadList quad_list;
28 SharedQuadStateList shared_quad_state_list; 28 SharedQuadStateList shared_quad_state_list;
29 gfx::Transform transform_to_root_target; 29 gfx::Transform transform_to_root_target;
30 gfx::Rect output_rect; 30 gfx::Rect output_rect;
31 gfx::RectF damage_rect; 31 gfx::RectF damage_rect;
32 bool has_transparent_background; 32 bool has_transparent_background;
33 ScopedPtrVector<CopyOutputRequest> copy_callbacks; 33 ScopedPtrVector<CopyOutputRequest> copy_callbacks;
34 RenderPass::OverlayState overlay_state;
35 }; 34 };
36 35
37 static void CompareRenderPassLists(const RenderPassList& expected_list, 36 static void CompareRenderPassLists(const RenderPassList& expected_list,
38 const RenderPassList& actual_list) { 37 const RenderPassList& actual_list) {
39 EXPECT_EQ(expected_list.size(), actual_list.size()); 38 EXPECT_EQ(expected_list.size(), actual_list.size());
40 for (size_t i = 0; i < actual_list.size(); ++i) { 39 for (size_t i = 0; i < actual_list.size(); ++i) {
41 RenderPass* expected = expected_list[i]; 40 RenderPass* expected = expected_list[i];
42 RenderPass* actual = actual_list[i]; 41 RenderPass* actual = actual_list[i];
43 42
44 EXPECT_EQ(expected->id, actual->id); 43 EXPECT_EQ(expected->id, actual->id);
45 EXPECT_RECT_EQ(expected->output_rect, actual->output_rect); 44 EXPECT_RECT_EQ(expected->output_rect, actual->output_rect);
46 EXPECT_EQ(expected->transform_to_root_target, 45 EXPECT_EQ(expected->transform_to_root_target,
47 actual->transform_to_root_target); 46 actual->transform_to_root_target);
48 EXPECT_RECT_EQ(expected->damage_rect, actual->damage_rect); 47 EXPECT_RECT_EQ(expected->damage_rect, actual->damage_rect);
49 EXPECT_EQ(expected->has_transparent_background, 48 EXPECT_EQ(expected->has_transparent_background,
50 actual->has_transparent_background); 49 actual->has_transparent_background);
51 EXPECT_EQ(expected->overlay_state, actual->overlay_state);
52 50
53 EXPECT_EQ(expected->shared_quad_state_list.size(), 51 EXPECT_EQ(expected->shared_quad_state_list.size(),
54 actual->shared_quad_state_list.size()); 52 actual->shared_quad_state_list.size());
55 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); 53 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size());
56 54
57 for (size_t i = 0; i < expected->quad_list.size(); ++i) { 55 for (size_t i = 0; i < expected->quad_list.size(); ++i) {
58 EXPECT_EQ(expected->quad_list[i]->rect.ToString(), 56 EXPECT_EQ(expected->quad_list[i]->rect.ToString(),
59 actual->quad_list[i]->rect.ToString()); 57 actual->quad_list[i]->rect.ToString());
60 EXPECT_EQ( 58 EXPECT_EQ(
61 expected->quad_list[i]->shared_quad_state->content_bounds.ToString(), 59 expected->quad_list[i]->shared_quad_state->content_bounds.ToString(),
62 actual->quad_list[i]->shared_quad_state->content_bounds.ToString()); 60 actual->quad_list[i]->shared_quad_state->content_bounds.ToString());
63 } 61 }
64 } 62 }
65 } 63 }
66 64
67 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { 65 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) {
68 RenderPass::Id id(3, 2); 66 RenderPass::Id id(3, 2);
69 gfx::Rect output_rect(45, 22, 120, 13); 67 gfx::Rect output_rect(45, 22, 120, 13);
70 gfx::Transform transform_to_root = 68 gfx::Transform transform_to_root =
71 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 69 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
72 gfx::Rect damage_rect(56, 123, 19, 43); 70 gfx::Rect damage_rect(56, 123, 19, 43);
73 bool has_transparent_background = true; 71 bool has_transparent_background = true;
74 RenderPass::OverlayState overlay_state = RenderPass::SIMPLE_OVERLAY;
75 72
76 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 73 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
77 pass->SetAll(id, 74 pass->SetAll(id,
78 output_rect, 75 output_rect,
79 damage_rect, 76 damage_rect,
80 transform_to_root, 77 transform_to_root,
81 has_transparent_background, 78 has_transparent_background);
82 overlay_state);
83 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
84 80
85 // Stick a quad in the pass, this should not get copied. 81 // Stick a quad in the pass, this should not get copied.
86 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create(); 82 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create();
87 shared_state->SetAll(gfx::Transform(), 83 shared_state->SetAll(gfx::Transform(),
88 gfx::Size(), 84 gfx::Size(),
89 gfx::Rect(), 85 gfx::Rect(),
90 gfx::Rect(), 86 gfx::Rect(),
91 false, 87 false,
92 1, 88 1,
93 SkXfermode::kSrcOver_Mode); 89 SkXfermode::kSrcOver_Mode);
94 pass->AppendSharedQuadState(shared_state.Pass()); 90 pass->AppendSharedQuadState(shared_state.Pass());
95 91
96 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = 92 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad =
97 CheckerboardDrawQuad::Create(); 93 CheckerboardDrawQuad::Create();
98 checkerboard_quad->SetNew( 94 checkerboard_quad->SetNew(
99 pass->shared_quad_state_list.back(), gfx::Rect(), gfx::Rect(), SkColor()); 95 pass->shared_quad_state_list.back(), gfx::Rect(), gfx::Rect(), SkColor());
100 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); 96 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>());
101 97
102 RenderPass::Id new_id(63, 4); 98 RenderPass::Id new_id(63, 4);
103 99
104 scoped_ptr<RenderPass> copy = pass->Copy(new_id); 100 scoped_ptr<RenderPass> copy = pass->Copy(new_id);
105 EXPECT_EQ(new_id, copy->id); 101 EXPECT_EQ(new_id, copy->id);
106 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); 102 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect);
107 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); 103 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target);
108 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); 104 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect);
109 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); 105 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background);
110 EXPECT_EQ(pass->overlay_state, copy->overlay_state);
111 EXPECT_EQ(0u, copy->quad_list.size()); 106 EXPECT_EQ(0u, copy->quad_list.size());
112 107
113 // The copy request should not be copied/duplicated. 108 // The copy request should not be copied/duplicated.
114 EXPECT_EQ(1u, pass->copy_requests.size()); 109 EXPECT_EQ(1u, pass->copy_requests.size());
115 EXPECT_EQ(0u, copy->copy_requests.size()); 110 EXPECT_EQ(0u, copy->copy_requests.size());
116 111
117 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); 112 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass));
118 } 113 }
119 114
120 TEST(RenderPassTest, CopyAllShouldBeIdentical) { 115 TEST(RenderPassTest, CopyAllShouldBeIdentical) {
121 RenderPassList pass_list; 116 RenderPassList pass_list;
122 117
123 RenderPass::Id id(3, 2); 118 RenderPass::Id id(3, 2);
124 gfx::Rect output_rect(45, 22, 120, 13); 119 gfx::Rect output_rect(45, 22, 120, 13);
125 gfx::Transform transform_to_root = 120 gfx::Transform transform_to_root =
126 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 121 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
127 gfx::Rect damage_rect(56, 123, 19, 43); 122 gfx::Rect damage_rect(56, 123, 19, 43);
128 bool has_transparent_background = true; 123 bool has_transparent_background = true;
129 RenderPass::OverlayState overlay_state = RenderPass::SIMPLE_OVERLAY;
130 124
131 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 125 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
132 pass->SetAll(id, 126 pass->SetAll(id,
133 output_rect, 127 output_rect,
134 damage_rect, 128 damage_rect,
135 transform_to_root, 129 transform_to_root,
136 has_transparent_background, 130 has_transparent_background);
137 overlay_state);
138 131
139 // Two quads using one shared state. 132 // Two quads using one shared state.
140 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create(); 133 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create();
141 shared_state1->SetAll(gfx::Transform(), 134 shared_state1->SetAll(gfx::Transform(),
142 gfx::Size(1, 1), 135 gfx::Size(1, 1),
143 gfx::Rect(), 136 gfx::Rect(),
144 gfx::Rect(), 137 gfx::Rect(),
145 false, 138 false,
146 1, 139 1,
147 SkXfermode::kSrcOver_Mode); 140 SkXfermode::kSrcOver_Mode);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 SkColor()); 183 SkColor());
191 pass->quad_list.push_back(checkerboard_quad4.PassAs<DrawQuad>()); 184 pass->quad_list.push_back(checkerboard_quad4.PassAs<DrawQuad>());
192 185
193 // A second render pass with a quad. 186 // A second render pass with a quad.
194 RenderPass::Id contrib_id(4, 1); 187 RenderPass::Id contrib_id(4, 1);
195 gfx::Rect contrib_output_rect(10, 15, 12, 17); 188 gfx::Rect contrib_output_rect(10, 15, 12, 17);
196 gfx::Transform contrib_transform_to_root = 189 gfx::Transform contrib_transform_to_root =
197 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 190 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
198 gfx::Rect contrib_damage_rect(11, 16, 10, 15); 191 gfx::Rect contrib_damage_rect(11, 16, 10, 15);
199 bool contrib_has_transparent_background = true; 192 bool contrib_has_transparent_background = true;
200 RenderPass::OverlayState contrib_overlay_state = RenderPass::SIMPLE_OVERLAY;
201 193
202 scoped_ptr<TestRenderPass> contrib = TestRenderPass::Create(); 194 scoped_ptr<TestRenderPass> contrib = TestRenderPass::Create();
203 contrib->SetAll(contrib_id, 195 contrib->SetAll(contrib_id,
204 contrib_output_rect, 196 contrib_output_rect,
205 contrib_damage_rect, 197 contrib_damage_rect,
206 contrib_transform_to_root, 198 contrib_transform_to_root,
207 contrib_has_transparent_background, 199 contrib_has_transparent_background);
208 contrib_overlay_state);
209 200
210 scoped_ptr<SharedQuadState> contrib_shared_state = SharedQuadState::Create(); 201 scoped_ptr<SharedQuadState> contrib_shared_state = SharedQuadState::Create();
211 contrib_shared_state->SetAll(gfx::Transform(), 202 contrib_shared_state->SetAll(gfx::Transform(),
212 gfx::Size(2, 2), 203 gfx::Size(2, 2),
213 gfx::Rect(), 204 gfx::Rect(),
214 gfx::Rect(), 205 gfx::Rect(),
215 false, 206 false,
216 1, 207 1,
217 SkXfermode::kSrcOver_Mode); 208 SkXfermode::kSrcOver_Mode);
218 contrib->AppendSharedQuadState(contrib_shared_state.Pass()); 209 contrib->AppendSharedQuadState(contrib_shared_state.Pass());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 242
252 TEST(RenderPassTest, CopyAllWithCulledQuads) { 243 TEST(RenderPassTest, CopyAllWithCulledQuads) {
253 RenderPassList pass_list; 244 RenderPassList pass_list;
254 245
255 RenderPass::Id id(3, 2); 246 RenderPass::Id id(3, 2);
256 gfx::Rect output_rect(45, 22, 120, 13); 247 gfx::Rect output_rect(45, 22, 120, 13);
257 gfx::Transform transform_to_root = 248 gfx::Transform transform_to_root =
258 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 249 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
259 gfx::Rect damage_rect(56, 123, 19, 43); 250 gfx::Rect damage_rect(56, 123, 19, 43);
260 bool has_transparent_background = true; 251 bool has_transparent_background = true;
261 RenderPass::OverlayState overlay_state = RenderPass::SIMPLE_OVERLAY;
262 252
263 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 253 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
264 pass->SetAll(id, 254 pass->SetAll(id,
265 output_rect, 255 output_rect,
266 damage_rect, 256 damage_rect,
267 transform_to_root, 257 transform_to_root,
268 has_transparent_background, 258 has_transparent_background);
269 overlay_state);
270 259
271 // A shared state with a quad. 260 // A shared state with a quad.
272 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create(); 261 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create();
273 shared_state1->SetAll(gfx::Transform(), 262 shared_state1->SetAll(gfx::Transform(),
274 gfx::Size(1, 1), 263 gfx::Size(1, 1),
275 gfx::Rect(), 264 gfx::Rect(),
276 gfx::Rect(), 265 gfx::Rect(),
277 false, 266 false,
278 1, 267 1,
279 SkXfermode::kSrcOver_Mode); 268 SkXfermode::kSrcOver_Mode);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 321
333 // Make a copy with CopyAll(). 322 // Make a copy with CopyAll().
334 RenderPassList copy_list; 323 RenderPassList copy_list;
335 RenderPass::CopyAll(pass_list, &copy_list); 324 RenderPass::CopyAll(pass_list, &copy_list);
336 325
337 CompareRenderPassLists(pass_list, copy_list); 326 CompareRenderPassLists(pass_list, copy_list);
338 } 327 }
339 328
340 } // namespace 329 } // namespace
341 } // namespace cc 330 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698