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

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

Issue 1715853002: Insert an empty image when we cannot decode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkErrorInternals.h" 10 #include "SkErrorInternals.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 int originX = this->read32(); 308 int originX = this->read32();
309 int originY = this->read32(); 309 int originY = this->read32();
310 if (originX < 0 || originY < 0) { 310 if (originX < 0 || originY < 0) {
311 this->validate(false); 311 this->validate(false);
312 return nullptr; 312 return nullptr;
313 } 313 }
314 314
315 const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height); 315 const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height);
316 return SkImage::NewFromEncoded(encoded, &subset); 316 SkImage* image = SkImage::NewFromEncoded(encoded, &subset);
317 if (image) {
318 return image;
319 }
320
321 return SkImage::NewFromGenerator(
322 new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height)));
317 } 323 }
318 324
319 SkTypeface* SkReadBuffer::readTypeface() { 325 SkTypeface* SkReadBuffer::readTypeface() {
320 326
321 uint32_t index = fReader.readU32(); 327 uint32_t index = fReader.readU32();
322 if (0 == index || index > (unsigned)fTFCount) { 328 if (0 == index || index > (unsigned)fTFCount) {
323 return nullptr; 329 return nullptr;
324 } else { 330 } else {
325 SkASSERT(fTFArray); 331 SkASSERT(fTFArray);
326 return fTFArray[index - 1]; 332 return fTFArray[index - 1];
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return; 403 return;
398 } 404 }
399 } else { 405 } else {
400 if (nullptr == this->readFunctionPtr()) { 406 if (nullptr == this->readFunctionPtr()) {
401 return; 407 return;
402 } 408 }
403 } 409 }
404 uint32_t sizeRecorded = fReader.readU32(); 410 uint32_t sizeRecorded = fReader.readU32();
405 fReader.skip(sizeRecorded); 411 fReader.skip(sizeRecorded);
406 } 412 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698