OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "Test.h" | 7 #include "Test.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 { | 442 { |
443 // Test without call to endRecording | 443 // Test without call to endRecording |
444 SkPicture picture; | 444 SkPicture picture; |
445 picture.beginRecording(1, 1); | 445 picture.beginRecording(1, 1); |
446 SkPicture* destPicture = picture.clone(); | 446 SkPicture* destPicture = picture.clone(); |
447 REPORTER_ASSERT(reporter, NULL != destPicture); | 447 REPORTER_ASSERT(reporter, NULL != destPicture); |
448 destPicture->unref(); | 448 destPicture->unref(); |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
| 452 static void test_subregion_playback(skiatest::Reporter* reporter) { |
| 453 // This test verifies early content clipping based on encoded bounds |
| 454 // in SkPicture playback. We verify that content will properly propagate |
| 455 // to the destination canvas in the case where the recorded content is |
| 456 // outside the bounds of the playback canvas, but is brought in-bounds by |
| 457 // a pre-playback transform that is applied to the destination canvas. |
| 458 // In other words, we are verifying that clipping optimizations are |
| 459 // handled in matching frames of reference. |
| 460 SkPicture picture; |
| 461 SkCanvas* recordingCanvas = picture.beginRecording(10, 10); |
| 462 SkPaint paint; |
| 463 paint.setColor(SK_ColorWHITE); |
| 464 SkRect rect = SkRect::MakeXYWH(SkIntToScalar(8), SkIntToScalar(8), SK_Scalar
1, SK_Scalar1); |
| 465 recordingCanvas->drawRect(rect, paint); |
| 466 picture.endRecording(); |
| 467 SkBitmap store; |
| 468 store.setConfig(SkBitmap::kARGB_8888_Config, 3, 3); |
| 469 store.allocPixels(); |
| 470 SkCanvas playbackCanvas(store); |
| 471 playbackCanvas.clear(SK_ColorTRANSPARENT); |
| 472 playbackCanvas.translate(SkIntToScalar(-7), SkIntToScalar(-7)); |
| 473 playbackCanvas.drawPicture(picture); |
| 474 for (int x = 0; x < 3; x++) { |
| 475 for (int y = 0; y < 3; y++) { |
| 476 if (1 == x && 1 == y) { |
| 477 REPORTER_ASSERT(reporter, SK_ColorWHITE == store.getColor(x,y)); |
| 478 } else { |
| 479 REPORTER_ASSERT(reporter, SK_ColorTRANSPARENT == store.getColor(
x,y)); |
| 480 } |
| 481 } |
| 482 } |
| 483 } |
| 484 |
452 static void test_clip_bound_opt(skiatest::Reporter* reporter) { | 485 static void test_clip_bound_opt(skiatest::Reporter* reporter) { |
453 // Test for crbug.com/229011 | 486 // Test for crbug.com/229011 |
454 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), | 487 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), |
455 SkIntToScalar(2), SkIntToScalar(2)); | 488 SkIntToScalar(2), SkIntToScalar(2)); |
456 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), | 489 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), |
457 SkIntToScalar(1), SkIntToScalar(1)); | 490 SkIntToScalar(1), SkIntToScalar(1)); |
458 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6), | 491 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6), |
459 SkIntToScalar(1), SkIntToScalar(1)); | 492 SkIntToScalar(1), SkIntToScalar(1)); |
460 | 493 |
461 SkPath invPath; | 494 SkPath invPath; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 #ifdef SK_DEBUG | 585 #ifdef SK_DEBUG |
553 test_deleting_empty_playback(); | 586 test_deleting_empty_playback(); |
554 test_serializing_empty_picture(); | 587 test_serializing_empty_picture(); |
555 #else | 588 #else |
556 test_bad_bitmap(); | 589 test_bad_bitmap(); |
557 #endif | 590 #endif |
558 test_peephole(); | 591 test_peephole(); |
559 test_gatherpixelrefs(reporter); | 592 test_gatherpixelrefs(reporter); |
560 test_bitmap_with_encoded_data(reporter); | 593 test_bitmap_with_encoded_data(reporter); |
561 test_clone_empty(reporter); | 594 test_clone_empty(reporter); |
| 595 test_subregion_playback(reporter); |
562 test_clip_bound_opt(reporter); | 596 test_clip_bound_opt(reporter); |
563 } | 597 } |
564 | 598 |
565 #include "TestClassDef.h" | 599 #include "TestClassDef.h" |
566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 600 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
OLD | NEW |