OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmapFactory.h" | 8 #include "SkBitmapFactory.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 } | 54 } |
55 | 55 |
56 bool isOpaque = false; | 56 bool isOpaque = false; |
57 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); | 57 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); |
58 | 58 |
59 Target target; | 59 Target target; |
60 // FIMXE: There will be a problem if this rowbytes is calculated differently from | 60 // FIMXE: There will be a problem if this rowbytes is calculated differently from |
61 // in SkLazyPixelRef. | 61 // in SkLazyPixelRef. |
62 target.fRowBytes = SkImageMinRowBytes(info); | 62 target.fRowBytes = SkImageMinRowBytes(info); |
63 | 63 |
64 dst->setConfig(config, info.fWidth, info.fHeight, target.fRowBytes); | 64 dst->setConfig(config, info.fWidth, info.fHeight, target.fRowBytes, |
65 dst->setIsOpaque(isOpaque); | 65 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
scroggo
2013/10/18 19:32:40
info should have the actual alpha type.
| |
66 | 66 |
67 // fImageCache and fCacheSelector are mutually exclusive. | 67 // fImageCache and fCacheSelector are mutually exclusive. |
68 SkASSERT(NULL == fImageCache || NULL == fCacheSelector); | 68 SkASSERT(NULL == fImageCache || NULL == fCacheSelector); |
69 | 69 |
70 SkImageCache* cache = NULL == fCacheSelector ? fImageCache : fCacheSelector- >selectCache(info); | 70 SkImageCache* cache = NULL == fCacheSelector ? fImageCache : fCacheSelector- >selectCache(info); |
71 | 71 |
72 if (cache != NULL) { | 72 if (cache != NULL) { |
73 // Now set a new LazyPixelRef on dst. | 73 // Now set a new LazyPixelRef on dst. |
74 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, | 74 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, |
75 (data, fDecodeProc, cach e))); | 75 (data, fDecodeProc, cach e))); |
76 dst->setPixelRef(lazyRef); | 76 dst->setPixelRef(lazyRef); |
77 return true; | 77 return true; |
78 } else { | 78 } else { |
79 dst->allocPixels(); | 79 dst->allocPixels(); |
80 target.fAddr = dst->getPixels(); | 80 target.fAddr = dst->getPixels(); |
81 return fDecodeProc(data->data(), data->size(), &info, &target); | 81 return fDecodeProc(data->data(), data->size(), &info, &target); |
82 } | 82 } |
83 } | 83 } |
OLD | NEW |