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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { | 54 SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { |
55 fInputCount = buffer.readInt(); | 55 fInputCount = buffer.readInt(); |
56 if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount
== inputCount)))) { | 56 if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount
== inputCount)))) { |
57 fInputs = new SkImageFilter*[fInputCount]; | 57 fInputs = new SkImageFilter*[fInputCount]; |
58 for (int i = 0; i < fInputCount; i++) { | 58 for (int i = 0; i < fInputCount; i++) { |
59 if (buffer.readBool()) { | 59 if (buffer.readBool()) { |
60 fInputs[i] = buffer.readImageFilter(); | 60 fInputs[i] = buffer.readImageFilter(); |
61 } else { | 61 } else { |
62 fInputs[i] = NULL; | 62 fInputs[i] = NULL; |
63 } | 63 } |
| 64 if (!buffer.isValid()) { |
| 65 fInputCount = i; // Do not use fInputs past that point in the de
structor |
| 66 break; |
| 67 } |
64 } | 68 } |
65 SkRect rect; | 69 SkRect rect; |
66 buffer.readRect(&rect); | 70 buffer.readRect(&rect); |
67 if (buffer.validate(SkIsValidRect(rect))) { | 71 if (buffer.isValid() && buffer.validate(SkIsValidRect(rect))) { |
68 uint32_t flags = buffer.readUInt(); | 72 uint32_t flags = buffer.readUInt(); |
69 fCropRect = CropRect(rect, flags); | 73 fCropRect = CropRect(rect, flags); |
70 } | 74 } |
71 } else { | 75 } else { |
72 fInputCount = 0; | 76 fInputCount = 0; |
73 fInputs = NULL; | 77 fInputs = NULL; |
74 } | 78 } |
75 } | 79 } |
76 | 80 |
77 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 81 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 return true; | 189 return true; |
186 } | 190 } |
187 | 191 |
188 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { | 192 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { |
189 return false; | 193 return false; |
190 } | 194 } |
191 | 195 |
192 bool SkImageFilter::asColorFilter(SkColorFilter**) const { | 196 bool SkImageFilter::asColorFilter(SkColorFilter**) const { |
193 return false; | 197 return false; |
194 } | 198 } |
OLD | NEW |