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

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

Issue 1279843004: cc: Plumb more details about pixel refs to tile manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/pixel_ref_utils.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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 SkPoint points[3]; 176 SkPoint points[3];
177 points[0].set(10, 10); 177 points[0].set(10, 10);
178 points[1].set(100, 20); 178 points[1].set(100, 20);
179 points[2].set(50, 100); 179 points[2].set(50, 100);
180 // (10, 10, 90, 90). 180 // (10, 10, 90, 90).
181 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, first_paint); 181 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, first_paint);
182 182
183 canvas->save(); 183 canvas->save();
184 184
185 canvas->clipRect(SkRect::MakeWH(50, 50)); 185 canvas->clipRect(SkRect::MakeWH(50, 50));
186 // (10, 10, 40, 40). 186 // (10, 10, 90, 90).
187 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, second_paint); 187 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, second_paint);
188 188
189 canvas->restore(); 189 canvas->restore();
190 190
191 points[0].set(50, 55); 191 points[0].set(50, 55);
192 points[1].set(50, 55); 192 points[1].set(50, 55);
193 points[2].set(200, 200); 193 points[2].set(200, 200);
194 // (50, 55, 150, 145). 194 // (50, 55, 150, 145).
195 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint); 195 canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint);
196 196
197 skia::RefPtr<SkPicture> picture = 197 skia::RefPtr<SkPicture> picture =
198 skia::AdoptRef(StopRecording(&recorder, canvas)); 198 skia::AdoptRef(StopRecording(&recorder, canvas));
199 199
200 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 200 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
201 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 201 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
202 202
203 EXPECT_EQ(3u, pixel_refs.size()); 203 EXPECT_EQ(3u, pixel_refs.size());
204 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 204 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
205 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 205 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
206 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 206 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
207 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 207 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
208 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), 208 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
209 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 209 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
210 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__); 210 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__);
211 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 211 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
212 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), 212 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
213 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 213 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
214 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__); 214 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__);
215 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 215 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
216 } 216 }
217 217
218 TEST(PixelRefUtilsTest, DrawRect) { 218 TEST(PixelRefUtilsTest, DrawRect) {
(...skipping 20 matching lines...) Expand all
239 canvas->save(); 239 canvas->save();
240 240
241 canvas->translate(5, 17); 241 canvas->translate(5, 17);
242 // (5, 50, 25, 35) 242 // (5, 50, 25, 35)
243 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint); 243 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint);
244 244
245 canvas->restore(); 245 canvas->restore();
246 246
247 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 247 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
248 canvas->translate(20, 20); 248 canvas->translate(20, 20);
249 // (50, 50, 50, 50) 249 // (20, 20, 100, 100)
250 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); 250 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
251 251
252 skia::RefPtr<SkPicture> picture = 252 skia::RefPtr<SkPicture> picture =
253 skia::AdoptRef(StopRecording(&recorder, canvas)); 253 skia::AdoptRef(StopRecording(&recorder, canvas));
254 254
255 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 255 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
256 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 256 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
257 257
258 EXPECT_EQ(3u, pixel_refs.size()); 258 EXPECT_EQ(3u, pixel_refs.size());
259 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), 259 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
260 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 260 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
261 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 261 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
262 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 262 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
263 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35), 263 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
264 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 264 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
265 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__); 265 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__);
266 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 266 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
267 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 267 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 20, 100, 100),
268 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 268 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
269 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__); 269 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__);
270 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 270 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
271 } 271 }
272 272
273 TEST(PixelRefUtilsTest, DrawRRect) { 273 TEST(PixelRefUtilsTest, DrawRRect) {
274 gfx::Rect layer_rect(0, 0, 256, 256); 274 gfx::Rect layer_rect(0, 0, 256, 256);
275 275
276 SkPictureRecorder recorder; 276 SkPictureRecorder recorder;
277 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 277 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
(...skipping 21 matching lines...) Expand all
299 canvas->translate(5, 17); 299 canvas->translate(5, 17);
300 rrect.setRect(SkRect::MakeXYWH(0, 33, 25, 35)); 300 rrect.setRect(SkRect::MakeXYWH(0, 33, 25, 35));
301 // (5, 50, 25, 35) 301 // (5, 50, 25, 35)
302 canvas->drawRRect(rrect, second_paint); 302 canvas->drawRRect(rrect, second_paint);
303 303
304 canvas->restore(); 304 canvas->restore();
305 305
306 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 306 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
307 canvas->translate(20, 20); 307 canvas->translate(20, 20);
308 rrect.setRect(SkRect::MakeXYWH(0, 0, 100, 100)); 308 rrect.setRect(SkRect::MakeXYWH(0, 0, 100, 100));
309 // (50, 50, 50, 50) 309 // (20, 20, 100, 100)
310 canvas->drawRRect(rrect, third_paint); 310 canvas->drawRRect(rrect, third_paint);
311 311
312 skia::RefPtr<SkPicture> picture = 312 skia::RefPtr<SkPicture> picture =
313 skia::AdoptRef(StopRecording(&recorder, canvas)); 313 skia::AdoptRef(StopRecording(&recorder, canvas));
314 314
315 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 315 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
316 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 316 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
317 317
318 EXPECT_EQ(3u, pixel_refs.size()); 318 EXPECT_EQ(3u, pixel_refs.size());
319 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), 319 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40),
320 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 320 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
321 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 321 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
322 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 322 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
323 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35), 323 EXPECT_FLOAT_RECT_EQ(gfx::RectF(5, 50, 25, 35),
324 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 324 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
325 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__); 325 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__);
326 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 326 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
327 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 327 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 20, 100, 100),
328 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 328 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
329 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__); 329 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__);
330 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 330 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
331 } 331 }
332 332
333 TEST(PixelRefUtilsTest, DrawOval) { 333 TEST(PixelRefUtilsTest, DrawOval) {
334 gfx::Rect layer_rect(0, 0, 256, 256); 334 gfx::Rect layer_rect(0, 0, 256, 256);
335 335
336 SkPictureRecorder recorder; 336 SkPictureRecorder recorder;
337 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 337 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
(...skipping 20 matching lines...) Expand all
358 canvas->save(); 358 canvas->save();
359 359
360 canvas->translate(1, 2); 360 canvas->translate(1, 2);
361 // (1, 35, 25, 35) 361 // (1, 35, 25, 35)
362 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint); 362 canvas->drawRect(SkRect::MakeXYWH(0, 33, 25, 35), second_paint);
363 363
364 canvas->restore(); 364 canvas->restore();
365 365
366 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50)); 366 canvas->clipRect(SkRect::MakeXYWH(50, 50, 50, 50));
367 canvas->translate(20, 20); 367 canvas->translate(20, 20);
368 // (50, 50, 50, 50) 368 // (20, 20, 100, 100).
369 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); 369 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
370 370
371 skia::RefPtr<SkPicture> picture = 371 skia::RefPtr<SkPicture> picture =
372 skia::AdoptRef(StopRecording(&recorder, canvas)); 372 skia::AdoptRef(StopRecording(&recorder, canvas));
373 373
374 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 374 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
375 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 375 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
376 376
377 EXPECT_EQ(3u, pixel_refs.size()); 377 EXPECT_EQ(3u, pixel_refs.size());
378 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20), 378 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20),
379 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 379 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
380 VerifyScales(2.f, 0.5f, pixel_refs[0].matrix, __LINE__); 380 VerifyScales(2.f, 0.5f, pixel_refs[0].matrix, __LINE__);
381 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 381 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
382 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35), 382 EXPECT_FLOAT_RECT_EQ(gfx::RectF(1, 35, 25, 35),
383 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 383 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
384 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__); 384 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__);
385 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 385 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
386 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50), 386 EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 20, 100, 100),
387 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 387 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
388 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__); 388 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__);
389 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 389 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
390 } 390 }
391 391
392 TEST(PixelRefUtilsTest, DrawPath) { 392 TEST(PixelRefUtilsTest, DrawPath) {
393 gfx::Rect layer_rect(0, 0, 256, 256); 393 gfx::Rect layer_rect(0, 0, 256, 256);
394 394
395 SkPictureRecorder recorder; 395 SkPictureRecorder recorder;
396 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 396 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
(...skipping 10 matching lines...) Expand all
407 path.moveTo(12, 13); 407 path.moveTo(12, 13);
408 path.lineTo(50, 50); 408 path.lineTo(50, 50);
409 path.lineTo(22, 101); 409 path.lineTo(22, 101);
410 410
411 // (12, 13, 38, 88). 411 // (12, 13, 38, 88).
412 canvas->drawPath(path, first_paint); 412 canvas->drawPath(path, first_paint);
413 413
414 canvas->save(); 414 canvas->save();
415 canvas->clipRect(SkRect::MakeWH(50, 50)); 415 canvas->clipRect(SkRect::MakeWH(50, 50));
416 416
417 // (12, 13, 38, 37). 417 // (12, 13, 38, 88), since clips are ignored as long as the shape is in the
418 // clip.
418 canvas->drawPath(path, second_paint); 419 canvas->drawPath(path, second_paint);
419 420
420 canvas->restore(); 421 canvas->restore();
421 422
422 skia::RefPtr<SkPicture> picture = 423 skia::RefPtr<SkPicture> picture =
423 skia::AdoptRef(StopRecording(&recorder, canvas)); 424 skia::AdoptRef(StopRecording(&recorder, canvas));
424 425
425 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 426 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
426 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 427 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
427 428
428 EXPECT_EQ(2u, pixel_refs.size()); 429 EXPECT_EQ(2u, pixel_refs.size());
429 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88), 430 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
430 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 431 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
431 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 432 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
432 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 433 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
433 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 37), 434 EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88),
434 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 435 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
435 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__); 436 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__);
436 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 437 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
437 } 438 }
438 439
439 TEST(PixelRefUtilsTest, DrawBitmap) { 440 TEST(PixelRefUtilsTest, DrawBitmap) {
440 gfx::Rect layer_rect(0, 0, 256, 256); 441 gfx::Rect layer_rect(0, 0, 256, 256);
441 442
442 SkPictureRecorder recorder; 443 SkPictureRecorder recorder;
443 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 444 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__); 511 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__);
511 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 512 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
512 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50), 513 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50),
513 gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect)); 514 gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect));
514 VerifyScales(1.f, 1.f, pixel_refs[3].matrix, __LINE__); 515 VerifyScales(1.f, 1.f, pixel_refs[3].matrix, __LINE__);
515 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[3].filter_quality); 516 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[3].filter_quality);
516 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60), 517 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60),
517 gfx::SkRectToRectF(pixel_refs[4].pixel_ref_rect)); 518 gfx::SkRectToRectF(pixel_refs[4].pixel_ref_rect));
518 VerifyScales(5.f, 6.f, pixel_refs[4].matrix, __LINE__); 519 VerifyScales(5.f, 6.f, pixel_refs[4].matrix, __LINE__);
519 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[4].filter_quality); 520 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[4].filter_quality);
520 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 29.403214f, 18.545712f), 521 EXPECT_FLOAT_RECT_EQ(gfx::RectF(-1.8159621f, 0, 31.219175f, 18.545712f),
521 gfx::SkRectToRectF(pixel_refs[5].pixel_ref_rect)); 522 gfx::SkRectToRectF(pixel_refs[5].pixel_ref_rect));
522 VerifyScales(3.3f, 0.4f, pixel_refs[5].matrix, __LINE__); 523 VerifyScales(3.3f, 0.4f, pixel_refs[5].matrix, __LINE__);
523 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[5].filter_quality); 524 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[5].filter_quality);
524 } 525 }
525 526
526 TEST(PixelRefUtilsTest, DrawBitmapRect) { 527 TEST(PixelRefUtilsTest, DrawBitmapRect) {
527 gfx::Rect layer_rect(0, 0, 256, 256); 528 gfx::Rect layer_rect(0, 0, 256, 256);
528 529
529 SkPictureRecorder recorder; 530 SkPictureRecorder recorder;
530 SkCanvas* canvas = StartRecording(&recorder, layer_rect); 531 SkCanvas* canvas = StartRecording(&recorder, layer_rect);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 points, 731 points,
731 colors, 732 colors,
732 NULL, 733 NULL,
733 indecies, 734 indecies,
734 3, 735 3,
735 first_paint); 736 first_paint);
736 737
737 canvas->save(); 738 canvas->save();
738 739
739 canvas->clipRect(SkRect::MakeWH(50, 50)); 740 canvas->clipRect(SkRect::MakeWH(50, 50));
740 // (10, 10, 40, 40). 741 // (10, 10, 90, 90), since clips are ignored as long as the draw object is
742 // within clip.
741 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, 743 canvas->drawVertices(SkCanvas::kTriangles_VertexMode,
742 3, 744 3,
743 points, 745 points,
744 points, 746 points,
745 colors, 747 colors,
746 NULL, 748 NULL,
747 indecies, 749 indecies,
748 3, 750 3,
749 second_paint); 751 second_paint);
750 752
(...skipping 17 matching lines...) Expand all
768 skia::AdoptRef(StopRecording(&recorder, canvas)); 770 skia::AdoptRef(StopRecording(&recorder, canvas));
769 771
770 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; 772 std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
771 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); 773 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
772 774
773 EXPECT_EQ(3u, pixel_refs.size()); 775 EXPECT_EQ(3u, pixel_refs.size());
774 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), 776 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
775 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); 777 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect));
776 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__); 778 VerifyScales(1.f, 1.f, pixel_refs[0].matrix, __LINE__);
777 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality); 779 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[0].filter_quality);
778 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), 780 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90),
779 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); 781 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
780 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__); 782 VerifyScales(1.f, 1.f, pixel_refs[1].matrix, __LINE__);
781 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality); 783 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[1].filter_quality);
782 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), 784 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145),
783 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); 785 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
784 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__); 786 VerifyScales(1.f, 1.f, pixel_refs[2].matrix, __LINE__);
785 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality); 787 EXPECT_EQ(kNone_SkFilterQuality, pixel_refs[2].filter_quality);
786 } 788 }
787 789
788 } // namespace skia 790 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/pixel_ref_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698