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

Side by Side Diff: src/images/SkDecodingImageGenerator.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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/image/SkImage.cpp ('k') | src/images/SkImageDecoder.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 "SkData.h" 8 #include "SkData.h"
9 #include "SkDecodingImageGenerator.h" 9 #include "SkDecodingImageGenerator.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 : fInfo(info) 62 : fInfo(info)
63 , fTarget(target) 63 , fTarget(target)
64 , fRowBytes(rowBytes) 64 , fRowBytes(rowBytes)
65 {} 65 {}
66 66
67 bool isReady() { return (fTarget != NULL); } 67 bool isReady() { return (fTarget != NULL); }
68 68
69 virtual bool allocPixelRef(SkBitmap* bm, SkColorTable* ct) { 69 virtual bool allocPixelRef(SkBitmap* bm, SkColorTable* ct) {
70 if (NULL == fTarget || !equal_modulo_alpha(fInfo, bm->info())) { 70 if (NULL == fTarget || !equal_modulo_alpha(fInfo, bm->info())) {
71 // Call default allocator. 71 // Call default allocator.
72 return bm->allocPixels(NULL, ct); 72 return bm->tryAllocPixels(NULL, ct);
73 } 73 }
74 74
75 // TODO(halcanary): verify that all callers of this function 75 // TODO(halcanary): verify that all callers of this function
76 // will respect new RowBytes. Will be moot once rowbytes belongs 76 // will respect new RowBytes. Will be moot once rowbytes belongs
77 // to PixelRef. 77 // to PixelRef.
78 bm->installPixels(fInfo, fTarget, fRowBytes, ct, NULL, NULL); 78 bm->installPixels(fInfo, fTarget, fRowBytes, ct, NULL, NULL);
79 79
80 fTarget = NULL; // never alloc same pixels twice! 80 fTarget = NULL; // never alloc same pixels twice!
81 return true; 81 return true;
82 } 82 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 SkStreamRewindable* stream, 277 SkStreamRewindable* stream,
278 const SkDecodingImageGenerator::Options& opts) { 278 const SkDecodingImageGenerator::Options& opts) {
279 SkASSERT(stream != NULL); 279 SkASSERT(stream != NULL);
280 SkASSERT(stream->unique()); 280 SkASSERT(stream->unique());
281 if ((stream == NULL) || !stream->unique()) { 281 if ((stream == NULL) || !stream->unique()) {
282 SkSafeUnref(stream); 282 SkSafeUnref(stream);
283 return NULL; 283 return NULL;
284 } 284 }
285 return CreateDecodingImageGenerator(NULL, stream, opts); 285 return CreateDecodingImageGenerator(NULL, stream, opts);
286 } 286 }
OLDNEW
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698