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 virtual 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 virtual size_t contextSize() const OVERRIDE
{
47 return sizeof(SkShader::Context
);
50 virtual void flatten(SkWriteBuffer
&) const OVERRIDE
{}
52 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestDiscardableShader
);
58 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
59 SkFlattenable
* TestDiscardableShader::CreateProc(SkReadBuffer
&) {
60 return new TestDiscardableShader
;
64 void CreateBitmap(gfx::Size size
, const char* uri
, SkBitmap
* bitmap
) {
65 bitmap
->allocN32Pixels(size
.width(), size
.height());
66 bitmap
->pixelRef()->setImmutable();
67 bitmap
->pixelRef()->setURI(uri
);
70 SkCanvas
* StartRecording(SkPictureRecorder
* recorder
, gfx::Rect layer_rect
) {
72 recorder
->beginRecording(layer_rect
.width(), layer_rect
.height());
75 canvas
->translate(-layer_rect
.x(), -layer_rect
.y());
76 canvas
->clipRect(SkRect::MakeXYWH(
77 layer_rect
.x(), layer_rect
.y(), layer_rect
.width(), layer_rect
.height()));
82 SkPicture
* StopRecording(SkPictureRecorder
* recorder
, SkCanvas
* canvas
) {
84 return recorder
->endRecording();
89 TEST(PixelRefUtilsTest
, DrawPaint
) {
90 gfx::Rect
layer_rect(0, 0, 256, 256);
92 SkPictureRecorder recorder
;
93 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
95 TestDiscardableShader first_shader
;
97 first_paint
.setShader(&first_shader
);
99 TestDiscardableShader second_shader
;
100 SkPaint second_paint
;
101 second_paint
.setShader(&second_shader
);
103 TestDiscardableShader third_shader
;
105 third_paint
.setShader(&third_shader
);
107 canvas
->drawPaint(first_paint
);
108 canvas
->clipRect(SkRect::MakeXYWH(34, 45, 56, 67));
109 canvas
->drawPaint(second_paint
);
110 // Total clip is now (34, 45, 56, 55)
111 canvas
->clipRect(SkRect::MakeWH(100, 100));
112 canvas
->drawPaint(third_paint
);
114 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
116 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
117 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
119 EXPECT_EQ(3u, pixel_refs
.size());
120 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256),
121 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
122 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 67),
123 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
124 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 55),
125 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
128 TEST(PixelRefUtilsTest
, DrawPoints
) {
129 gfx::Rect
layer_rect(0, 0, 256, 256);
131 SkPictureRecorder recorder
;
132 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
134 TestDiscardableShader first_shader
;
136 first_paint
.setShader(&first_shader
);
138 TestDiscardableShader second_shader
;
139 SkPaint second_paint
;
140 second_paint
.setShader(&second_shader
);
142 TestDiscardableShader third_shader
;
144 third_paint
.setShader(&third_shader
);
147 points
[0].set(10, 10);
148 points
[1].set(100, 20);
149 points
[2].set(50, 100);
151 canvas
->drawPoints(SkCanvas::kPolygon_PointMode
, 3, points
, first_paint
);
155 canvas
->clipRect(SkRect::MakeWH(50, 50));
157 canvas
->drawPoints(SkCanvas::kPolygon_PointMode
, 3, points
, second_paint
);
161 points
[0].set(50, 55);
162 points
[1].set(50, 55);
163 points
[2].set(200, 200);
164 // (50, 55, 150, 145).
165 canvas
->drawPoints(SkCanvas::kPolygon_PointMode
, 3, points
, third_paint
);
167 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
169 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
170 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
172 EXPECT_EQ(3u, pixel_refs
.size());
173 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
174 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
175 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40),
176 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
177 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
178 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
181 TEST(PixelRefUtilsTest
, DrawRect
) {
182 gfx::Rect
layer_rect(0, 0, 256, 256);
184 SkPictureRecorder recorder
;
185 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
187 TestDiscardableShader first_shader
;
189 first_paint
.setShader(&first_shader
);
191 TestDiscardableShader second_shader
;
192 SkPaint second_paint
;
193 second_paint
.setShader(&second_shader
);
195 TestDiscardableShader third_shader
;
197 third_paint
.setShader(&third_shader
);
200 canvas
->drawRect(SkRect::MakeXYWH(10, 20, 30, 40), first_paint
);
204 canvas
->translate(5, 17);
206 canvas
->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint
);
210 canvas
->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
211 canvas
->translate(20, 20);
213 canvas
->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint
);
215 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
217 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
218 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
220 EXPECT_EQ(3u, pixel_refs
.size());
221 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
222 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
223 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
224 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
225 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
226 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
229 TEST(PixelRefUtilsTest
, DrawRRect
) {
230 gfx::Rect
layer_rect(0, 0, 256, 256);
232 SkPictureRecorder recorder
;
233 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
235 TestDiscardableShader first_shader
;
237 first_paint
.setShader(&first_shader
);
239 TestDiscardableShader second_shader
;
240 SkPaint second_paint
;
241 second_paint
.setShader(&second_shader
);
243 TestDiscardableShader third_shader
;
245 third_paint
.setShader(&third_shader
);
248 rrect
.setRect(SkRect::MakeXYWH(10, 20, 30, 40));
251 canvas
->drawRRect(rrect
, first_paint
);
255 canvas
->translate(5, 17);
256 rrect
.setRect(SkRect::MakeXYWH(0, 33, 25, 35));
258 canvas
->drawRRect(rrect
, second_paint
);
262 canvas
->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
263 canvas
->translate(20, 20);
264 rrect
.setRect(SkRect::MakeXYWH(0, 0, 100, 100));
266 canvas
->drawRRect(rrect
, third_paint
);
268 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
270 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
271 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
273 EXPECT_EQ(3u, pixel_refs
.size());
274 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
275 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
276 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
277 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
278 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
279 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
282 TEST(PixelRefUtilsTest
, DrawOval
) {
283 gfx::Rect
layer_rect(0, 0, 256, 256);
285 SkPictureRecorder recorder
;
286 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
288 TestDiscardableShader first_shader
;
290 first_paint
.setShader(&first_shader
);
292 TestDiscardableShader second_shader
;
293 SkPaint second_paint
;
294 second_paint
.setShader(&second_shader
);
296 TestDiscardableShader third_shader
;
298 third_paint
.setShader(&third_shader
);
302 canvas
->scale(2, 0.5);
304 canvas
->drawOval(SkRect::MakeXYWH(10, 20, 30, 40), first_paint
);
309 canvas
->translate(1, 2);
311 canvas
->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint
);
315 canvas
->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
316 canvas
->translate(20, 20);
318 canvas
->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint
);
320 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
322 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
323 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
325 EXPECT_EQ(3u, pixel_refs
.size());
326 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20),
327 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
328 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35),
329 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
330 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
331 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
334 TEST(PixelRefUtilsTest
, DrawPath
) {
335 gfx::Rect
layer_rect(0, 0, 256, 256);
337 SkPictureRecorder recorder
;
338 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
340 TestDiscardableShader first_shader
;
342 first_paint
.setShader(&first_shader
);
344 TestDiscardableShader second_shader
;
345 SkPaint second_paint
;
346 second_paint
.setShader(&second_shader
);
351 path
.lineTo(22, 101);
354 canvas
->drawPath(path
, first_paint
);
357 canvas
->clipRect(SkRect::MakeWH(50, 50));
360 canvas
->drawPath(path
, second_paint
);
364 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
366 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
367 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
369 EXPECT_EQ(2u, pixel_refs
.size());
370 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
371 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
372 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 37),
373 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
376 TEST(PixelRefUtilsTest
, DrawBitmap
) {
377 gfx::Rect
layer_rect(0, 0, 256, 256);
379 SkPictureRecorder recorder
;
380 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
383 CreateBitmap(gfx::Size(50, 50), "discardable", &first
);
385 CreateBitmap(gfx::Size(50, 50), "discardable", &second
);
387 CreateBitmap(gfx::Size(50, 50), "discardable", &third
);
389 CreateBitmap(gfx::Size(50, 1), "discardable", &fourth
);
391 CreateBitmap(gfx::Size(10, 10), "discardable", &fifth
);
396 canvas
->drawBitmap(first
, 0, 0);
397 canvas
->translate(25, 0);
399 canvas
->drawBitmap(second
, 0, 0);
400 canvas
->translate(0, 50);
402 canvas
->drawBitmap(third
, 25, 0);
407 canvas
->translate(1, 0);
409 // At (1, 0), rotated 90 degrees
410 canvas
->drawBitmap(fourth
, 0, 0);
415 // At (0, 0), scaled by 5 and 6
416 canvas
->drawBitmap(fifth
, 0, 0);
418 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
420 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
421 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
423 EXPECT_EQ(5u, pixel_refs
.size());
424 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
425 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
426 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
427 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
428 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
429 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
430 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50),
431 gfx::SkRectToRectF(pixel_refs
[3].pixel_ref_rect
));
432 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60),
433 gfx::SkRectToRectF(pixel_refs
[4].pixel_ref_rect
));
437 TEST(PixelRefUtilsTest
, DrawBitmapRect
) {
438 gfx::Rect
layer_rect(0, 0, 256, 256);
440 SkPictureRecorder recorder
;
441 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
444 CreateBitmap(gfx::Size(50, 50), "discardable", &first
);
446 CreateBitmap(gfx::Size(50, 50), "discardable", &second
);
448 CreateBitmap(gfx::Size(50, 50), "discardable", &third
);
450 TestDiscardableShader first_shader
;
452 first_paint
.setShader(&first_shader
);
454 SkPaint non_discardable_paint
;
459 canvas
->drawBitmapRect(
460 first
, SkRect::MakeWH(100, 100), &non_discardable_paint
);
461 canvas
->translate(25, 0);
463 canvas
->drawBitmapRect(
464 second
, SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint
);
465 canvas
->translate(5, 50);
466 // (0, 30, 100, 100). One from bitmap, one from paint.
467 canvas
->drawBitmapRect(
468 third
, SkRect::MakeXYWH(-30, -20, 100, 100), &first_paint
);
472 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
474 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
475 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
477 EXPECT_EQ(4u, pixel_refs
.size());
478 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100),
479 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
480 EXPECT_FLOAT_RECT_EQ(gfx::RectF(75, 50, 10, 10),
481 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
482 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
483 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
484 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
485 gfx::SkRectToRectF(pixel_refs
[3].pixel_ref_rect
));
488 TEST(PixelRefUtilsTest
, DrawSprite
) {
489 gfx::Rect
layer_rect(0, 0, 256, 256);
491 SkPictureRecorder recorder
;
492 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
495 CreateBitmap(gfx::Size(50, 50), "discardable", &first
);
497 CreateBitmap(gfx::Size(50, 50), "discardable", &second
);
499 CreateBitmap(gfx::Size(50, 50), "discardable", &third
);
501 CreateBitmap(gfx::Size(50, 50), "discardable", &fourth
);
503 CreateBitmap(gfx::Size(50, 50), "discardable", &fifth
);
507 // Sprites aren't affected by the current matrix.
510 canvas
->drawSprite(first
, 0, 0);
511 canvas
->translate(25, 0);
513 canvas
->drawSprite(second
, 10, 0);
514 canvas
->translate(0, 50);
516 canvas
->drawSprite(third
, 25, 0);
523 canvas
->drawSprite(fourth
, 0, 0);
527 TestDiscardableShader first_shader
;
529 first_paint
.setShader(&first_shader
);
532 // (100, 100, 50, 50).
533 canvas
->drawSprite(fifth
, 100, 100, &first_paint
);
535 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
537 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
538 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
540 EXPECT_EQ(6u, pixel_refs
.size());
541 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
542 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
543 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 0, 50, 50),
544 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
545 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
546 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));
547 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
548 gfx::SkRectToRectF(pixel_refs
[3].pixel_ref_rect
));
549 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 50, 50),
550 gfx::SkRectToRectF(pixel_refs
[4].pixel_ref_rect
));
551 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 50, 50),
552 gfx::SkRectToRectF(pixel_refs
[5].pixel_ref_rect
));
555 TEST(PixelRefUtilsTest
, DrawText
) {
556 gfx::Rect
layer_rect(0, 0, 256, 256);
558 SkPictureRecorder recorder
;
559 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
561 TestDiscardableShader first_shader
;
563 first_paint
.setShader(&first_shader
);
566 points
[0].set(10, 50);
567 points
[1].set(20, 50);
568 points
[2].set(30, 50);
569 points
[3].set(40, 50);
578 canvas
->drawText("text", 4, 50, 50, first_paint
);
579 canvas
->drawPosText("text", 4, points
, first_paint
);
580 canvas
->drawTextOnPath("text", 4, path
, NULL
, first_paint
);
582 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
584 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
585 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
587 EXPECT_EQ(3u, pixel_refs
.size());
590 TEST(PixelRefUtilsTest
, DrawVertices
) {
591 gfx::Rect
layer_rect(0, 0, 256, 256);
593 SkPictureRecorder recorder
;
594 SkCanvas
* canvas
= StartRecording(&recorder
, layer_rect
);
596 TestDiscardableShader first_shader
;
598 first_paint
.setShader(&first_shader
);
600 TestDiscardableShader second_shader
;
601 SkPaint second_paint
;
602 second_paint
.setShader(&second_shader
);
604 TestDiscardableShader third_shader
;
606 third_paint
.setShader(&third_shader
);
610 uint16_t indecies
[3] = {0, 1, 2};
611 points
[0].set(10, 10);
612 points
[1].set(100, 20);
613 points
[2].set(50, 100);
615 canvas
->drawVertices(SkCanvas::kTriangles_VertexMode
,
627 canvas
->clipRect(SkRect::MakeWH(50, 50));
629 canvas
->drawVertices(SkCanvas::kTriangles_VertexMode
,
641 points
[0].set(50, 55);
642 points
[1].set(50, 55);
643 points
[2].set(200, 200);
644 // (50, 55, 150, 145).
645 canvas
->drawVertices(SkCanvas::kTriangles_VertexMode
,
655 skia::RefPtr
<SkPicture
> picture
= skia::AdoptRef(StopRecording(&recorder
, canvas
));
657 std::vector
<skia::PixelRefUtils::PositionPixelRef
> pixel_refs
;
658 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture
.get(), &pixel_refs
);
660 EXPECT_EQ(3u, pixel_refs
.size());
661 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
662 gfx::SkRectToRectF(pixel_refs
[0].pixel_ref_rect
));
663 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40),
664 gfx::SkRectToRectF(pixel_refs
[1].pixel_ref_rect
));
665 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
666 gfx::SkRectToRectF(pixel_refs
[2].pixel_ref_rect
));