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 "SkMergeImageFilter.h" | 8 #include "SkMergeImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 if (fModes) { | 154 if (fModes) { |
155 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); | 155 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI
TED(buffer) { | 159 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI
TED(buffer) { |
160 bool hasModes = buffer.readBool(); | 160 bool hasModes = buffer.readBool(); |
161 if (hasModes) { | 161 if (hasModes) { |
162 this->initAllocModes(); | 162 this->initAllocModes(); |
163 int nbInputs = countInputs(); | 163 int nbInputs = countInputs(); |
164 bool sizeMatches = buffer.getArrayCount() == nbInputs * sizeof(fModes[0]
); | 164 size_t size = nbInputs * sizeof(fModes[0]); |
165 buffer.validate(sizeMatches); | 165 SkASSERT(buffer.getArrayCount() == size); |
166 SkASSERT(sizeMatches); | 166 buffer.readByteArray(fModes, size); |
167 buffer.readByteArray(fModes); | |
168 for (int i = 0; i < nbInputs; ++i) { | 167 for (int i = 0; i < nbInputs; ++i) { |
169 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); | 168 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); |
170 } | 169 } |
171 } else { | 170 } else { |
172 fModes = 0; | 171 fModes = 0; |
173 } | 172 } |
174 } | 173 } |
OLD | NEW |