| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 The Android Open Source Project |
| 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 | 7 |
| 8 #include "SkPictureImageFilter.h" | 8 #include "SkPictureImageFilter.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 SkSafeRef(fPicture); | 27 SkSafeRef(fPicture); |
| 28 } | 28 } |
| 29 | 29 |
| 30 SkPictureImageFilter::~SkPictureImageFilter() { | 30 SkPictureImageFilter::~SkPictureImageFilter() { |
| 31 SkSafeUnref(fPicture); | 31 SkSafeUnref(fPicture); |
| 32 } | 32 } |
| 33 | 33 |
| 34 SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer) | 34 SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer) |
| 35 : INHERITED(0, buffer), | 35 : INHERITED(0, buffer), |
| 36 fPicture(NULL) { | 36 fPicture(NULL) { |
| 37 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION | 37 if (!buffer.isCrossProcess()) { |
| 38 if (buffer.readBool()) { | 38 if (buffer.readBool()) { |
| 39 fPicture = SkPicture::CreateFromBuffer(buffer); | 39 fPicture = SkPicture::CreateFromBuffer(buffer); |
| 40 } |
| 41 } else { |
| 42 buffer.validate(!buffer.readBool()); |
| 40 } | 43 } |
| 41 #else | |
| 42 buffer.readBool(); | |
| 43 #endif | |
| 44 buffer.readRect(&fCropRect); | 44 buffer.readRect(&fCropRect); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { | 47 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 48 this->INHERITED::flatten(buffer); | 48 this->INHERITED::flatten(buffer); |
| 49 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION | 49 if (!buffer.isCrossProcess()) { |
| 50 bool hasPicture = (fPicture != NULL); | 50 bool hasPicture = (fPicture != NULL); |
| 51 buffer.writeBool(hasPicture); | 51 buffer.writeBool(hasPicture); |
| 52 if (hasPicture) { | 52 if (hasPicture) { |
| 53 fPicture->flatten(buffer); | 53 fPicture->flatten(buffer); |
| 54 } |
| 55 } else { |
| 56 buffer.writeBool(false); |
| 54 } | 57 } |
| 55 #else | |
| 56 buffer.writeBool(false); | |
| 57 #endif | |
| 58 buffer.writeRect(fCropRect); | 58 buffer.writeRect(fCropRect); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, | 61 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, |
| 62 SkBitmap* result, SkIPoint* offset) con
st { | 62 SkBitmap* result, SkIPoint* offset) con
st { |
| 63 if (!fPicture) { | 63 if (!fPicture) { |
| 64 offset->fX = offset->fY = 0; | 64 offset->fX = offset->fY = 0; |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 92 offset->fY = bounds.fTop; | 92 offset->fY = bounds.fTop; |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool SkPictureImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ct
m, | 96 bool SkPictureImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ct
m, |
| 97 SkIRect* dst) const { | 97 SkIRect* dst) const { |
| 98 *dst = src; | 98 *dst = src; |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| OLD | NEW |