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

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

Issue 37803002: Adding size parameter to read array functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed comments 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
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"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698