| 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" |
| 11 #include "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
| 12 #include "SkValidationUtils.h" |
| 12 | 13 |
| 13 /////////////////////////////////////////////////////////////////////////////// | 14 /////////////////////////////////////////////////////////////////////////////// |
| 14 | 15 |
| 15 void SkMergeImageFilter::initAllocModes() { | 16 void SkMergeImageFilter::initAllocModes() { |
| 16 int inputCount = countInputs(); | 17 int inputCount = countInputs(); |
| 17 if (inputCount) { | 18 if (inputCount) { |
| 18 size_t size = sizeof(uint8_t) * inputCount; | 19 size_t size = sizeof(uint8_t) * inputCount; |
| 19 if (size <= sizeof(fStorage)) { | 20 if (size <= sizeof(fStorage)) { |
| 20 fModes = SkTCast<uint8_t*>(fStorage); | 21 fModes = SkTCast<uint8_t*>(fStorage); |
| 21 } else { | 22 } else { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 buffer.writeBool(fModes != NULL); | 153 buffer.writeBool(fModes != NULL); |
| 153 if (fModes) { | 154 if (fModes) { |
| 154 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); | 155 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); |
| 155 } | 156 } |
| 156 } | 157 } |
| 157 | 158 |
| 158 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI
TED(buffer) { | 159 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI
TED(buffer) { |
| 159 bool hasModes = buffer.readBool(); | 160 bool hasModes = buffer.readBool(); |
| 160 if (hasModes) { | 161 if (hasModes) { |
| 161 this->initAllocModes(); | 162 this->initAllocModes(); |
| 162 SkASSERT(buffer.getArrayCount() == countInputs() * sizeof(fModes[0])); | 163 int nbInputs = countInputs(); |
| 164 SkASSERT(buffer.getArrayCount() == nbInputs * sizeof(fModes[0])); |
| 163 buffer.readByteArray(fModes); | 165 buffer.readByteArray(fModes); |
| 166 for (int i = 0; i < nbInputs; ++i) { |
| 167 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); |
| 168 } |
| 164 } else { | 169 } else { |
| 165 fModes = 0; | 170 fModes = 0; |
| 166 } | 171 } |
| 167 } | 172 } |
| OLD | NEW |