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

Side by Side Diff: skia/ext/pixel_ref_utils_unittest.cc

Issue 1819683002: Use sk_sp-based picture recording APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skspify GetPicture/GetFlattenedPicture Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
10 #include "skia/ext/pixel_ref_utils.h" 10 #include "skia/ext/pixel_ref_utils.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 recorder->beginRecording(layer_rect.width(), layer_rect.height()); 51 recorder->beginRecording(layer_rect.width(), layer_rect.height());
52 52
53 canvas->save(); 53 canvas->save();
54 canvas->translate(-layer_rect.x(), -layer_rect.y()); 54 canvas->translate(-layer_rect.x(), -layer_rect.y());
55 canvas->clipRect(SkRect::MakeXYWH( 55 canvas->clipRect(SkRect::MakeXYWH(
56 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height())); 56 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height()));
57 57
58 return canvas; 58 return canvas;
59 } 59 }
60 60
61 SkPicture* StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) { 61 sk_sp<SkPicture> StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) {
62 canvas->restore(); 62 canvas->restore();
63 return recorder->endRecordingAsPicture(); 63 return recorder->finishRecordingAsPicture();
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 void VerifyScales(SkScalar x_scale, 68 void VerifyScales(SkScalar x_scale,
69 SkScalar y_scale, 69 SkScalar y_scale,
70 const SkMatrix& matrix, 70 const SkMatrix& matrix,
71 int source_line) { 71 int source_line) {
72 SkSize scales; 72 SkSize scales;
73 bool success = matrix.decomposeScale(&scales); 73 bool success = matrix.decomposeScale(&scales);
(...skipping 23 matching lines...) Expand all
97 97
98 canvas->save(); 98 canvas->save();
99 canvas->scale(2.f, 3.f); 99 canvas->scale(2.f, 3.f);
100 canvas->drawPaint(second_paint); 100 canvas->drawPaint(second_paint);
101 canvas->restore(); 101 canvas->restore();
102 102
103 // Total clip is now (34, 45, 56, 55) 103 // Total clip is now (34, 45, 56, 55)
104 canvas->clipRect(SkRect::MakeWH(100, 100)); 104 canvas->clipRect(SkRect::MakeWH(100, 100));
105 canvas->drawPaint(third_paint); 105 canvas->drawPaint(third_paint);
106 106
107 skia::RefPtr<SkPicture> picture = 107 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
108 skia::AdoptRef(StopRecording(&recorder, canvas));
109 108
110 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 109 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
111 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 110 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
112 111
113 EXPECT_EQ(4u, pixel_refs.size()); 112 EXPECT_EQ(4u, pixel_refs.size());
114 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256), 113 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256),
115 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 114 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
116 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 115 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
117 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 116 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 67), 117 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 67),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, second_paint); 156 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, second_paint);
158 157
159 canvas->restore(); 158 canvas->restore();
160 159
161 points[0].set(50, 55); 160 points[0].set(50, 55);
162 points[1].set(50, 55); 161 points[1].set(50, 55);
163 points[2].set(200, 200); 162 points[2].set(200, 200);
164 // (50, 55, 150, 145). 163 // (50, 55, 150, 145).
165 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint); 164 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint);
166 165
167 skia::RefPtr<SkPicture> picture = 166 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
168 skia::AdoptRef(StopRecording(&recorder, canvas));
169 167
170 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 168 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
171 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 169 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
172 170
173 EXPECT_EQ(3u, pixel_refs.size()); 171 EXPECT_EQ(3u, pixel_refs.size());
174 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 172 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
175 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 173 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
176 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 174 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
177 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 175 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
178 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 176 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
(...skipping 30 matching lines...) Expand all
209 // (5, 50, 25, 35) 207 // (5, 50, 25, 35)
210 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint); 208 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint);
211 209
212 canvas->restore(); 210 canvas->restore();
213 211
214 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 212 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
215 canvas->translate(20, 20); 213 canvas->translate(20, 20);
216 // (20, 20, 100, 100) 214 // (20, 20, 100, 100)
217 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); 215 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
218 216
219 skia::RefPtr<SkPicture> picture = 217 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
220 skia::AdoptRef(StopRecording(&recorder, canvas));
221 218
222 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 219 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
223 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 220 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
224 221
225 EXPECT_EQ(3u, pixel_refs.size()); 222 EXPECT_EQ(3u, pixel_refs.size());
226 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), 223 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
227 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 224 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
228 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 225 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
229 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 226 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
230 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35), 227 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 canvas->drawRRect(rrect, second_paint); 263 canvas->drawRRect(rrect, second_paint);
267 264
268 canvas->restore(); 265 canvas->restore();
269 266
270 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 267 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
271 canvas->translate(20, 20); 268 canvas->translate(20, 20);
272 rrect.setRect(SkRect::MakeXYWH(0, 0, 100, 100)); 269 rrect.setRect(SkRect::MakeXYWH(0, 0, 100, 100));
273 // (20, 20, 100, 100) 270 // (20, 20, 100, 100)
274 canvas->drawRRect(rrect, third_paint); 271 canvas->drawRRect(rrect, third_paint);
275 272
276 skia::RefPtr<SkPicture> picture = 273 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
277 skia::AdoptRef(StopRecording(&recorder, canvas));
278 274
279 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 275 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
280 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 276 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
281 277
282 EXPECT_EQ(3u, pixel_refs.size()); 278 EXPECT_EQ(3u, pixel_refs.size());
283 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), 279 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
284 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 280 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
285 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 281 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
286 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 282 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
287 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35), 283 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // (1, 35, 25, 35) 318 // (1, 35, 25, 35)
323 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint); 319 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint);
324 320
325 canvas->restore(); 321 canvas->restore();
326 322
327 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 323 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
328 canvas->translate(20, 20); 324 canvas->translate(20, 20);
329 // (20, 20, 100, 100). 325 // (20, 20, 100, 100).
330 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); 326 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
331 327
332 skia::RefPtr<SkPicture> picture = 328 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
333 skia::AdoptRef(StopRecording(&recorder, canvas));
334 329
335 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 330 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
336 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 331 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
337 332
338 EXPECT_EQ(3u, pixel_refs.size()); 333 EXPECT_EQ(3u, pixel_refs.size());
339 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20), 334 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20),
340 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 335 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
341 VerifyScales(2.f, 0.5f, pixel_refs[0].matrix, __LINE__); 336 VerifyScales(2.f, 0.5f, pixel_refs[0].matrix, __LINE__);
342 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 337 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
343 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35), 338 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35),
(...skipping 28 matching lines...) Expand all
372 367
373 canvas->save(); 368 canvas->save();
374 canvas->clipRect(SkRect::MakeWH(50, 50)); 369 canvas->clipRect(SkRect::MakeWH(50, 50));
375 370
376 // (12, 13, 38, 88), since clips are ignored as long as the shape is in the 371 // (12, 13, 38, 88), since clips are ignored as long as the shape is in the
377 // clip. 372 // clip.
378 canvas->drawPath(path, second_paint); 373 canvas->drawPath(path, second_paint);
379 374
380 canvas->restore(); 375 canvas->restore();
381 376
382 skia::RefPtr<SkPicture> picture = 377 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
383 skia::AdoptRef(StopRecording(&recorder, canvas));
384 378
385 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 379 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
386 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 380 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
387 381
388 EXPECT_EQ(2u, pixel_refs.size()); 382 EXPECT_EQ(2u, pixel_refs.size());
389 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88), 383 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
390 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 384 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
391 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 385 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
392 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 386 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
393 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88), 387 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
(...skipping 21 matching lines...) Expand all
415 path.moveTo(10, 50); 409 path.moveTo(10, 50);
416 path.lineTo(20, 50); 410 path.lineTo(20, 50);
417 path.lineTo(30, 50); 411 path.lineTo(30, 50);
418 path.lineTo(40, 50); 412 path.lineTo(40, 50);
419 path.lineTo(50, 50); 413 path.lineTo(50, 50);
420 414
421 canvas->drawText("text", 4, 50, 50, first_paint); 415 canvas->drawText("text", 4, 50, 50, first_paint);
422 canvas->drawPosText("text", 4, points, first_paint); 416 canvas->drawPosText("text", 4, points, first_paint);
423 canvas->drawTextOnPath("text", 4, path, NULL, first_paint); 417 canvas->drawTextOnPath("text", 4, path, NULL, first_paint);
424 418
425 skia::RefPtr<SkPicture> picture = 419 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
426 skia::AdoptRef(StopRecording(&recorder, canvas));
427 420
428 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 421 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
429 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 422 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
430 423
431 EXPECT_EQ(3u, pixel_refs.size()); 424 EXPECT_EQ(3u, pixel_refs.size());
432 } 425 }
433 426
434 TEST(PixelRefUtilsTest, DrawVertices) { 427 TEST(PixelRefUtilsTest, DrawVertices) {
435 gfx::Rect layer_rect(0, 0, 256, 256); 428 gfx::Rect layer_rect(0, 0, 256, 256);
436 429
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, 480 canvas->drawVertices(SkCanvas::kTriangles_VertexMode,
488 3, 481 3,
489 points, 482 points,
490 points, 483 points,
491 colors, 484 colors,
492 NULL, 485 NULL,
493 indecies, 486 indecies,
494 3, 487 3,
495 third_paint); 488 third_paint);
496 489
497 skia::RefPtr<SkPicture> picture = 490 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
498 skia::AdoptRef(StopRecording(&recorder, canvas));
499 491
500 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 492 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
501 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 493 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
502 494
503 EXPECT_EQ(3u, pixel_refs.size()); 495 EXPECT_EQ(3u, pixel_refs.size());
504 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 496 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
505 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 497 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
506 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 498 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
507 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 499 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
508 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 500 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 548
557 canvas->restore(); 549 canvas->restore();
558 550
559 canvas->rotate(27); 551 canvas->rotate(27);
560 canvas->scale(3.3f, 0.4f); 552 canvas->scale(3.3f, 0.4f);
561 553
562 canvas->drawImage(sixth.get(), 0, 0); 554 canvas->drawImage(sixth.get(), 0, 0);
563 555
564 canvas->restore(); 556 canvas->restore();
565 557
566 skia::RefPtr<SkPicture> picture = 558 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
567 skia::AdoptRef(StopRecording(&recorder, canvas));
568 559
569 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 560 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
570 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 561 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
571 562
572 EXPECT_EQ(6u, pixel_refs.size()); 563 EXPECT_EQ(6u, pixel_refs.size());
573 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50), 564 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
574 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 565 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
575 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 566 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
576 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 567 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
577 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50), 568 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // (75, 50, 10, 10). 611 // (75, 50, 10, 10).
621 canvas->drawImageRect( 612 canvas->drawImageRect(
622 second.get(), SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint); 613 second.get(), SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint);
623 canvas->translate(5, 50); 614 canvas->translate(5, 50);
624 // (0, 30, 100, 100). One from bitmap, one from paint. 615 // (0, 30, 100, 100). One from bitmap, one from paint.
625 canvas->drawImageRect( 616 canvas->drawImageRect(
626 third.get(), SkRect::MakeXYWH(-30, -20, 100, 100), &first_paint); 617 third.get(), SkRect::MakeXYWH(-30, -20, 100, 100), &first_paint);
627 618
628 canvas->restore(); 619 canvas->restore();
629 620
630 skia::RefPtr<SkPicture> picture = 621 sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
631 skia::AdoptRef(StopRecording(&recorder, canvas));
632 622
633 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 623 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
634 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 624 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
635 625
636 EXPECT_EQ(4u, pixel_refs.size()); 626 EXPECT_EQ(4u, pixel_refs.size());
637 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), 627 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100),
638 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 628 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
639 VerifyScales(2.f, 2.f, pixel_refs[0].matrix, __LINE__); 629 VerifyScales(2.f, 2.f, pixel_refs[0].matrix, __LINE__);
640 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 630 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
641 EXPECT_FLOAT_RECT_EQ(gfx::RectF(75, 50, 10, 10), 631 EXPECT_FLOAT_RECT_EQ(gfx::RectF(75, 50, 10, 10),
642 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 632 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
643 VerifyScales(0.2f, 0.2f, pixel_refs[1].matrix, __LINE__); 633 VerifyScales(0.2f, 0.2f, pixel_refs[1].matrix, __LINE__);
644 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 634 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
645 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100), 635 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
646 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 636 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
647 VerifyScales(2.f, 2.f, pixel_refs[2].matrix, __LINE__); 637 VerifyScales(2.f, 2.f, pixel_refs[2].matrix, __LINE__);
648 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 638 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
649 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100), 639 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
650 gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect)); 640 gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect));
651 VerifyScales(2.f, 2.f, pixel_refs[3].matrix, __LINE__); 641 VerifyScales(2.f, 2.f, pixel_refs[3].matrix, __LINE__);
652 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[3].filter_quality); 642 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[3].filter_quality);
653 } 643 }
654 644
655 } // namespace skia 645 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/analysis_canvas_unittest.cc ('k') | third_party/WebKit/Source/platform/graphics/ContentLayerDelegate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698