OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 SkSafeRef(fInputs[1]); | 46 SkSafeRef(fInputs[1]); |
47 } | 47 } |
48 | 48 |
49 SkImageFilter::~SkImageFilter() { | 49 SkImageFilter::~SkImageFilter() { |
50 for (int i = 0; i < fInputCount; i++) { | 50 for (int i = 0; i < fInputCount; i++) { |
51 SkSafeUnref(fInputs[i]); | 51 SkSafeUnref(fInputs[i]); |
52 } | 52 } |
53 delete[] fInputs; | 53 delete[] fInputs; |
54 } | 54 } |
55 | 55 |
56 SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer) | 56 SkImageFilter::SkImageFilter(int maxInputCount, SkFlattenableReadBuffer& buffer)
{ |
57 : fInputCount(buffer.readInt()), fInputs(new SkImageFilter*[fInputCount]) { | 57 fInputCount = buffer.readInt(); |
58 for (int i = 0; i < fInputCount; i++) { | 58 if (buffer.validate((fInputCount >= 0) && (fInputCount <= maxInputCount))) { |
59 if (buffer.readBool()) { | 59 fInputs = new SkImageFilter*[fInputCount]; |
60 fInputs[i] = buffer.readImageFilter(); | 60 for (int i = 0; i < fInputCount; i++) { |
61 } else { | 61 if (buffer.readBool()) { |
62 fInputs[i] = NULL; | 62 fInputs[i] = buffer.readImageFilter(); |
| 63 } else { |
| 64 fInputs[i] = NULL; |
| 65 } |
63 } | 66 } |
| 67 SkRect rect; |
| 68 buffer.readRect(&rect); |
| 69 if (buffer.validate(SkIsValidRect(rect))) { |
| 70 uint32_t flags = buffer.readUInt(); |
| 71 fCropRect = CropRect(rect, flags); |
| 72 } |
| 73 } else { |
| 74 fInputCount = 0; |
| 75 fInputs = NULL; |
64 } | 76 } |
65 SkRect rect; | |
66 buffer.readRect(&rect); | |
67 uint32_t flags = buffer.readUInt(); | |
68 fCropRect = CropRect(rect, flags); | |
69 buffer.validate(SkIsValidRect(rect)); | |
70 } | 77 } |
71 | 78 |
72 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 79 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
73 buffer.writeInt(fInputCount); | 80 buffer.writeInt(fInputCount); |
74 for (int i = 0; i < fInputCount; i++) { | 81 for (int i = 0; i < fInputCount; i++) { |
75 SkImageFilter* input = getInput(i); | 82 SkImageFilter* input = getInput(i); |
76 buffer.writeBool(input != NULL); | 83 buffer.writeBool(input != NULL); |
77 if (input != NULL) { | 84 if (input != NULL) { |
78 buffer.writeFlattenable(input); | 85 buffer.writeFlattenable(input); |
79 } | 86 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 return true; | 187 return true; |
181 } | 188 } |
182 | 189 |
183 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { | 190 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { |
184 return false; | 191 return false; |
185 } | 192 } |
186 | 193 |
187 bool SkImageFilter::asColorFilter(SkColorFilter**) const { | 194 bool SkImageFilter::asColorFilter(SkColorFilter**) const { |
188 return false; | 195 return false; |
189 } | 196 } |
OLD | NEW |