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

Side by Side Diff: cc/output/software_renderer_unittest.cc

Issue 2543473004: cc: Move filters from RenderPassDrawQuad to RenderPass (Closed)
Patch Set: Address review comments Created 4 years 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
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/output/software_renderer.h" 5 #include "cc/output/software_renderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 gfx::Size outer_size(100, 100); 94 gfx::Size outer_size(100, 100);
95 gfx::Size inner_size(98, 98); 95 gfx::Size inner_size(98, 98);
96 gfx::Rect outer_rect(outer_size); 96 gfx::Rect outer_rect(outer_size);
97 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); 97 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size);
98 gfx::Rect visible_rect(gfx::Point(1, 2), gfx::Size(98, 97)); 98 gfx::Rect visible_rect(gfx::Point(1, 2), gfx::Size(98, 97));
99 99
100 InitializeRenderer(base::WrapUnique(new SoftwareOutputDevice)); 100 InitializeRenderer(base::WrapUnique(new SoftwareOutputDevice));
101 101
102 RenderPassId root_render_pass_id = RenderPassId(1, 1); 102 RenderPassId root_render_pass_id = RenderPassId(1, 1);
103 std::unique_ptr<RenderPass> root_render_pass = RenderPass::Create(); 103 std::unique_ptr<RenderPass> root_render_pass = RenderPass::Create();
104 root_render_pass->SetNew( 104 root_render_pass->SetNew(root_render_pass_id, outer_rect, outer_rect,
105 root_render_pass_id, outer_rect, outer_rect, gfx::Transform()); 105 gfx::Transform());
106 SharedQuadState* shared_quad_state = 106 SharedQuadState* shared_quad_state =
107 root_render_pass->CreateAndAppendSharedQuadState(); 107 root_render_pass->CreateAndAppendSharedQuadState();
108 shared_quad_state->SetAll(gfx::Transform(), outer_size, outer_rect, 108 shared_quad_state->SetAll(gfx::Transform(), outer_size, outer_rect,
109 outer_rect, false, 1.0, SkBlendMode::kSrcOver, 0); 109 outer_rect, false, 1.0, SkBlendMode::kSrcOver, 0);
110 SolidColorDrawQuad* inner_quad = 110 SolidColorDrawQuad* inner_quad =
111 root_render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 111 root_render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
112 inner_quad->SetNew( 112 inner_quad->SetNew(
113 shared_quad_state, inner_rect, inner_rect, SK_ColorCYAN, false); 113 shared_quad_state, inner_rect, inner_rect, SK_ColorCYAN, false);
114 inner_quad->visible_rect = visible_rect; 114 inner_quad->visible_rect = visible_rect;
115 SolidColorDrawQuad* outer_quad = 115 SolidColorDrawQuad* outer_quad =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 resource_provider()->CopyToResource( 160 resource_provider()->CopyToResource(
161 resource_yellow, static_cast<uint8_t*>(yellow_tile.getPixels()), 161 resource_yellow, static_cast<uint8_t*>(yellow_tile.getPixels()),
162 outer_size); 162 outer_size);
163 resource_provider()->CopyToResource( 163 resource_provider()->CopyToResource(
164 resource_cyan, static_cast<uint8_t*>(cyan_tile.getPixels()), inner_size); 164 resource_cyan, static_cast<uint8_t*>(cyan_tile.getPixels()), inner_size);
165 165
166 gfx::Rect root_rect = outer_rect; 166 gfx::Rect root_rect = outer_rect;
167 167
168 RenderPassId root_render_pass_id = RenderPassId(1, 1); 168 RenderPassId root_render_pass_id = RenderPassId(1, 1);
169 std::unique_ptr<RenderPass> root_render_pass = RenderPass::Create(); 169 std::unique_ptr<RenderPass> root_render_pass = RenderPass::Create();
170 root_render_pass->SetNew( 170 root_render_pass->SetNew(root_render_pass_id, root_rect, root_rect,
171 root_render_pass_id, root_rect, root_rect, gfx::Transform()); 171 gfx::Transform());
172 SharedQuadState* shared_quad_state = 172 SharedQuadState* shared_quad_state =
173 root_render_pass->CreateAndAppendSharedQuadState(); 173 root_render_pass->CreateAndAppendSharedQuadState();
174 shared_quad_state->SetAll(gfx::Transform(), outer_size, outer_rect, 174 shared_quad_state->SetAll(gfx::Transform(), outer_size, outer_rect,
175 outer_rect, false, 1.0, SkBlendMode::kSrcOver, 0); 175 outer_rect, false, 1.0, SkBlendMode::kSrcOver, 0);
176 TileDrawQuad* inner_quad = 176 TileDrawQuad* inner_quad =
177 root_render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 177 root_render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
178 inner_quad->SetNew(shared_quad_state, inner_rect, inner_rect, inner_rect, 178 inner_quad->SetNew(shared_quad_state, inner_rect, inner_rect, inner_rect,
179 resource_cyan, gfx::RectF(gfx::SizeF(inner_size)), 179 resource_cyan, gfx::RectF(gfx::SizeF(inner_size)),
180 inner_size, false, false); 180 inner_size, false, false);
181 TileDrawQuad* outer_quad = 181 TileDrawQuad* outer_quad =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()), 220 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()),
221 SK_ColorYELLOW); 221 SK_ColorYELLOW);
222 222
223 resource_provider()->CopyToResource( 223 resource_provider()->CopyToResource(
224 resource_cyan, static_cast<uint8_t*>(cyan_tile.getPixels()), tile_size); 224 resource_cyan, static_cast<uint8_t*>(cyan_tile.getPixels()), tile_size);
225 225
226 gfx::Rect root_rect(tile_size); 226 gfx::Rect root_rect(tile_size);
227 227
228 RenderPassId root_render_pass_id = RenderPassId(1, 1); 228 RenderPassId root_render_pass_id = RenderPassId(1, 1);
229 std::unique_ptr<RenderPass> root_render_pass = RenderPass::Create(); 229 std::unique_ptr<RenderPass> root_render_pass = RenderPass::Create();
230 root_render_pass->SetNew( 230 root_render_pass->SetNew(root_render_pass_id, root_rect, root_rect,
231 root_render_pass_id, root_rect, root_rect, gfx::Transform()); 231 gfx::Transform());
232 SharedQuadState* shared_quad_state = 232 SharedQuadState* shared_quad_state =
233 root_render_pass->CreateAndAppendSharedQuadState(); 233 root_render_pass->CreateAndAppendSharedQuadState();
234 shared_quad_state->SetAll(gfx::Transform(), tile_size, tile_rect, tile_rect, 234 shared_quad_state->SetAll(gfx::Transform(), tile_size, tile_rect, tile_rect,
235 false, 1.0, SkBlendMode::kSrcOver, 0); 235 false, 1.0, SkBlendMode::kSrcOver, 0);
236 TileDrawQuad* quad = 236 TileDrawQuad* quad =
237 root_render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 237 root_render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
238 quad->SetNew(shared_quad_state, tile_rect, tile_rect, tile_rect, 238 quad->SetNew(shared_quad_state, tile_rect, tile_rect, tile_rect,
239 resource_cyan, gfx::RectF(gfx::SizeF(tile_size)), tile_size, 239 resource_cyan, gfx::RectF(gfx::SizeF(tile_size)), tile_size,
240 false, false); 240 false, false);
241 quad->visible_rect = visible_rect; 241 quad->visible_rect = visible_rect;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 float device_scale_factor = 1.f; 273 float device_scale_factor = 1.f;
274 gfx::Size viewport_size(100, 100); 274 gfx::Size viewport_size(100, 100);
275 275
276 settings_.should_clear_root_render_pass = false; 276 settings_.should_clear_root_render_pass = false;
277 InitializeRenderer(base::WrapUnique(new SoftwareOutputDevice)); 277 InitializeRenderer(base::WrapUnique(new SoftwareOutputDevice));
278 278
279 RenderPassList list; 279 RenderPassList list;
280 280
281 // Draw a fullscreen green quad in a first frame. 281 // Draw a fullscreen green quad in a first frame.
282 RenderPassId root_clear_pass_id(1, 0); 282 RenderPassId root_clear_pass_id(1, 0);
283 RenderPass* root_clear_pass = AddRenderPass( 283 RenderPass* root_clear_pass =
284 &list, root_clear_pass_id, gfx::Rect(viewport_size), gfx::Transform()); 284 AddRenderPass(&list, root_clear_pass_id, gfx::Rect(viewport_size),
285 gfx::Transform(), FilterOperations());
285 AddQuad(root_clear_pass, gfx::Rect(viewport_size), SK_ColorGREEN); 286 AddQuad(root_clear_pass, gfx::Rect(viewport_size), SK_ColorGREEN);
286 287
287 renderer()->DecideRenderPassAllocationsForFrame(list); 288 renderer()->DecideRenderPassAllocationsForFrame(list);
288 289
289 std::unique_ptr<SkBitmap> output = 290 std::unique_ptr<SkBitmap> output =
290 DrawAndCopyOutput(&list, device_scale_factor, viewport_size); 291 DrawAndCopyOutput(&list, device_scale_factor, viewport_size);
291 EXPECT_EQ(viewport_size.width(), output->info().width()); 292 EXPECT_EQ(viewport_size.width(), output->info().width());
292 EXPECT_EQ(viewport_size.height(), output->info().height()); 293 EXPECT_EQ(viewport_size.height(), output->info().height());
293 294
294 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); 295 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0));
295 EXPECT_EQ(SK_ColorGREEN, output->getColor(viewport_size.width() - 1, 296 EXPECT_EQ(SK_ColorGREEN, output->getColor(viewport_size.width() - 1,
296 viewport_size.height() - 1)); 297 viewport_size.height() - 1));
297 298
298 list.clear(); 299 list.clear();
299 300
300 // Draw a smaller magenta rect without filling the viewport in a separate 301 // Draw a smaller magenta rect without filling the viewport in a separate
301 // frame. 302 // frame.
302 gfx::Rect smaller_rect(20, 20, 60, 60); 303 gfx::Rect smaller_rect(20, 20, 60, 60);
303 304
304 RenderPassId root_smaller_pass_id(2, 0); 305 RenderPassId root_smaller_pass_id(2, 0);
305 RenderPass* root_smaller_pass = AddRenderPass( 306 RenderPass* root_smaller_pass =
306 &list, root_smaller_pass_id, gfx::Rect(viewport_size), gfx::Transform()); 307 AddRenderPass(&list, root_smaller_pass_id, gfx::Rect(viewport_size),
308 gfx::Transform(), FilterOperations());
307 AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA); 309 AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA);
308 310
309 renderer()->DecideRenderPassAllocationsForFrame(list); 311 renderer()->DecideRenderPassAllocationsForFrame(list);
310 312
311 output = DrawAndCopyOutput(&list, device_scale_factor, viewport_size); 313 output = DrawAndCopyOutput(&list, device_scale_factor, viewport_size);
312 EXPECT_EQ(viewport_size.width(), output->info().width()); 314 EXPECT_EQ(viewport_size.width(), output->info().width());
313 EXPECT_EQ(viewport_size.height(), output->info().height()); 315 EXPECT_EQ(viewport_size.height(), output->info().height());
314 316
315 // If we didn't clear, the borders should still be green. 317 // If we didn't clear, the borders should still be green.
316 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); 318 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0));
(...skipping 11 matching lines...) Expand all
328 float device_scale_factor = 1.f; 330 float device_scale_factor = 1.f;
329 gfx::Size viewport_size(100, 100); 331 gfx::Size viewport_size(100, 100);
330 InitializeRenderer(base::WrapUnique(new SoftwareOutputDevice)); 332 InitializeRenderer(base::WrapUnique(new SoftwareOutputDevice));
331 333
332 RenderPassList list; 334 RenderPassList list;
333 335
334 // Pass drawn as inner quad is magenta. 336 // Pass drawn as inner quad is magenta.
335 gfx::Rect smaller_rect(20, 20, 60, 60); 337 gfx::Rect smaller_rect(20, 20, 60, 60);
336 RenderPassId smaller_pass_id(2, 1); 338 RenderPassId smaller_pass_id(2, 1);
337 RenderPass* smaller_pass = 339 RenderPass* smaller_pass =
338 AddRenderPass(&list, smaller_pass_id, smaller_rect, gfx::Transform()); 340 AddRenderPass(&list, smaller_pass_id, smaller_rect, gfx::Transform(),
341 FilterOperations());
339 AddQuad(smaller_pass, smaller_rect, SK_ColorMAGENTA); 342 AddQuad(smaller_pass, smaller_rect, SK_ColorMAGENTA);
340 343
341 // Root pass is green. 344 // Root pass is green.
342 RenderPassId root_clear_pass_id(1, 0); 345 RenderPassId root_clear_pass_id(1, 0);
343 RenderPass* root_clear_pass = AddRenderPass( 346 RenderPass* root_clear_pass =
344 &list, root_clear_pass_id, gfx::Rect(viewport_size), gfx::Transform()); 347 AddRenderPass(&list, root_clear_pass_id, gfx::Rect(viewport_size),
348 gfx::Transform(), FilterOperations());
345 AddRenderPassQuad(root_clear_pass, smaller_pass); 349 AddRenderPassQuad(root_clear_pass, smaller_pass);
346 AddQuad(root_clear_pass, gfx::Rect(viewport_size), SK_ColorGREEN); 350 AddQuad(root_clear_pass, gfx::Rect(viewport_size), SK_ColorGREEN);
347 351
348 // Interior pass quad has smaller visible rect. 352 // Interior pass quad has smaller visible rect.
349 gfx::Rect interior_visible_rect(30, 30, 40, 40); 353 gfx::Rect interior_visible_rect(30, 30, 40, 40);
350 root_clear_pass->quad_list.front()->visible_rect = interior_visible_rect; 354 root_clear_pass->quad_list.front()->visible_rect = interior_visible_rect;
351 355
352 renderer()->DecideRenderPassAllocationsForFrame(list); 356 renderer()->DecideRenderPassAllocationsForFrame(list);
353 357
354 std::unique_ptr<SkBitmap> output = 358 std::unique_ptr<SkBitmap> output =
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 409
406 settings_.partial_swap_enabled = true; 410 settings_.partial_swap_enabled = true;
407 411
408 auto device_owned = base::MakeUnique<PartialSwapSoftwareOutputDevice>(); 412 auto device_owned = base::MakeUnique<PartialSwapSoftwareOutputDevice>();
409 auto* device = device_owned.get(); 413 auto* device = device_owned.get();
410 InitializeRenderer(std::move(device_owned)); 414 InitializeRenderer(std::move(device_owned));
411 415
412 RenderPassList list; 416 RenderPassList list;
413 417
414 RenderPassId root_pass_id(1, 0); 418 RenderPassId root_pass_id(1, 0);
415 RenderPass* root_pass = AddRenderPass( 419 RenderPass* root_pass =
416 &list, root_pass_id, gfx::Rect(viewport_size), gfx::Transform()); 420 AddRenderPass(&list, root_pass_id, gfx::Rect(viewport_size),
421 gfx::Transform(), FilterOperations());
417 AddQuad(root_pass, gfx::Rect(viewport_size), SK_ColorGREEN); 422 AddQuad(root_pass, gfx::Rect(viewport_size), SK_ColorGREEN);
418 423
419 // Partial frame, we should pass this rect to the SoftwareOutputDevice. 424 // Partial frame, we should pass this rect to the SoftwareOutputDevice.
420 // partial swap is enabled. 425 // partial swap is enabled.
421 root_pass->damage_rect = gfx::Rect(2, 2, 3, 3); 426 root_pass->damage_rect = gfx::Rect(2, 2, 3, 3);
422 427
423 renderer()->DecideRenderPassAllocationsForFrame(list); 428 renderer()->DecideRenderPassAllocationsForFrame(list);
424 renderer()->DrawFrame(&list, device_scale_factor, gfx::ColorSpace(), 429 renderer()->DrawFrame(&list, device_scale_factor, gfx::ColorSpace(),
425 viewport_size); 430 viewport_size);
426 431
427 // The damage rect should be reported to the SoftwareOutputDevice. 432 // The damage rect should be reported to the SoftwareOutputDevice.
428 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start()); 433 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start());
429 // The SkCanvas should be clipped to the damage rect. 434 // The SkCanvas should be clipped to the damage rect.
430 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end()); 435 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end());
431 } 436 }
432 437
433 } // namespace 438 } // namespace
434 } // namespace cc 439 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698