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

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

Issue 1066273002: Use SkPictureRecorder::endRecordingAsPicture() instead of endRecording() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « skia/ext/analysis_canvas_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "cc/test/geometry_test_utils.h" 7 #include "cc/test/geometry_test_utils.h"
8 #include "skia/ext/pixel_ref_utils.h" 8 #include "skia/ext/pixel_ref_utils.h"
9 #include "skia/ext/refptr.h" 9 #include "skia/ext/refptr.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 canvas->save(); 78 canvas->save();
79 canvas->translate(-layer_rect.x(), -layer_rect.y()); 79 canvas->translate(-layer_rect.x(), -layer_rect.y());
80 canvas->clipRect(SkRect::MakeXYWH( 80 canvas->clipRect(SkRect::MakeXYWH(
81 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height())); 81 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height()));
82 82
83 return canvas; 83 return canvas;
84 } 84 }
85 85
86 SkPicture* StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) { 86 SkPicture* StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) {
87 canvas->restore(); 87 canvas->restore();
88 return recorder->endRecording(); 88 return recorder->endRecordingAsPicture();
89 } 89 }
90 90
91 } // namespace 91 } // namespace
92 92
93 TEST(PixelRefUtilsTest, DrawPaint) { 93 TEST(PixelRefUtilsTest, DrawPaint) {
94 gfx::Rect layer_rect(0, 0, 256, 256); 94 gfx::Rect layer_rect(0, 0, 256, 256);
95 95
96 SkPictureRecorder recorder; 96 SkPictureRecorder recorder;
97 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 97 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
98 98
99 TestDiscardableShader first_shader; 99 TestDiscardableShader first_shader;
100 SkPaint first_paint; 100 SkPaint first_paint;
101 first_paint.setShader(&first_shader); 101 first_paint.setShader(&first_shader);
102 102
103 TestDiscardableShader second_shader; 103 TestDiscardableShader second_shader;
104 SkPaint second_paint; 104 SkPaint second_paint;
105 second_paint.setShader(&second_shader); 105 second_paint.setShader(&second_shader);
106 106
107 TestDiscardableShader third_shader; 107 TestDiscardableShader third_shader;
108 SkPaint third_paint; 108 SkPaint third_paint;
109 third_paint.setShader(&third_shader); 109 third_paint.setShader(&third_shader);
110 110
111 canvas->drawPaint(first_paint); 111 canvas->drawPaint(first_paint);
112 canvas->clipRect(SkRect::MakeXYWH(34, 45, 56, 67)); 112 canvas->clipRect(SkRect::MakeXYWH(34, 45, 56, 67));
113 canvas->drawPaint(second_paint); 113 canvas->drawPaint(second_paint);
114 // Total clip is now (34, 45, 56, 55) 114 // Total clip is now (34, 45, 56, 55)
115 canvas->clipRect(SkRect::MakeWH(100, 100)); 115 canvas->clipRect(SkRect::MakeWH(100, 100));
116 canvas->drawPaint(third_paint); 116 canvas->drawPaint(third_paint);
117 117
118 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 118 skia::RefPtr<SkPicture> picture =
119 skia::AdoptRef(StopRecording(&recorder, canvas));
119 120
120 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 121 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
121 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 122 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
122 123
123 EXPECT_EQ(3u, pixel_refs.size()); 124 EXPECT_EQ(3u, pixel_refs.size());
124 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256), 125 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256),
125 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 126 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
126 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 67), 127 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 67),
127 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 128 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
128 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 55), 129 EXPECT_FLOAT_RECT_EQ(gfx::RectF(34, 45, 56, 55),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, second_paint); 162 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, second_paint);
162 163
163 canvas->restore(); 164 canvas->restore();
164 165
165 points[0].set(50, 55); 166 points[0].set(50, 55);
166 points[1].set(50, 55); 167 points[1].set(50, 55);
167 points[2].set(200, 200); 168 points[2].set(200, 200);
168 // (50, 55, 150, 145). 169 // (50, 55, 150, 145).
169 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint); 170 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint);
170 171
171 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 172 skia::RefPtr<SkPicture> picture =
173 skia::AdoptRef(StopRecording(&recorder, canvas));
172 174
173 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 175 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
174 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 176 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
175 177
176 EXPECT_EQ(3u, pixel_refs.size()); 178 EXPECT_EQ(3u, pixel_refs.size());
177 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 179 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
178 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 180 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
179 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), 181 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40),
180 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 182 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
181 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), 183 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
(...skipping 27 matching lines...) Expand all
209 // (5, 50, 25, 35) 211 // (5, 50, 25, 35)
210 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint); 212 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint);
211 213
212 canvas->restore(); 214 canvas->restore();
213 215
214 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 216 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
215 canvas->translate(20, 20); 217 canvas->translate(20, 20);
216 // (50, 50, 50, 50) 218 // (50, 50, 50, 50)
217 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); 219 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
218 220
219 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 221 skia::RefPtr<SkPicture> picture =
222 skia::AdoptRef(StopRecording(&recorder, canvas));
220 223
221 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 224 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
222 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 225 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
223 226
224 EXPECT_EQ(3u, pixel_refs.size()); 227 EXPECT_EQ(3u, pixel_refs.size());
225 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), 228 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
226 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 229 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
227 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35), 230 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
228 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 231 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
229 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 232 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 canvas->drawRRect(rrect, second_paint); 265 canvas->drawRRect(rrect, second_paint);
263 266
264 canvas->restore(); 267 canvas->restore();
265 268
266 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 269 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
267 canvas->translate(20, 20); 270 canvas->translate(20, 20);
268 rrect.setRect(SkRect::MakeXYWH(0, 0, 100, 100)); 271 rrect.setRect(SkRect::MakeXYWH(0, 0, 100, 100));
269 // (50, 50, 50, 50) 272 // (50, 50, 50, 50)
270 canvas->drawRRect(rrect, third_paint); 273 canvas->drawRRect(rrect, third_paint);
271 274
272 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 275 skia::RefPtr<SkPicture> picture =
276 skia::AdoptRef(StopRecording(&recorder, canvas));
273 277
274 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 278 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
275 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 279 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
276 280
277 EXPECT_EQ(3u, pixel_refs.size()); 281 EXPECT_EQ(3u, pixel_refs.size());
278 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), 282 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
279 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 283 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
280 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35), 284 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
281 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 285 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
282 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 286 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // (1, 35, 25, 35) 318 // (1, 35, 25, 35)
315 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint); 319 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint);
316 320
317 canvas->restore(); 321 canvas->restore();
318 322
319 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 323 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
320 canvas->translate(20, 20); 324 canvas->translate(20, 20);
321 // (50, 50, 50, 50) 325 // (50, 50, 50, 50)
322 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); 326 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
323 327
324 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 328 skia::RefPtr<SkPicture> picture =
329 skia::AdoptRef(StopRecording(&recorder, canvas));
325 330
326 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 331 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
327 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 332 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
328 333
329 EXPECT_EQ(3u, pixel_refs.size()); 334 EXPECT_EQ(3u, pixel_refs.size());
330 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20), 335 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20),
331 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 336 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
332 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35), 337 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35),
333 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 338 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
334 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 339 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
(...skipping 23 matching lines...) Expand all
358 canvas->drawPath(path, first_paint); 363 canvas->drawPath(path, first_paint);
359 364
360 canvas->save(); 365 canvas->save();
361 canvas->clipRect(SkRect::MakeWH(50, 50)); 366 canvas->clipRect(SkRect::MakeWH(50, 50));
362 367
363 // (12, 13, 38, 37). 368 // (12, 13, 38, 37).
364 canvas->drawPath(path, second_paint); 369 canvas->drawPath(path, second_paint);
365 370
366 canvas->restore(); 371 canvas->restore();
367 372
368 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 373 skia::RefPtr<SkPicture> picture =
374 skia::AdoptRef(StopRecording(&recorder, canvas));
369 375
370 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 376 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
371 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 377 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
372 378
373 EXPECT_EQ(2u, pixel_refs.size()); 379 EXPECT_EQ(2u, pixel_refs.size());
374 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88), 380 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
375 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 381 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
376 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 37), 382 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 37),
377 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 383 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
378 } 384 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 canvas->rotate(90); 418 canvas->rotate(90);
413 // At (1, 0), rotated 90 degrees 419 // At (1, 0), rotated 90 degrees
414 canvas->drawBitmap(fourth, 0, 0); 420 canvas->drawBitmap(fourth, 0, 0);
415 421
416 canvas->restore(); 422 canvas->restore();
417 423
418 canvas->scale(5, 6); 424 canvas->scale(5, 6);
419 // At (0, 0), scaled by 5 and 6 425 // At (0, 0), scaled by 5 and 6
420 canvas->drawBitmap(fifth, 0, 0); 426 canvas->drawBitmap(fifth, 0, 0);
421 427
422 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 428 skia::RefPtr<SkPicture> picture =
429 skia::AdoptRef(StopRecording(&recorder, canvas));
423 430
424 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 431 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
425 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 432 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
426 433
427 EXPECT_EQ(5u, pixel_refs.size()); 434 EXPECT_EQ(5u, pixel_refs.size());
428 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50), 435 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
429 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 436 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
430 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50), 437 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
431 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 438 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
432 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 439 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
433 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 440 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
434 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50), 441 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50),
435 gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect)); 442 gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect));
436 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60), 443 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60),
437 gfx::SkRectToRectF(pixel_refs[4].pixel_ref_rect)); 444 gfx::SkRectToRectF(pixel_refs[4].pixel_ref_rect));
438
439 } 445 }
440 446
441 TEST(PixelRefUtilsTest, DrawBitmapRect) { 447 TEST(PixelRefUtilsTest, DrawBitmapRect) {
442 gfx::Rect layer_rect(0, 0, 256, 256); 448 gfx::Rect layer_rect(0, 0, 256, 256);
443 449
444 SkPictureRecorder recorder; 450 SkPictureRecorder recorder;
445 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 451 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
446 452
447 SkBitmap first; 453 SkBitmap first;
448 CreateBitmap(gfx::Size(50, 50), "discardable", &first); 454 CreateBitmap(gfx::Size(50, 50), "discardable", &first);
(...skipping 17 matching lines...) Expand all
466 // (75, 50, 10, 10). 472 // (75, 50, 10, 10).
467 canvas->drawBitmapRect( 473 canvas->drawBitmapRect(
468 second, SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint); 474 second, SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint);
469 canvas->translate(5, 50); 475 canvas->translate(5, 50);
470 // (0, 30, 100, 100). One from bitmap, one from paint. 476 // (0, 30, 100, 100). One from bitmap, one from paint.
471 canvas->drawBitmapRect( 477 canvas->drawBitmapRect(
472 third, SkRect::MakeXYWH(-30, -20, 100, 100), &first_paint); 478 third, SkRect::MakeXYWH(-30, -20, 100, 100), &first_paint);
473 479
474 canvas->restore(); 480 canvas->restore();
475 481
476 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 482 skia::RefPtr<SkPicture> picture =
483 skia::AdoptRef(StopRecording(&recorder, canvas));
477 484
478 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 485 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
479 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 486 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
480 487
481 EXPECT_EQ(4u, pixel_refs.size()); 488 EXPECT_EQ(4u, pixel_refs.size());
482 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), 489 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100),
483 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 490 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
484 EXPECT_FLOAT_RECT_EQ(gfx::RectF(75, 50, 10, 10), 491 EXPECT_FLOAT_RECT_EQ(gfx::RectF(75, 50, 10, 10),
485 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 492 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
486 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100), 493 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 30, 100, 100),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 canvas->restore(); 536 canvas->restore();
530 537
531 TestDiscardableShader first_shader; 538 TestDiscardableShader first_shader;
532 SkPaint first_paint; 539 SkPaint first_paint;
533 first_paint.setShader(&first_shader); 540 first_paint.setShader(&first_shader);
534 541
535 canvas->scale(5, 6); 542 canvas->scale(5, 6);
536 // (100, 100, 50, 50). 543 // (100, 100, 50, 50).
537 canvas->drawSprite(fifth, 100, 100, &first_paint); 544 canvas->drawSprite(fifth, 100, 100, &first_paint);
538 545
539 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 546 skia::RefPtr<SkPicture> picture =
547 skia::AdoptRef(StopRecording(&recorder, canvas));
540 548
541 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 549 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
542 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 550 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
543 551
544 EXPECT_EQ(6u, pixel_refs.size()); 552 EXPECT_EQ(6u, pixel_refs.size());
545 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50), 553 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50),
546 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 554 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
547 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 0, 50, 50), 555 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 0, 50, 50),
548 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 556 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
549 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50), 557 EXPECT_FLOAT_RECT_EQ(gfx::RectF(25, 0, 50, 50),
(...skipping 26 matching lines...) Expand all
576 path.moveTo(10, 50); 584 path.moveTo(10, 50);
577 path.lineTo(20, 50); 585 path.lineTo(20, 50);
578 path.lineTo(30, 50); 586 path.lineTo(30, 50);
579 path.lineTo(40, 50); 587 path.lineTo(40, 50);
580 path.lineTo(50, 50); 588 path.lineTo(50, 50);
581 589
582 canvas->drawText("text", 4, 50, 50, first_paint); 590 canvas->drawText("text", 4, 50, 50, first_paint);
583 canvas->drawPosText("text", 4, points, first_paint); 591 canvas->drawPosText("text", 4, points, first_paint);
584 canvas->drawTextOnPath("text", 4, path, NULL, first_paint); 592 canvas->drawTextOnPath("text", 4, path, NULL, first_paint);
585 593
586 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 594 skia::RefPtr<SkPicture> picture =
595 skia::AdoptRef(StopRecording(&recorder, canvas));
587 596
588 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 597 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
589 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 598 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
590 599
591 EXPECT_EQ(3u, pixel_refs.size()); 600 EXPECT_EQ(3u, pixel_refs.size());
592 } 601 }
593 602
594 TEST(PixelRefUtilsTest, DrawVertices) { 603 TEST(PixelRefUtilsTest, DrawVertices) {
595 gfx::Rect layer_rect(0, 0, 256, 256); 604 gfx::Rect layer_rect(0, 0, 256, 256);
596 605
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, 658 canvas->drawVertices(SkCanvas::kTriangles_VertexMode,
650 3, 659 3,
651 points, 660 points,
652 points, 661 points,
653 colors, 662 colors,
654 NULL, 663 NULL,
655 indecies, 664 indecies,
656 3, 665 3,
657 third_paint); 666 third_paint);
658 667
659 skia::RefPtr<SkPicture> picture = skia::AdoptRef(StopRecording(&recorder, canv as)); 668 skia::RefPtr<SkPicture> picture =
669 skia::AdoptRef(StopRecording(&recorder, canvas));
660 670
661 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 671 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
662 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 672 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
663 673
664 EXPECT_EQ(3u, pixel_refs.size()); 674 EXPECT_EQ(3u, pixel_refs.size());
665 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 675 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
666 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 676 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
667 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), 677 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40),
668 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 678 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
669 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), 679 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
670 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 680 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
671 } 681 }
672 682
673 } // namespace skia 683 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/analysis_canvas_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698