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 // FIXME: unflatten picture here. | 37 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION |
38 if (buffer.readBool()) { | |
39 fPicture = SkPicture::CreateFromBuffer(buffer); | |
40 } | |
41 #endif | |
38 buffer.readRect(&fRect); | 42 buffer.readRect(&fRect); |
39 } | 43 } |
40 | 44 |
41 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { | 45 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { |
42 this->INHERITED::flatten(buffer); | 46 this->INHERITED::flatten(buffer); |
43 // FIXME: flatten picture here. | 47 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION |
48 bool hasPicture = (fPicture != NULL); | |
49 buffer.writeBool(hasPicture); | |
Stephen White
2014/02/05 16:44:39
Maybe we should just writeBool(false) (and readBoo
sugoi1
2014/02/05 16:48:58
Good idea, I'll do that.
| |
50 if (hasPicture) { | |
51 fPicture->flatten(buffer); | |
52 } | |
53 #endif | |
44 buffer.writeRect(fRect); | 54 buffer.writeRect(fRect); |
45 } | 55 } |
46 | 56 |
47 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix, | 57 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix, |
48 SkBitmap* result, SkIPoint* offset) { | 58 SkBitmap* result, SkIPoint* offset) { |
49 if (!fPicture) { | 59 if (!fPicture) { |
50 offset->fX = offset->fY = 0; | 60 offset->fX = offset->fY = 0; |
51 return true; | 61 return true; |
52 } | 62 } |
53 | 63 |
(...skipping 17 matching lines...) Expand all Loading... | |
71 | 81 |
72 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 82 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
73 canvas.concat(matrix); | 83 canvas.concat(matrix); |
74 canvas.drawPicture(*fPicture); | 84 canvas.drawPicture(*fPicture); |
75 | 85 |
76 *result = device.get()->accessBitmap(false); | 86 *result = device.get()->accessBitmap(false); |
77 offset->fX = bounds.fLeft; | 87 offset->fX = bounds.fLeft; |
78 offset->fY = bounds.fTop; | 88 offset->fY = bounds.fTop; |
79 return true; | 89 return true; |
80 } | 90 } |
OLD | NEW |