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" |
11 #include "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
| 13 #include "SkValidationUtils.h" |
13 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
14 #include "GrContext.h" | 15 #include "GrContext.h" |
15 #include "GrTexture.h" | 16 #include "GrTexture.h" |
16 #include "SkImageFilterUtils.h" | 17 #include "SkImageFilterUtils.h" |
17 #endif | 18 #endif |
18 | 19 |
19 SK_DEFINE_INST_COUNT(SkImageFilter) | 20 SK_DEFINE_INST_COUNT(SkImageFilter) |
20 | 21 |
21 SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropR
ect* cropRect) | 22 SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropR
ect* cropRect) |
22 : fInputCount(inputCount), | 23 : fInputCount(inputCount), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (buffer.readBool()) { | 59 if (buffer.readBool()) { |
59 fInputs[i] = buffer.readImageFilter(); | 60 fInputs[i] = buffer.readImageFilter(); |
60 } else { | 61 } else { |
61 fInputs[i] = NULL; | 62 fInputs[i] = NULL; |
62 } | 63 } |
63 } | 64 } |
64 SkRect rect; | 65 SkRect rect; |
65 buffer.readRect(&rect); | 66 buffer.readRect(&rect); |
66 uint32_t flags = buffer.readUInt(); | 67 uint32_t flags = buffer.readUInt(); |
67 fCropRect = CropRect(rect, flags); | 68 fCropRect = CropRect(rect, flags); |
| 69 buffer.validate(SkIsValidRect(rect)); |
68 } | 70 } |
69 | 71 |
70 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 72 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
71 buffer.writeInt(fInputCount); | 73 buffer.writeInt(fInputCount); |
72 for (int i = 0; i < fInputCount; i++) { | 74 for (int i = 0; i < fInputCount; i++) { |
73 SkImageFilter* input = getInput(i); | 75 SkImageFilter* input = getInput(i); |
74 buffer.writeBool(input != NULL); | 76 buffer.writeBool(input != NULL); |
75 if (input != NULL) { | 77 if (input != NULL) { |
76 buffer.writeFlattenable(input); | 78 buffer.writeFlattenable(input); |
77 } | 79 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return true; | 180 return true; |
179 } | 181 } |
180 | 182 |
181 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { | 183 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { |
182 return false; | 184 return false; |
183 } | 185 } |
184 | 186 |
185 bool SkImageFilter::asColorFilter(SkColorFilter**) const { | 187 bool SkImageFilter::asColorFilter(SkColorFilter**) const { |
186 return false; | 188 return false; |
187 } | 189 } |
OLD | NEW |