Chromium Code Reviews| Index: tests/PictureTest.cpp |
| =================================================================== |
| --- tests/PictureTest.cpp (revision 8043) |
| +++ tests/PictureTest.cpp (working copy) |
| @@ -8,6 +8,7 @@ |
| #include "SkCanvas.h" |
| #include "SkColorPriv.h" |
| #include "SkData.h" |
| +#include "SkDevice.h" |
| #include "SkPaint.h" |
| #include "SkPicture.h" |
| #include "SkRandom.h" |
| @@ -419,6 +420,33 @@ |
| } |
| } |
| +static void test_subregion_playback(skiatest::Reporter* reporter) { |
|
reed1
2013/03/12 16:05:04
Can you simplify or document the complexity in thi
|
| + SkPicture picture; |
| + SkCanvas* recordingCanvas = picture.beginRecording(6, 6); |
| + SkPaint paint; |
| + paint.setColor(SK_ColorWHITE); |
| + SkRect rect = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), SK_Scalar1, SK_Scalar1); |
| + recordingCanvas->clear(SK_ColorTRANSPARENT); |
| + recordingCanvas->drawRect(rect, paint); |
| + picture.endRecording(); |
| + SkBitmap store; |
| + store.setConfig(SkBitmap::kARGB_8888_Config, 3, 3); |
| + store.allocPixels(); |
| + SkDevice device(store); |
|
reed1
2013/03/12 16:05:04
minor, but can't you just pass store to the canvas
|
| + SkCanvas playbackCanvas(&device); |
| + playbackCanvas.translate(SkIntToScalar(-3), SkIntToScalar(-3)); |
| + playbackCanvas.drawPicture(picture); |
| + for (int x = 0; x < 3; x++) { |
| + for (int y = 0; y < 3; y++) { |
| + if (1 == x && 1 == y) { |
| + REPORTER_ASSERT(reporter, SK_ColorWHITE == store.getColor(x,y)); |
| + } else { |
| + REPORTER_ASSERT(reporter, SK_ColorTRANSPARENT == store.getColor(x,y)); |
| + } |
| + } |
| + } |
| +} |
| + |
| static void TestPicture(skiatest::Reporter* reporter) { |
| #ifdef SK_DEBUG |
| test_deleting_empty_playback(); |
| @@ -430,6 +458,7 @@ |
| test_gatherpixelrefs(reporter); |
| test_bitmap_with_encoded_data(reporter); |
| test_clone_empty(reporter); |
| + test_subregion_playback(reporter); |
| } |
| #include "TestClassDef.h" |