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

Side by Side Diff: src/core/SkValidatingReadBuffer.cpp

Issue 195223003: Fixing SkPicture serialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed nits Created 6 years, 9 months 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
« no previous file with comments | « src/core/SkValidatingReadBuffer.h ('k') | src/ports/SkGlobalInitialization_chromium.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkValidatingReadBuffer.h" 10 #include "SkValidatingReadBuffer.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 uint32_t SkValidatingReadBuffer::getArrayCount() { 207 uint32_t SkValidatingReadBuffer::getArrayCount() {
208 const size_t inc = sizeof(uint32_t); 208 const size_t inc = sizeof(uint32_t);
209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ; 209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ;
210 return fError ? 0 : *(uint32_t*)fReader.peek(); 210 return fError ? 0 : *(uint32_t*)fReader.peek();
211 } 211 }
212 212
213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { 213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) {
214 const int width = this->readInt(); 214 const int width = this->readInt();
215 const int height = this->readInt(); 215 const int height = this->readInt();
216 const bool useBitmapHeap = this->readBool();
216 const size_t length = this->readUInt(); 217 const size_t length = this->readUInt();
217 // A size of zero means the SkBitmap was simply flattened. 218 // A size of zero means the SkBitmap was simply flattened.
218 this->validate(length == 0); 219 if (!this->validate(!useBitmapHeap && (0 == length))) {
219 if (fError) {
220 return; 220 return;
221 } 221 }
222 bitmap->unflatten(*this); 222 bitmap->unflatten(*this);
223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); 223 this->validate((bitmap->width() == width) && (bitmap->height() == height));
224 } 224 }
225 225
226 SkTypeface* SkValidatingReadBuffer::readTypeface() { 226 SkTypeface* SkValidatingReadBuffer::readTypeface() {
227 // TODO: Implement this (securely) when needed 227 // TODO: Implement this (securely) when needed
228 return NULL; 228 return NULL;
229 } 229 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 delete obj; 266 delete obj;
267 obj = NULL; 267 obj = NULL;
268 } 268 }
269 } else { 269 } else {
270 // we must skip the remaining data 270 // we must skip the remaining data
271 this->skip(sizeRecorded); 271 this->skip(sizeRecorded);
272 SkASSERT(false); 272 SkASSERT(false);
273 } 273 }
274 return obj; 274 return obj;
275 } 275 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.h ('k') | src/ports/SkGlobalInitialization_chromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698