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

Side by Side Diff: cc/playback/raster_source_unittest.cc

Issue 2678903003: cc: Clean up naming of paint-related identifiers (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/playback/raster_source.h" 5 #include "cc/playback/raster_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "cc/test/fake_recording_source.h" 11 #include "cc/test/fake_recording_source.h"
12 #include "cc/test/skia_common.h" 12 #include "cc/test/skia_common.h"
13 #include "cc/tiles/software_image_decode_cache.h" 13 #include "cc/tiles/software_image_decode_cache.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/core/SkPixelRef.h" 15 #include "third_party/skia/include/core/SkPixelRef.h"
16 #include "third_party/skia/include/core/SkRefCnt.h" 16 #include "third_party/skia/include/core/SkRefCnt.h"
17 #include "third_party/skia/include/core/SkShader.h" 17 #include "third_party/skia/include/core/SkShader.h"
18 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/size_conversions.h" 19 #include "ui/gfx/geometry/size_conversions.h"
20 20
21 namespace cc { 21 namespace cc {
22 namespace { 22 namespace {
23 23
24 TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) { 24 TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) {
25 gfx::Size layer_bounds(400, 400); 25 gfx::Size layer_bounds(400, 400);
26 26
27 std::unique_ptr<FakeRecordingSource> recording_source = 27 std::unique_ptr<FakeRecordingSource> recording_source =
28 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 28 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
29 29
30 SkPaint solid_paint; 30 PaintFlags solid_flags;
31 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); 31 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
32 solid_paint.setColor(solid_color); 32 solid_flags.setColor(solid_color);
33 33
34 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); 34 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
35 SkColor color = SK_ColorTRANSPARENT; 35 SkColor color = SK_ColorTRANSPARENT;
36 SkPaint non_solid_paint; 36 PaintFlags non_solid_flags;
37 bool is_solid_color = false; 37 bool is_solid_color = false;
38 non_solid_paint.setColor(non_solid_color); 38 non_solid_flags.setColor(non_solid_color);
39 39
40 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), 40 recording_source->add_draw_rect_with_flags(gfx::Rect(layer_bounds),
41 solid_paint); 41 solid_flags);
42 recording_source->Rerecord(); 42 recording_source->Rerecord();
43 43
44 scoped_refptr<RasterSource> raster = 44 scoped_refptr<RasterSource> raster =
45 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 45 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
46 46
47 // Ensure everything is solid. 47 // Ensure everything is solid.
48 for (int y = 0; y <= 300; y += 100) { 48 for (int y = 0; y <= 300; y += 100) {
49 for (int x = 0; x <= 300; x += 100) { 49 for (int x = 0; x <= 300; x += 100) {
50 gfx::Rect rect(x, y, 100, 100); 50 gfx::Rect rect(x, y, 100, 100);
51 is_solid_color = raster->PerformSolidColorAnalysis(rect, 1.f, &color); 51 is_solid_color = raster->PerformSolidColorAnalysis(rect, 1.f, &color);
52 EXPECT_TRUE(is_solid_color) << rect.ToString(); 52 EXPECT_TRUE(is_solid_color) << rect.ToString();
53 EXPECT_EQ(solid_color, color) << rect.ToString(); 53 EXPECT_EQ(solid_color, color) << rect.ToString();
54 } 54 }
55 } 55 }
56 56
57 // Add one non-solid pixel and recreate the raster source. 57 // Add one non-solid pixel and recreate the raster source.
58 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), 58 recording_source->add_draw_rect_with_flags(gfx::Rect(50, 50, 1, 1),
59 non_solid_paint); 59 non_solid_flags);
60 recording_source->Rerecord(); 60 recording_source->Rerecord();
61 raster = 61 raster =
62 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 62 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
63 63
64 color = SK_ColorTRANSPARENT; 64 color = SK_ColorTRANSPARENT;
65 is_solid_color = 65 is_solid_color =
66 raster->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.f, &color); 66 raster->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.f, &color);
67 EXPECT_FALSE(is_solid_color); 67 EXPECT_FALSE(is_solid_color);
68 68
69 color = SK_ColorTRANSPARENT; 69 color = SK_ColorTRANSPARENT;
(...skipping 23 matching lines...) Expand all
93 } 93 }
94 94
95 TEST(RasterSourceTest, AnalyzeIsSolidScaled) { 95 TEST(RasterSourceTest, AnalyzeIsSolidScaled) {
96 gfx::Size layer_bounds(400, 400); 96 gfx::Size layer_bounds(400, 400);
97 97
98 std::unique_ptr<FakeRecordingSource> recording_source = 98 std::unique_ptr<FakeRecordingSource> recording_source =
99 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 99 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
100 100
101 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); 101 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
102 SkColor color = SK_ColorTRANSPARENT; 102 SkColor color = SK_ColorTRANSPARENT;
103 SkPaint solid_paint; 103 PaintFlags solid_flags;
104 bool is_solid_color = false; 104 bool is_solid_color = false;
105 solid_paint.setColor(solid_color); 105 solid_flags.setColor(solid_color);
106 106
107 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); 107 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
108 SkPaint non_solid_paint; 108 PaintFlags non_solid_flags;
109 non_solid_paint.setColor(non_solid_color); 109 non_solid_flags.setColor(non_solid_color);
110 110
111 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), 111 recording_source->add_draw_rect_with_flags(gfx::Rect(0, 0, 400, 400),
112 solid_paint); 112 solid_flags);
113 recording_source->Rerecord(); 113 recording_source->Rerecord();
114 114
115 scoped_refptr<RasterSource> raster = 115 scoped_refptr<RasterSource> raster =
116 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 116 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
117 117
118 // Ensure everything is solid. 118 // Ensure everything is solid.
119 for (int y = 0; y <= 30; y += 10) { 119 for (int y = 0; y <= 30; y += 10) {
120 for (int x = 0; x <= 30; x += 10) { 120 for (int x = 0; x <= 30; x += 10) {
121 gfx::Rect rect(x, y, 10, 10); 121 gfx::Rect rect(x, y, 10, 10);
122 is_solid_color = raster->PerformSolidColorAnalysis(rect, 0.1f, &color); 122 is_solid_color = raster->PerformSolidColorAnalysis(rect, 0.1f, &color);
123 EXPECT_TRUE(is_solid_color) << rect.ToString(); 123 EXPECT_TRUE(is_solid_color) << rect.ToString();
124 EXPECT_EQ(color, solid_color) << rect.ToString(); 124 EXPECT_EQ(color, solid_color) << rect.ToString();
125 } 125 }
126 } 126 }
127 127
128 // Add one non-solid pixel and recreate the raster source. 128 // Add one non-solid pixel and recreate the raster source.
129 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), 129 recording_source->add_draw_rect_with_flags(gfx::Rect(50, 50, 1, 1),
130 non_solid_paint); 130 non_solid_flags);
131 recording_source->Rerecord(); 131 recording_source->Rerecord();
132 raster = 132 raster =
133 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 133 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
134 134
135 color = SK_ColorTRANSPARENT; 135 color = SK_ColorTRANSPARENT;
136 is_solid_color = 136 is_solid_color =
137 raster->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &color); 137 raster->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &color);
138 EXPECT_FALSE(is_solid_color); 138 EXPECT_FALSE(is_solid_color);
139 139
140 color = SK_ColorTRANSPARENT; 140 color = SK_ColorTRANSPARENT;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 float contents_scale = 1.5f; 246 float contents_scale = 1.5f;
247 float raster_divisions = 2.f; 247 float raster_divisions = 2.f;
248 248
249 std::unique_ptr<FakeRecordingSource> recording_source = 249 std::unique_ptr<FakeRecordingSource> recording_source =
250 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 250 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
251 recording_source->SetBackgroundColor(SK_ColorBLACK); 251 recording_source->SetBackgroundColor(SK_ColorBLACK);
252 recording_source->SetClearCanvasWithDebugColor(false); 252 recording_source->SetClearCanvasWithDebugColor(false);
253 253
254 // Because the caller sets content opaque, it also promises that it 254 // Because the caller sets content opaque, it also promises that it
255 // has at least filled in layer_bounds opaquely. 255 // has at least filled in layer_bounds opaquely.
256 SkPaint white_paint; 256 PaintFlags white_flags;
257 white_paint.setColor(SK_ColorWHITE); 257 white_flags.setColor(SK_ColorWHITE);
258 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), 258 recording_source->add_draw_rect_with_flags(gfx::Rect(layer_bounds),
259 white_paint); 259 white_flags);
260 recording_source->Rerecord(); 260 recording_source->Rerecord();
261 261
262 scoped_refptr<RasterSource> raster = 262 scoped_refptr<RasterSource> raster =
263 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 263 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
264 264
265 gfx::Size content_bounds( 265 gfx::Size content_bounds(
266 gfx::ScaleToCeiledSize(layer_bounds, contents_scale)); 266 gfx::ScaleToCeiledSize(layer_bounds, contents_scale));
267 267
268 // Simulate drawing into different tiles at different offsets. 268 // Simulate drawing into different tiles at different offsets.
269 int step_x = std::ceil(content_bounds.width() / raster_divisions); 269 int step_x = std::ceil(content_bounds.width() / raster_divisions);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 TEST(RasterSourceTest, RasterPartialContents) { 311 TEST(RasterSourceTest, RasterPartialContents) {
312 gfx::Size layer_bounds(3, 5); 312 gfx::Size layer_bounds(3, 5);
313 float contents_scale = 1.5f; 313 float contents_scale = 1.5f;
314 314
315 std::unique_ptr<FakeRecordingSource> recording_source = 315 std::unique_ptr<FakeRecordingSource> recording_source =
316 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 316 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
317 recording_source->SetBackgroundColor(SK_ColorGREEN); 317 recording_source->SetBackgroundColor(SK_ColorGREEN);
318 recording_source->SetClearCanvasWithDebugColor(false); 318 recording_source->SetClearCanvasWithDebugColor(false);
319 319
320 // First record everything as white. 320 // First record everything as white.
321 SkPaint white_paint; 321 PaintFlags white_flags;
322 white_paint.setColor(SK_ColorWHITE); 322 white_flags.setColor(SK_ColorWHITE);
323 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), 323 recording_source->add_draw_rect_with_flags(gfx::Rect(layer_bounds),
324 white_paint); 324 white_flags);
325 recording_source->Rerecord(); 325 recording_source->Rerecord();
326 326
327 scoped_refptr<RasterSource> raster = 327 scoped_refptr<RasterSource> raster =
328 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 328 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
329 329
330 gfx::Size content_bounds( 330 gfx::Size content_bounds(
331 gfx::ScaleToCeiledSize(layer_bounds, contents_scale)); 331 gfx::ScaleToCeiledSize(layer_bounds, contents_scale));
332 332
333 SkBitmap bitmap; 333 SkBitmap bitmap;
334 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); 334 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
(...skipping 14 matching lines...) Expand all
349 SCOPED_TRACE(j); 349 SCOPED_TRACE(j);
350 EXPECT_EQ(255u, SkColorGetA(pixels[i + j * bitmap.width()])); 350 EXPECT_EQ(255u, SkColorGetA(pixels[i + j * bitmap.width()]));
351 EXPECT_EQ(255u, SkColorGetR(pixels[i + j * bitmap.width()])); 351 EXPECT_EQ(255u, SkColorGetR(pixels[i + j * bitmap.width()]));
352 EXPECT_EQ(255u, SkColorGetG(pixels[i + j * bitmap.width()])); 352 EXPECT_EQ(255u, SkColorGetG(pixels[i + j * bitmap.width()]));
353 EXPECT_EQ(255u, SkColorGetB(pixels[i + j * bitmap.width()])); 353 EXPECT_EQ(255u, SkColorGetB(pixels[i + j * bitmap.width()]));
354 } 354 }
355 } 355 }
356 } 356 }
357 357
358 // Re-record everything as black. 358 // Re-record everything as black.
359 SkPaint black_paint; 359 PaintFlags black_flags;
360 black_paint.setColor(SK_ColorBLACK); 360 black_flags.setColor(SK_ColorBLACK);
361 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), 361 recording_source->add_draw_rect_with_flags(gfx::Rect(layer_bounds),
362 black_paint); 362 black_flags);
363 recording_source->Rerecord(); 363 recording_source->Rerecord();
364 364
365 // Make a new RasterSource from the new recording. 365 // Make a new RasterSource from the new recording.
366 raster = 366 raster =
367 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 367 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
368 368
369 // We're going to playback from "everything is black" into a smaller area, 369 // We're going to playback from "everything is black" into a smaller area,
370 // that touches the edge pixels of the recording. 370 // that touches the edge pixels of the recording.
371 playback_rect.Inset(1, 2, 0, 1); 371 playback_rect.Inset(1, 2, 0, 1);
372 raster->PlaybackToCanvas(&canvas, raster_full_rect, playback_rect, 372 raster->PlaybackToCanvas(&canvas, raster_full_rect, playback_rect,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 float contents_scale = 1.5f; 405 float contents_scale = 1.5f;
406 406
407 std::unique_ptr<FakeRecordingSource> recording_source = 407 std::unique_ptr<FakeRecordingSource> recording_source =
408 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 408 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
409 recording_source->SetBackgroundColor(SK_ColorGREEN); 409 recording_source->SetBackgroundColor(SK_ColorGREEN);
410 recording_source->SetRequiresClear(true); 410 recording_source->SetRequiresClear(true);
411 recording_source->SetClearCanvasWithDebugColor(false); 411 recording_source->SetClearCanvasWithDebugColor(false);
412 412
413 // First record everything as white. 413 // First record everything as white.
414 const unsigned alpha_dark = 10u; 414 const unsigned alpha_dark = 10u;
415 SkPaint white_paint; 415 PaintFlags white_flags;
416 white_paint.setColor(SK_ColorWHITE); 416 white_flags.setColor(SK_ColorWHITE);
417 white_paint.setAlpha(alpha_dark); 417 white_flags.setAlpha(alpha_dark);
418 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), 418 recording_source->add_draw_rect_with_flags(gfx::Rect(layer_bounds),
419 white_paint); 419 white_flags);
420 recording_source->Rerecord(); 420 recording_source->Rerecord();
421 421
422 scoped_refptr<RasterSource> raster = 422 scoped_refptr<RasterSource> raster =
423 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 423 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
424 424
425 gfx::Size content_bounds( 425 gfx::Size content_bounds(
426 gfx::ScaleToCeiledSize(layer_bounds, contents_scale)); 426 gfx::ScaleToCeiledSize(layer_bounds, contents_scale));
427 427
428 SkBitmap bitmap; 428 SkBitmap bitmap;
429 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); 429 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
(...skipping 21 matching lines...) Expand all
451 } 451 }
452 452
453 std::unique_ptr<FakeRecordingSource> recording_source_light = 453 std::unique_ptr<FakeRecordingSource> recording_source_light =
454 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 454 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
455 recording_source_light->SetBackgroundColor(SK_ColorGREEN); 455 recording_source_light->SetBackgroundColor(SK_ColorGREEN);
456 recording_source_light->SetRequiresClear(true); 456 recording_source_light->SetRequiresClear(true);
457 recording_source_light->SetClearCanvasWithDebugColor(false); 457 recording_source_light->SetClearCanvasWithDebugColor(false);
458 458
459 // Record everything as a slightly lighter white. 459 // Record everything as a slightly lighter white.
460 const unsigned alpha_light = 18u; 460 const unsigned alpha_light = 18u;
461 white_paint.setAlpha(alpha_light); 461 white_flags.setAlpha(alpha_light);
462 recording_source_light->add_draw_rect_with_paint(gfx::Rect(layer_bounds), 462 recording_source_light->add_draw_rect_with_flags(gfx::Rect(layer_bounds),
463 white_paint); 463 white_flags);
464 recording_source_light->Rerecord(); 464 recording_source_light->Rerecord();
465 465
466 // Make a new RasterSource from the new recording. 466 // Make a new RasterSource from the new recording.
467 raster = RasterSource::CreateFromRecordingSource(recording_source_light.get(), 467 raster = RasterSource::CreateFromRecordingSource(recording_source_light.get(),
468 false); 468 false);
469 469
470 // We're going to playback from alpha(18) white rectangle into a smaller area 470 // We're going to playback from alpha(18) white rectangle into a smaller area
471 // of the recording resulting in a smaller lighter white rectangle over a 471 // of the recording resulting in a smaller lighter white rectangle over a
472 // darker white background rectangle. 472 // darker white background rectangle.
473 playback_rect = 473 playback_rect =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 TEST(RasterSourceTest, GetPictureMemoryUsageIncludesClientReportedMemory) { 525 TEST(RasterSourceTest, GetPictureMemoryUsageIncludesClientReportedMemory) {
526 const size_t kReportedMemoryUsageInBytes = 100 * 1024 * 1024; 526 const size_t kReportedMemoryUsageInBytes = 100 * 1024 * 1024;
527 gfx::Size layer_bounds(5, 3); 527 gfx::Size layer_bounds(5, 3);
528 std::unique_ptr<FakeRecordingSource> recording_source = 528 std::unique_ptr<FakeRecordingSource> recording_source =
529 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 529 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
530 recording_source->set_reported_memory_usage(kReportedMemoryUsageInBytes); 530 recording_source->set_reported_memory_usage(kReportedMemoryUsageInBytes);
531 recording_source->Rerecord(); 531 recording_source->Rerecord();
532 532
533 scoped_refptr<RasterSource> raster = 533 scoped_refptr<RasterSource> raster =
534 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 534 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
535 size_t total_memory_usage = raster->GetPictureMemoryUsage(); 535 size_t total_memory_usage = raster->GetMemoryUsage();
536 EXPECT_GE(total_memory_usage, kReportedMemoryUsageInBytes); 536 EXPECT_GE(total_memory_usage, kReportedMemoryUsageInBytes);
537 EXPECT_LT(total_memory_usage, 2 * kReportedMemoryUsageInBytes); 537 EXPECT_LT(total_memory_usage, 2 * kReportedMemoryUsageInBytes);
538 } 538 }
539 539
540 TEST(RasterSourceTest, ImageHijackCanvasRespectsSharedCanvasTransform) { 540 TEST(RasterSourceTest, ImageHijackCanvasRespectsSharedCanvasTransform) {
541 gfx::Size size(100, 100); 541 gfx::Size size(100, 100);
542 542
543 // Create a recording source that is filled with red and every corner is 543 // Create a recording source that is filled with red and every corner is
544 // green (4x4 rects in the corner are green to account for blending when 544 // green (4x4 rects in the corner are green to account for blending when
545 // scaling). Note that we paint an image first, so that we can force image 545 // scaling). Note that we paint an image first, so that we can force image
546 // hijack canvas to be used. 546 // hijack canvas to be used.
547 std::unique_ptr<FakeRecordingSource> recording_source = 547 std::unique_ptr<FakeRecordingSource> recording_source =
548 FakeRecordingSource::CreateFilledRecordingSource(size); 548 FakeRecordingSource::CreateFilledRecordingSource(size);
549 549
550 // 1. Paint the image. 550 // 1. Paint the image.
551 recording_source->add_draw_image(CreateDiscardableImage(gfx::Size(5, 5)), 551 recording_source->add_draw_image(CreateDiscardableImage(gfx::Size(5, 5)),
552 gfx::Point(0, 0)); 552 gfx::Point(0, 0));
553 553
554 // 2. Cover everything in red. 554 // 2. Cover everything in red.
555 SkPaint paint; 555 PaintFlags flags;
556 paint.setColor(SK_ColorRED); 556 flags.setColor(SK_ColorRED);
557 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); 557 recording_source->add_draw_rect_with_flags(gfx::Rect(size), flags);
558 558
559 // 3. Draw 4x4 green rects into every corner. 559 // 3. Draw 4x4 green rects into every corner.
560 paint.setColor(SK_ColorGREEN); 560 flags.setColor(SK_ColorGREEN);
561 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 4, 4), paint); 561 recording_source->add_draw_rect_with_flags(gfx::Rect(0, 0, 4, 4), flags);
562 recording_source->add_draw_rect_with_paint( 562 recording_source->add_draw_rect_with_flags(
563 gfx::Rect(size.width() - 4, 0, 4, 4), paint); 563 gfx::Rect(size.width() - 4, 0, 4, 4), flags);
564 recording_source->add_draw_rect_with_paint( 564 recording_source->add_draw_rect_with_flags(
565 gfx::Rect(0, size.height() - 4, 4, 4), paint); 565 gfx::Rect(0, size.height() - 4, 4, 4), flags);
566 recording_source->add_draw_rect_with_paint( 566 recording_source->add_draw_rect_with_flags(
567 gfx::Rect(size.width() - 4, size.height() - 4, 4, 4), paint); 567 gfx::Rect(size.width() - 4, size.height() - 4, 4, 4), flags);
568 568
569 recording_source->SetGenerateDiscardableImagesMetadata(true); 569 recording_source->SetGenerateDiscardableImagesMetadata(true);
570 recording_source->Rerecord(); 570 recording_source->Rerecord();
571 571
572 bool can_use_lcd = true; 572 bool can_use_lcd = true;
573 scoped_refptr<RasterSource> raster_source = 573 scoped_refptr<RasterSource> raster_source =
574 recording_source->CreateRasterSource(can_use_lcd); 574 recording_source->CreateRasterSource(can_use_lcd);
575 SoftwareImageDecodeCache controller( 575 SoftwareImageDecodeCache controller(
576 ResourceFormat::RGBA_8888, 576 ResourceFormat::RGBA_8888,
577 LayerTreeSettings().software_decoded_image_budget_bytes); 577 LayerTreeSettings().software_decoded_image_budget_bytes);
(...skipping 15 matching lines...) Expand all
593 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); 593 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24));
594 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); 594 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24));
595 for (int x = 0; x < 49; ++x) 595 for (int x = 0; x < 49; ++x)
596 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); 596 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12));
597 for (int y = 0; y < 24; ++y) 597 for (int y = 0; y < 24; ++y)
598 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); 598 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y));
599 } 599 }
600 600
601 } // namespace 601 } // namespace
602 } // namespace cc 602 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698