Chromium Code Reviews| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 buffer.writeBool(fModes != NULL); | 151 buffer.writeBool(fModes != NULL); |
| 151 if (fModes) { | 152 if (fModes) { |
| 152 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); | 153 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI TED(buffer) { | 157 SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) : INHERI TED(buffer) { |
| 157 bool hasModes = buffer.readBool(); | 158 bool hasModes = buffer.readBool(); |
| 158 if (hasModes) { | 159 if (hasModes) { |
| 159 this->initAllocModes(); | 160 this->initAllocModes(); |
| 160 SkASSERT(buffer.getArrayCount() == countInputs() * sizeof(fModes[0])); | 161 int nbInputs = countInputs(); |
| 162 SkASSERT(buffer.getArrayCount() == nbInputs * sizeof(fModes[0])); | |
|
Stephen White
2013/09/09 17:43:00
Should this also be validated, or is asserting goo
| |
| 161 buffer.readByteArray(fModes); | 163 buffer.readByteArray(fModes); |
| 164 for (int i = 0; i < nbInputs; ++i) { | |
| 165 buffer.validateData(SkIsValidMode((SkXfermode::Mode)fModes[i])); | |
| 166 } | |
| 162 } else { | 167 } else { |
| 163 fModes = 0; | 168 fModes = 0; |
| 164 } | 169 } |
| 165 } | 170 } |
| OLD | NEW |