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
3 // found in the LICENSE file.
5 #include "base/compiler_specific.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "cc/test/geometry_test_utils.h"
8 #include "skia/ext/pixel_ref_utils.h"
9 #include "skia/ext/refptr.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkPictureRecorder.h"
14 #include "third_party/skia/include/core/SkPixelRef.h"
15 #include "third_party/skia/include/core/SkPoint.h"
16 #include "third_party/skia/include/core/SkShader.h"
17 #include "third_party/skia/src/core/SkOrderedReadBuffer.h"
18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/skia_util.h"
25 void CreateBitmap(gfx::Size size
, const char* uri
, SkBitmap
* bitmap
);
27 class TestDiscardableShader
: public SkShader
{
29 TestDiscardableShader() {
30 CreateBitmap(gfx::Size(50, 50), "discardable", &bitmap_
);
33 TestDiscardableShader(SkReadBuffer
& buffer
) {
34 CreateBitmap(gfx::Size(50, 50), "discardable", &bitmap_
);
37 SkShader::BitmapType
asABitmap(SkBitmap
* bitmap
,
39 TileMode xy
[2]) const override
{
42 return SkShader::kDefault_BitmapType
;
45 // not indended to return an actual context. Just need to supply this.
46 size_t contextSize() const override
{ return sizeof(SkShader::Context
); }
48 void flatten(SkWriteBuffer
&) const override
{}
50 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestDiscardableShader
);
56 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
57 SkFlattenable
* TestDiscardableShader::CreateProc(SkReadBuffer
&) {
58 return new TestDiscardableShader
;
62 void CreateBitmap(gfx::Size size
, const char* uri
, SkBitmap
* bitmap
) {
63 bitmap
->allocN32Pixels(size
.width(), size
.height());
64 bitmap
->pixelRef()->setImmutable();
65 bitmap
->pixelRef()->setURI(uri
);
68 SkCanvas
* StartRecording(SkPictureRecorder
* recorder
, gfx::Rect layer_rect
) {
70 recorder
->beginRecording(layer_rect
.width(), layer_rect
.height());
73 canvas
->translate(-layer_rect
.x(), -layer_rect
.y());
74 canvas
->clipRect(SkRect::MakeXYWH(
75 layer_rect
.x(), layer_rect
.y(), layer_rect
.width(), layer_rect
.height()));
80 SkPicture
* StopRecording(SkPictureRecorder
* recorder
, SkCanvas
* canvas
) {
82 return recorder
->endRecording();
87 TEST(PixelRefUtilsTest
, DrawPaint
) {
88 gfx::Rect
layer_rect(0, 0, 256, 256);
90 SkPictureRecorder recorder
;
91 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
93 TestDiscardableShader first_shader
;
95 first_paint
.setShader(&first_shader
);
97 TestDiscardableShader second_shader
;
99 second_paint
.setShader(&second_shader
);
101 TestDiscardableShader third_shader
;
103 third_paint
.setShader(&third_shader
);
105 canvas
->drawPaint(first_paint
);
106 canvas
->clipRect(SkRect::MakeXYWH(34, 45, 56, 67));
107 canvas
->drawPaint(second_paint
);
108 // Total clip is now (34, 45, 56, 55)
109 canvas
->clipRect(SkRect::MakeWH(100, 100));
110 canvas
->drawPaint(third_paint
);
112 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
114 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
115 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
117 EXPECT_EQ(3u, pixel_refs
.size());
118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256),
119 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
120 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 67),
121 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
122 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 55),
123 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
126 TEST(PixelRefUtilsTest
, DrawPoints
) {
127 gfx::Rect
layer_rect(0, 0, 256, 256);
129 SkPictureRecorder recorder
;
130 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
132 TestDiscardableShader first_shader
;
134 first_paint
.setShader(&first_shader
);
136 TestDiscardableShader second_shader
;
137 SkPaint second_paint
;
138 second_paint
.setShader(&second_shader
);
140 TestDiscardableShader third_shader
;
142 third_paint
.setShader(&third_shader
);
145 points
[0].set(10, 10);
146 points
[1].set(100, 20);
147 points
[2].set(50, 100);
149 canvas
->drawPoints(SkCanvas::kPolygon_PointMode
, 3, points
, first_paint
);
153 canvas
->clipRect(SkRect::MakeWH(50, 50));
155 canvas
->drawPoints(SkCanvas::kPolygon_PointMode
, 3, points
, second_paint
);
159 points
[0].set(50, 55);
160 points
[1].set(50, 55);
161 points
[2].set(200, 200);
162 // (50, 55, 150, 145).
163 canvas
->drawPoints(SkCanvas::kPolygon_PointMode
, 3, points
, third_paint
);
165 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
167 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
168 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
170 EXPECT_EQ(3u, pixel_refs
.size());
171 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
172 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
173 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40),
174 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
175 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
176 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
179 TEST(PixelRefUtilsTest
, DrawRect
) {
180 gfx::Rect
layer_rect(0, 0, 256, 256);
182 SkPictureRecorder recorder
;
183 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
185 TestDiscardableShader first_shader
;
187 first_paint
.setShader(&first_shader
);
189 TestDiscardableShader second_shader
;
190 SkPaint second_paint
;
191 second_paint
.setShader(&second_shader
);
193 TestDiscardableShader third_shader
;
195 third_paint
.setShader(&third_shader
);
198 canvas
->drawRect(SkRect::MakeXYWH(10, 20, 30, 40), first_paint
);
202 canvas
->translate(5, 17);
204 canvas
->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint
);
208 canvas
->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
209 canvas
->translate(20, 20);
211 canvas
->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint
);
213 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
215 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
216 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
218 EXPECT_EQ(3u, pixel_refs
.size());
219 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
220 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
221 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
222 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
223 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
224 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
227 TEST(PixelRefUtilsTest
, DrawRRect
) {
228 gfx::Rect
layer_rect(0, 0, 256, 256);
230 SkPictureRecorder recorder
;
231 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
233 TestDiscardableShader first_shader
;
235 first_paint
.setShader(&first_shader
);
237 TestDiscardableShader second_shader
;
238 SkPaint second_paint
;
239 second_paint
.setShader(&second_shader
);
241 TestDiscardableShader third_shader
;
243 third_paint
.setShader(&third_shader
);
246 rrect
.setRect(SkRect::MakeXYWH(10, 20, 30, 40));
249 canvas
->drawRRect(rrect
, first_paint
);
253 canvas
->translate(5, 17);
254 rrect
.setRect(SkRect::MakeXYWH(0, 33, 25, 35));
256 canvas
->drawRRect(rrect
, second_paint
);
260 canvas
->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
261 canvas
->translate(20, 20);
262 rrect
.setRect(SkRect::MakeXYWH(0, 0, 100, 100));
264 canvas
->drawRRect(rrect
, third_paint
);
266 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
268 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
269 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
271 EXPECT_EQ(3u, pixel_refs
.size());
272 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
273 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
274 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
275 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
276 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
277 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
280 TEST(PixelRefUtilsTest
, DrawOval
) {
281 gfx::Rect
layer_rect(0, 0, 256, 256);
283 SkPictureRecorder recorder
;
284 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
286 TestDiscardableShader first_shader
;
288 first_paint
.setShader(&first_shader
);
290 TestDiscardableShader second_shader
;
291 SkPaint second_paint
;
292 second_paint
.setShader(&second_shader
);
294 TestDiscardableShader third_shader
;
296 third_paint
.setShader(&third_shader
);
300 canvas
->scale(2, 0.5);
302 canvas
->drawOval(SkRect::MakeXYWH(10, 20, 30, 40), first_paint
);
307 canvas
->translate(1, 2);
309 canvas
->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint
);
313 canvas
->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
314 canvas
->translate(20, 20);
316 canvas
->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint
);
318 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
320 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
321 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
323 EXPECT_EQ(3u, pixel_refs
.size());
324 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20),
325 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
326 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35),
327 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
328 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
329 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
332 TEST(PixelRefUtilsTest
, DrawPath
) {
333 gfx::Rect
layer_rect(0, 0, 256, 256);
335 SkPictureRecorder recorder
;
336 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
338 TestDiscardableShader first_shader
;
340 first_paint
.setShader(&first_shader
);
342 TestDiscardableShader second_shader
;
343 SkPaint second_paint
;
344 second_paint
.setShader(&second_shader
);
349 path
.lineTo(22, 101);
352 canvas
->drawPath(path
, first_paint
);
355 canvas
->clipRect(SkRect::MakeWH(50, 50));
358 canvas
->drawPath(path
, second_paint
);
362 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
364 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
365 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
367 EXPECT_EQ(2u, pixel_refs
.size());
368 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
369 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
370 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 37),
371 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
374 TEST(PixelRefUtilsTest
, DrawBitmap
) {
375 gfx::Rect
layer_rect(0, 0, 256, 256);
377 SkPictureRecorder recorder
;
378 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
381 CreateBitmap(gfx::Size(50, 50), "discardable", &first
);
383 CreateBitmap(gfx::Size(50, 50), "discardable", &second
);
385 CreateBitmap(gfx::Size(50, 50), "discardable", &third
);
387 CreateBitmap(gfx::Size(50, 1), "discardable", &fourth
);
389 CreateBitmap(gfx::Size(10, 10), "discardable", &fifth
);
394 canvas
->drawBitmap(first
, 0, 0);
395 canvas
->translate(25, 0);
397 canvas
->drawBitmap(second
, 0, 0);
398 canvas
->translate(0, 50);
400 canvas
->drawBitmap(third
, 25, 0);
405 canvas
->translate(1, 0);
407 // At (1, 0), rotated 90 degrees
408 canvas
->drawBitmap(fourth
, 0, 0);
413 // At (0, 0), scaled by 5 and 6
414 canvas
->drawBitmap(fifth
, 0, 0);
416 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
418 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
419 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
421 EXPECT_EQ(5u, pixel_refs
.size());
422 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
423 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
424 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
425 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
426 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
427 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
428 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50),
429 gfx::SkRectToRectF(pixel_refs
[3].pixel_ref_rect
));
430 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60),
431 gfx::SkRectToRectF(pixel_refs
[4].pixel_ref_rect
));
435 TEST(PixelRefUtilsTest
, DrawBitmapRect
) {
436 gfx::Rect
layer_rect(0, 0, 256, 256);
438 SkPictureRecorder recorder
;
439 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
442 CreateBitmap(gfx::Size(50, 50), "discardable", &first
);
444 CreateBitmap(gfx::Size(50, 50), "discardable", &second
);
446 CreateBitmap(gfx::Size(50, 50), "discardable", &third
);
448 TestDiscardableShader first_shader
;
450 first_paint
.setShader(&first_shader
);
452 SkPaint non_discardable_paint
;
457 canvas
->drawBitmapRect(
458 first
, SkRect::MakeWH(100, 100), &non_discardable_paint
);
459 canvas
->translate(25, 0);
461 canvas
->drawBitmapRect(
462 second
, SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint
);
463 canvas
->translate(5, 50);
464 // (0, 30, 100, 100). One from bitmap, one from paint.
465 canvas
->drawBitmapRect(
466 third
, SkRect::MakeXYWH(-30, -20, 100, 100), &first_paint
);
470 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
472 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
473 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
475 EXPECT_EQ(4u, pixel_refs
.size());
476 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100),
477 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
478 EXPECT_FLOAT_RECT_EQ(gfx::RectF(75, 50, 10, 10),
479 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
480 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
481 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
482 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
483 gfx::SkRectToRectF(pixel_refs
[3].pixel_ref_rect
));
486 TEST(PixelRefUtilsTest
, DrawSprite
) {
487 gfx::Rect
layer_rect(0, 0, 256, 256);
489 SkPictureRecorder recorder
;
490 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
493 CreateBitmap(gfx::Size(50, 50), "discardable", &first
);
495 CreateBitmap(gfx::Size(50, 50), "discardable", &second
);
497 CreateBitmap(gfx::Size(50, 50), "discardable", &third
);
499 CreateBitmap(gfx::Size(50, 50), "discardable", &fourth
);
501 CreateBitmap(gfx::Size(50, 50), "discardable", &fifth
);
505 // Sprites aren't affected by the current matrix.
508 canvas
->drawSprite(first
, 0, 0);
509 canvas
->translate(25, 0);
511 canvas
->drawSprite(second
, 10, 0);
512 canvas
->translate(0, 50);
514 canvas
->drawSprite(third
, 25, 0);
521 canvas
->drawSprite(fourth
, 0, 0);
525 TestDiscardableShader first_shader
;
527 first_paint
.setShader(&first_shader
);
530 // (100, 100, 50, 50).
531 canvas
->drawSprite(fifth
, 100, 100, &first_paint
);
533 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
535 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
536 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
538 EXPECT_EQ(6u, pixel_refs
.size());
539 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
540 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
541 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 0, 50, 50),
542 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
543 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
544 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
545 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
546 gfx::SkRectToRectF(pixel_refs
[3].pixel_ref_rect
));
547 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 50, 50),
548 gfx::SkRectToRectF(pixel_refs
[4].pixel_ref_rect
));
549 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 50, 50),
550 gfx::SkRectToRectF(pixel_refs
[5].pixel_ref_rect
));
553 TEST(PixelRefUtilsTest
, DrawText
) {
554 gfx::Rect
layer_rect(0, 0, 256, 256);
556 SkPictureRecorder recorder
;
557 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
559 TestDiscardableShader first_shader
;
561 first_paint
.setShader(&first_shader
);
564 points
[0].set(10, 50);
565 points
[1].set(20, 50);
566 points
[2].set(30, 50);
567 points
[3].set(40, 50);
576 canvas
->drawText("text", 4, 50, 50, first_paint
);
577 canvas
->drawPosText("text", 4, points
, first_paint
);
578 canvas
->drawTextOnPath("text", 4, path
, NULL
, first_paint
);
580 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
582 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
583 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
585 EXPECT_EQ(3u, pixel_refs
.size());
588 TEST(PixelRefUtilsTest
, DrawVertices
) {
589 gfx::Rect
layer_rect(0, 0, 256, 256);
591 SkPictureRecorder recorder
;
592 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
594 TestDiscardableShader first_shader
;
596 first_paint
.setShader(&first_shader
);
598 TestDiscardableShader second_shader
;
599 SkPaint second_paint
;
600 second_paint
.setShader(&second_shader
);
602 TestDiscardableShader third_shader
;
604 third_paint
.setShader(&third_shader
);
608 uint16_t indecies
[3] = {0, 1, 2};
609 points
[0].set(10, 10);
610 points
[1].set(100, 20);
611 points
[2].set(50, 100);
613 canvas
->drawVertices(SkCanvas::kTriangles_VertexMode
,
625 canvas
->clipRect(SkRect::MakeWH(50, 50));
627 canvas
->drawVertices(SkCanvas::kTriangles_VertexMode
,
639 points
[0].set(50, 55);
640 points
[1].set(50, 55);
641 points
[2].set(200, 200);
642 // (50, 55, 150, 145).
643 canvas
->drawVertices(SkCanvas::kTriangles_VertexMode
,
653 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
655 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
656 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
658 EXPECT_EQ(3u, pixel_refs
.size());
659 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
660 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
661 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40),
662 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
663 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
664 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));