aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-07 02:09:50 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-07 02:09:50 +0000
commit4f6318d2e64c96fba955ea9154829aee37e155b8 (patch)
tree844e218de608a5f157b71d82aba618b568b5616a /samplecode
parent70ac79b754aa6416a2bf7995792eaf07801dd76c (diff)
Serialization of SkPictureImageFilter
BUG=skia: Committed: http://code.google.com/p/skia/source/detail?r=13347 R=senorblanco@google.com, reed@google.com, mtklein@google.com, sugoi@google.com, senorblanco@chromium.org, robertphillips@google.com, scroggo@google.com Author: sugoi@chromium.org Review URL: https://codereview.chromium.org/138063005 git-svn-id: http://skia.googlecode.com/svn/trunk@13354 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleFilterFuzz.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index f77f3b814d..4ef7d4033a 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -184,6 +184,30 @@ static const SkBitmap& make_bitmap() {
return bitmap[R(2)];
}
+#ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION
+static void drawSomething(SkCanvas* canvas) {
+ SkPaint paint;
+
+ canvas->save();
+ canvas->scale(0.5f, 0.5f);
+ canvas->drawBitmap(make_bitmap(), 0, 0, NULL);
+ canvas->restore();
+
+ const char beforeStr[] = "before circle";
+ const char afterStr[] = "after circle";
+
+ paint.setAntiAlias(true);
+
+ paint.setColor(SK_ColorRED);
+ canvas->drawData(beforeStr, sizeof(beforeStr));
+ canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint);
+ canvas->drawData(afterStr, sizeof(afterStr));
+ paint.setColor(SK_ColorBLACK);
+ paint.setTextSize(SkIntToScalar(kBitmapSize/3));
+ canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint);
+}
+#endif
+
static SkImageFilter* make_image_filter(bool canBeNull = true) {
SkImageFilter* filter = 0;
@@ -294,7 +318,16 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
filter = new SkTileImageFilter(make_rect(), make_rect(), make_image_filter(false));
break;
case PICTURE:
- filter = new SkPictureImageFilter(NULL, make_rect());
+ {
+ SkPicture* pict = NULL;
+#ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION
+ pict = new SkPicture;
+ SkAutoUnref aur(pict);
+ drawSomething(pict->beginRecording(kBitmapSize, kBitmapSize));
+ pict->endRecording();
+#endif
+ filter = new SkPictureImageFilter(pict, make_rect());
+ }
break;
default:
break;