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 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 SkPictureImageFilter::~SkPictureImageFilter() { | 34 SkPictureImageFilter::~SkPictureImageFilter() { |
35 SkSafeUnref(fPicture); | 35 SkSafeUnref(fPicture); |
36 } | 36 } |
37 | 37 |
38 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { | 38 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { |
39 SkAutoTUnref<SkPicture> picture; | 39 SkAutoTUnref<SkPicture> picture; |
40 SkRect cropRect; | 40 SkRect cropRect; |
41 | 41 |
42 if (!buffer.isCrossProcess()) { | 42 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS |
| 43 if (buffer.isCrossProcess()) { |
| 44 buffer.validate(!buffer.readBool()); |
| 45 } else |
| 46 #endif |
| 47 { |
43 if (buffer.readBool()) { | 48 if (buffer.readBool()) { |
44 picture.reset(SkPicture::CreateFromBuffer(buffer)); | 49 picture.reset(SkPicture::CreateFromBuffer(buffer)); |
45 } | 50 } |
46 } else { | |
47 buffer.validate(!buffer.readBool()); | |
48 } | 51 } |
49 buffer.readRect(&cropRect); | 52 buffer.readRect(&cropRect); |
50 PictureResolution pictureResolution; | 53 PictureResolution pictureResolution; |
51 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version))
{ | 54 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version))
{ |
52 pictureResolution = kDeviceSpace_PictureResolution; | 55 pictureResolution = kDeviceSpace_PictureResolution; |
53 } else { | 56 } else { |
54 pictureResolution = (PictureResolution)buffer.readInt(); | 57 pictureResolution = (PictureResolution)buffer.readInt(); |
55 } | 58 } |
56 | 59 |
57 if (kLocalSpace_PictureResolution == pictureResolution) { | 60 if (kLocalSpace_PictureResolution == pictureResolution) { |
58 //filterLevel is only serialized if pictureResolution is LocalSpace | 61 //filterLevel is only serialized if pictureResolution is LocalSpace |
59 SkPaint::FilterLevel filterLevel; | 62 SkPaint::FilterLevel filterLevel; |
60 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version))
{ | 63 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version))
{ |
61 filterLevel = SkPaint::kLow_FilterLevel; | 64 filterLevel = SkPaint::kLow_FilterLevel; |
62 } else { | 65 } else { |
63 filterLevel = (SkPaint::FilterLevel)buffer.readInt(); | 66 filterLevel = (SkPaint::FilterLevel)buffer.readInt(); |
64 } | 67 } |
65 return CreateForLocalSpace(picture, cropRect, filterLevel); | 68 return CreateForLocalSpace(picture, cropRect, filterLevel); |
66 } | 69 } |
67 return Create(picture, cropRect); | 70 return Create(picture, cropRect); |
68 } | 71 } |
69 | 72 |
70 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { | 73 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { |
71 if (!buffer.isCrossProcess()) { | 74 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS |
| 75 if (buffer.isCrossProcess()) { |
| 76 buffer.writeBool(false); |
| 77 } else |
| 78 #endif |
| 79 { |
72 bool hasPicture = (fPicture != NULL); | 80 bool hasPicture = (fPicture != NULL); |
73 buffer.writeBool(hasPicture); | 81 buffer.writeBool(hasPicture); |
74 if (hasPicture) { | 82 if (hasPicture) { |
75 fPicture->flatten(buffer); | 83 fPicture->flatten(buffer); |
76 } | 84 } |
77 } else { | |
78 buffer.writeBool(false); | |
79 } | 85 } |
80 buffer.writeRect(fCropRect); | 86 buffer.writeRect(fCropRect); |
81 buffer.writeInt(fPictureResolution); | 87 buffer.writeInt(fPictureResolution); |
82 if (kLocalSpace_PictureResolution == fPictureResolution) { | 88 if (kLocalSpace_PictureResolution == fPictureResolution) { |
83 buffer.writeInt(fFilterLevel); | 89 buffer.writeInt(fFilterLevel); |
84 } | 90 } |
85 } | 91 } |
86 | 92 |
87 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, | 93 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, |
88 SkBitmap* result, SkIPoint* offset) con
st { | 94 SkBitmap* result, SkIPoint* offset) con
st { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 str->appendf("crop: (%f,%f,%f,%f) ", | 180 str->appendf("crop: (%f,%f,%f,%f) ", |
175 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); | 181 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); |
176 if (fPicture) { | 182 if (fPicture) { |
177 str->appendf("picture: (%f,%f,%f,%f)", | 183 str->appendf("picture: (%f,%f,%f,%f)", |
178 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, | 184 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, |
179 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); | 185 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); |
180 } | 186 } |
181 str->append(")"); | 187 str->append(")"); |
182 } | 188 } |
183 #endif | 189 #endif |
OLD | NEW |