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 "Sk64.h" | 8 #include "Sk64.h" |
9 #include "SkLazyPixelRef.h" | 9 #include "SkLazyPixelRef.h" |
10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 #include "SkImagePriv.h" | 149 #include "SkImagePriv.h" |
150 | 150 |
151 static bool init_from_info(SkBitmap* bm, const SkImage::Info& info, | 151 static bool init_from_info(SkBitmap* bm, const SkImage::Info& info, |
152 size_t rowBytes) { | 152 size_t rowBytes) { |
153 bool isOpaque; | 153 bool isOpaque; |
154 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); | 154 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); |
155 if (SkBitmap::kNo_Config == config) { | 155 if (SkBitmap::kNo_Config == config) { |
156 return false; | 156 return false; |
157 } | 157 } |
158 | 158 |
159 bm->setConfig(config, info.fWidth, info.fHeight, rowBytes); | 159 return bm->setConfig(config, info.fWidth, info.fHeight, rowBytes, |
160 bm->setIsOpaque(isOpaque); | 160 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType) |
161 return bm->allocPixels(); | 161 && |
| 162 bm->allocPixels(); |
162 } | 163 } |
163 | 164 |
164 bool SkLazyPixelRef::onImplementsDecodeInto() { | 165 bool SkLazyPixelRef::onImplementsDecodeInto() { |
165 return true; | 166 return true; |
166 } | 167 } |
167 | 168 |
168 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) { | 169 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) { |
169 SkASSERT(fData != NULL && fData->size() > 0); | 170 SkASSERT(fData != NULL && fData->size() > 0); |
170 if (fErrorInDecoding) { | 171 if (fErrorInDecoding) { |
171 return false; | 172 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
189 | 190 |
190 target.fAddr = tmp.getPixels(); | 191 target.fAddr = tmp.getPixels(); |
191 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target
); | 192 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target
); |
192 if (fErrorInDecoding) { | 193 if (fErrorInDecoding) { |
193 return false; | 194 return false; |
194 } | 195 } |
195 | 196 |
196 *bitmap = tmp; | 197 *bitmap = tmp; |
197 return true; | 198 return true; |
198 } | 199 } |
OLD | NEW |