Require explicit disabling of cross process pictureimagefilters

This is to allow capturing .skp files with their pictureimagefilters intact.

This is a companion to https://codereview.chromium.org/810933004/ (Provide a way of allowing cross process pictureimagefilters).

Review URL: https://codereview.chromium.org/834673006
This commit is contained in:
robertphillips 2015-01-06 09:17:02 -08:00 committed by Commit bot
parent 3f4e045b4f
commit c4bd39c903
2 changed files with 16 additions and 6 deletions

View File

@ -39,12 +39,15 @@ SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
SkAutoTUnref<SkPicture> picture;
SkRect cropRect;
if (!buffer.isCrossProcess()) {
#ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
if (buffer.isCrossProcess()) {
buffer.validate(!buffer.readBool());
} else
#endif
{
if (buffer.readBool()) {
picture.reset(SkPicture::CreateFromBuffer(buffer));
}
} else {
buffer.validate(!buffer.readBool());
}
buffer.readRect(&cropRect);
PictureResolution pictureResolution;
@ -68,14 +71,17 @@ SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
}
void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
if (!buffer.isCrossProcess()) {
#ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
if (buffer.isCrossProcess()) {
buffer.writeBool(false);
} else
#endif
{
bool hasPicture = (fPicture != NULL);
buffer.writeBool(hasPicture);
if (hasPicture) {
fPicture->flatten(buffer);
}
} else {
buffer.writeBool(false);
}
buffer.writeRect(fCropRect);
buffer.writeInt(fPictureResolution);

View File

@ -802,8 +802,12 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
canvas.clear(0x0);
canvas.drawPicture(crossProcessPicture);
pixel = *bitmap.getAddr32(0, 0);
#ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
// The result here should not be green, since the filter draws nothing.
REPORTER_ASSERT(reporter, pixel != SK_ColorGREEN);
#else
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
#endif
}
DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {