Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: src/effects/SkMergeImageFilter.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adapting code to sk_once changes Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698