OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |