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

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

Issue 2502373003: stop using SkXfermode -- use SkBlendMode instead (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « cc/quads/draw_quad_unittest.cc ('k') | cc/quads/shared_quad_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 73 std::unique_ptr<RenderPass> pass = RenderPass::Create();
74 pass->SetAll(id, 74 pass->SetAll(id,
75 output_rect, 75 output_rect,
76 damage_rect, 76 damage_rect,
77 transform_to_root, 77 transform_to_root,
78 has_transparent_background); 78 has_transparent_background);
79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
80 80
81 // Stick a quad in the pass, this should not get copied. 81 // Stick a quad in the pass, this should not get copied.
82 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); 82 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState();
83 shared_state->SetAll(gfx::Transform(), 83 shared_state->SetAll(gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(),
84 gfx::Size(), 84 false, 1, SkBlendMode::kSrcOver, 0);
85 gfx::Rect(),
86 gfx::Rect(),
87 false,
88 1,
89 SkXfermode::kSrcOver_Mode,
90 0);
91 85
92 SolidColorDrawQuad* color_quad = 86 SolidColorDrawQuad* color_quad =
93 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 87 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
94 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), 88 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(),
95 gfx::Rect(), SkColor(), false); 89 gfx::Rect(), SkColor(), false);
96 90
97 RenderPassId new_id(63, 4); 91 RenderPassId new_id(63, 4);
98 92
99 std::unique_ptr<RenderPass> copy = pass->Copy(new_id); 93 std::unique_ptr<RenderPass> copy = pass->Copy(new_id);
100 EXPECT_EQ(new_id, copy->id); 94 EXPECT_EQ(new_id, copy->id);
(...skipping 22 matching lines...) Expand all
123 117
124 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 118 std::unique_ptr<RenderPass> pass = RenderPass::Create();
125 pass->SetAll(id, 119 pass->SetAll(id,
126 output_rect, 120 output_rect,
127 damage_rect, 121 damage_rect,
128 transform_to_root, 122 transform_to_root,
129 has_transparent_background); 123 has_transparent_background);
130 124
131 // Two quads using one shared state. 125 // Two quads using one shared state.
132 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); 126 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
133 shared_state1->SetAll(gfx::Transform(), 127 shared_state1->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(),
134 gfx::Size(1, 1), 128 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
135 gfx::Rect(),
136 gfx::Rect(),
137 false,
138 1,
139 SkXfermode::kSrcOver_Mode,
140 0);
141 129
142 SolidColorDrawQuad* color_quad1 = 130 SolidColorDrawQuad* color_quad1 =
143 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 131 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
144 color_quad1->SetNew(pass->shared_quad_state_list.back(), 132 color_quad1->SetNew(pass->shared_quad_state_list.back(),
145 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), 133 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(),
146 false); 134 false);
147 135
148 SolidColorDrawQuad* color_quad2 = 136 SolidColorDrawQuad* color_quad2 =
149 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 137 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
150 color_quad2->SetNew(pass->shared_quad_state_list.back(), 138 color_quad2->SetNew(pass->shared_quad_state_list.back(),
151 gfx::Rect(2, 2, 2, 2), gfx::Rect(2, 2, 2, 2), SkColor(), 139 gfx::Rect(2, 2, 2, 2), gfx::Rect(2, 2, 2, 2), SkColor(),
152 false); 140 false);
153 141
154 // And two quads using another shared state. 142 // And two quads using another shared state.
155 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); 143 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState();
156 shared_state2->SetAll(gfx::Transform(), 144 shared_state2->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
157 gfx::Size(2, 2), 145 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
158 gfx::Rect(),
159 gfx::Rect(),
160 false,
161 1,
162 SkXfermode::kSrcOver_Mode,
163 0);
164 146
165 SolidColorDrawQuad* color_quad3 = 147 SolidColorDrawQuad* color_quad3 =
166 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 148 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
167 color_quad3->SetNew(pass->shared_quad_state_list.back(), 149 color_quad3->SetNew(pass->shared_quad_state_list.back(),
168 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), 150 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(),
169 false); 151 false);
170 152
171 SolidColorDrawQuad* color_quad4 = 153 SolidColorDrawQuad* color_quad4 =
172 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 154 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
173 color_quad4->SetNew(pass->shared_quad_state_list.back(), 155 color_quad4->SetNew(pass->shared_quad_state_list.back(),
(...skipping 10 matching lines...) Expand all
184 166
185 std::unique_ptr<RenderPass> contrib = RenderPass::Create(); 167 std::unique_ptr<RenderPass> contrib = RenderPass::Create();
186 contrib->SetAll(contrib_id, 168 contrib->SetAll(contrib_id,
187 contrib_output_rect, 169 contrib_output_rect,
188 contrib_damage_rect, 170 contrib_damage_rect,
189 contrib_transform_to_root, 171 contrib_transform_to_root,
190 contrib_has_transparent_background); 172 contrib_has_transparent_background);
191 173
192 SharedQuadState* contrib_shared_state = 174 SharedQuadState* contrib_shared_state =
193 contrib->CreateAndAppendSharedQuadState(); 175 contrib->CreateAndAppendSharedQuadState();
194 contrib_shared_state->SetAll(gfx::Transform(), 176 contrib_shared_state->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
195 gfx::Size(2, 2), 177 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
196 gfx::Rect(),
197 gfx::Rect(),
198 false,
199 1,
200 SkXfermode::kSrcOver_Mode,
201 0);
202 178
203 SolidColorDrawQuad* contrib_quad = 179 SolidColorDrawQuad* contrib_quad =
204 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 180 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
205 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), 181 contrib_quad->SetNew(contrib->shared_quad_state_list.back(),
206 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), 182 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(),
207 false); 183 false);
208 184
209 // And a RenderPassDrawQuad for the contributing pass. 185 // And a RenderPassDrawQuad for the contributing pass.
210 std::unique_ptr<RenderPassDrawQuad> pass_quad = 186 std::unique_ptr<RenderPassDrawQuad> pass_quad =
211 base::WrapUnique(new RenderPassDrawQuad); 187 base::WrapUnique(new RenderPassDrawQuad);
(...skipping 24 matching lines...) Expand all
236 212
237 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 213 std::unique_ptr<RenderPass> pass = RenderPass::Create();
238 pass->SetAll(id, 214 pass->SetAll(id,
239 output_rect, 215 output_rect,
240 damage_rect, 216 damage_rect,
241 transform_to_root, 217 transform_to_root,
242 has_transparent_background); 218 has_transparent_background);
243 219
244 // A shared state with a quad. 220 // A shared state with a quad.
245 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); 221 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
246 shared_state1->SetAll(gfx::Transform(), 222 shared_state1->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(),
247 gfx::Size(1, 1), 223 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
248 gfx::Rect(),
249 gfx::Rect(),
250 false,
251 1,
252 SkXfermode::kSrcOver_Mode,
253 0);
254 224
255 SolidColorDrawQuad* color_quad1 = 225 SolidColorDrawQuad* color_quad1 =
256 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 226 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
257 color_quad1->SetNew(pass->shared_quad_state_list.back(), 227 color_quad1->SetNew(pass->shared_quad_state_list.back(),
258 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), 228 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(),
259 false); 229 false);
260 230
261 // A shared state with no quads, they were culled. 231 // A shared state with no quads, they were culled.
262 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); 232 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState();
263 shared_state2->SetAll(gfx::Transform(), 233 shared_state2->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
264 gfx::Size(2, 2), 234 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
265 gfx::Rect(),
266 gfx::Rect(),
267 false,
268 1,
269 SkXfermode::kSrcOver_Mode,
270 0);
271 235
272 // A second shared state with no quads. 236 // A second shared state with no quads.
273 SharedQuadState* shared_state3 = pass->CreateAndAppendSharedQuadState(); 237 SharedQuadState* shared_state3 = pass->CreateAndAppendSharedQuadState();
274 shared_state3->SetAll(gfx::Transform(), 238 shared_state3->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
275 gfx::Size(2, 2), 239 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
276 gfx::Rect(),
277 gfx::Rect(),
278 false,
279 1,
280 SkXfermode::kSrcOver_Mode,
281 0);
282 240
283 // A last shared state with a quad again. 241 // A last shared state with a quad again.
284 SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState(); 242 SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState();
285 shared_state4->SetAll(gfx::Transform(), 243 shared_state4->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
286 gfx::Size(2, 2), 244 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
287 gfx::Rect(),
288 gfx::Rect(),
289 false,
290 1,
291 SkXfermode::kSrcOver_Mode,
292 0);
293 245
294 SolidColorDrawQuad* color_quad2 = 246 SolidColorDrawQuad* color_quad2 =
295 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 247 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
296 color_quad2->SetNew(pass->shared_quad_state_list.back(), 248 color_quad2->SetNew(pass->shared_quad_state_list.back(),
297 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), 249 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(),
298 false); 250 false);
299 251
300 pass_list.push_back(std::move(pass)); 252 pass_list.push_back(std::move(pass));
301 253
302 // Make a copy with CopyAll(). 254 // Make a copy with CopyAll().
303 RenderPassList copy_list; 255 RenderPassList copy_list;
304 RenderPass::CopyAll(pass_list, &copy_list); 256 RenderPass::CopyAll(pass_list, &copy_list);
305 257
306 CompareRenderPassLists(pass_list, copy_list); 258 CompareRenderPassLists(pass_list, copy_list);
307 } 259 }
308 260
309 } // namespace 261 } // namespace
310 } // namespace cc 262 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/draw_quad_unittest.cc ('k') | cc/quads/shared_quad_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698