diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 20:50:56 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 20:50:56 +0000 |
commit | 97f5fc651956287e78e35934cf62b9e1b45b4f6c (patch) | |
tree | 9aed84527f56452f05442457830ac30f0ef2ba6d /samplecode | |
parent | 1fd263edb3bac44c8921bd34590bbc57fb348001 (diff) |
Allow SkPictureImageFilter to be serialized when not run cross-process.
Picture serialization is not yet hardened, but it turns out we do need
serialization of SkPictureImageFilter for deferred SVG-on-SVG filters,
since the SkPaints (and thus the SkImageFilters) are serialized by
SkPictureRecord. However, deferred filters are always drawn in the
same process, so we can safely serialize them in this case. We do this
by turning the compile-time check for
SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION to a runtime check for
isCrossProcess().
The image filter fuzzer sample was also modified to enable fuzzing
of basic picture image filters (the code had rotted a bit, being behind
an #ifdef that no one sets).
BUG=375162
R=sugoi@google.com
Review URL: https://codereview.chromium.org/311443003
git-svn-id: http://skia.googlecode.com/svn/trunk@15008 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleFilterFuzz.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 0cba43c266..7f4c2474fc 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -27,6 +27,7 @@ #include "SkOffsetImageFilter.h" #include "SkPerlinNoiseShader.h" #include "SkPictureImageFilter.h" +#include "SkPictureRecorder.h" #include "SkRandom.h" #include "SkRectShaderImageFilter.h" #include "SkTestImageFilters.h" @@ -206,7 +207,6 @@ static const SkBitmap& make_bitmap() { return bitmap[R(2)]; } -#ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION static void drawSomething(SkCanvas* canvas) { SkPaint paint; @@ -228,7 +228,6 @@ static void drawSomething(SkCanvas* canvas) { 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; @@ -376,14 +375,12 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) { break; case PICTURE: { - SkPicture* pict = NULL; -#ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION - pict = new SkPicture; - SkAutoUnref aur(pict); - drawSomething(pict->beginRecording(kBitmapSize, kBitmapSize)); - pict->endRecording(); -#endif - filter = SkPictureImageFilter::Create(pict, make_rect()); + SkRTreeFactory factory; + SkPictureRecorder recorder; + SkCanvas* recordingCanvas = recorder.beginRecording(kBitmapSize, kBitmapSize, &factory, 0); + drawSomething(recordingCanvas); + SkAutoTUnref<SkPicture> pict(recorder.endRecording()); + filter = SkPictureImageFilter::Create(pict.get(), make_rect()); } break; default: |