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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 SkData* SkLazyPixelRef::onRefEncodedData() { | 144 SkData* SkLazyPixelRef::onRefEncodedData() { |
145 fData->ref(); | 145 fData->ref(); |
146 return fData; | 146 return fData; |
147 } | 147 } |
148 | 148 |
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 SkBitmap::Config config = SkImageInfoToBitmapConfig(info); |
154 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); | |
155 if (SkBitmap::kNo_Config == config) { | 154 if (SkBitmap::kNo_Config == config) { |
156 return false; | 155 return false; |
157 } | 156 } |
158 | 157 |
159 bm->setConfig(config, info.fWidth, info.fHeight, rowBytes); | 158 return bm->setConfig(config, info.fWidth, info.fHeight, rowBytes, info.fAlph
aType) |
160 bm->setIsOpaque(isOpaque); | 159 && |
161 return bm->allocPixels(); | 160 bm->allocPixels(); |
162 } | 161 } |
163 | 162 |
164 bool SkLazyPixelRef::onImplementsDecodeInto() { | 163 bool SkLazyPixelRef::onImplementsDecodeInto() { |
165 return true; | 164 return true; |
166 } | 165 } |
167 | 166 |
168 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) { | 167 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) { |
169 SkASSERT(fData != NULL && fData->size() > 0); | 168 SkASSERT(fData != NULL && fData->size() > 0); |
170 if (fErrorInDecoding) { | 169 if (fErrorInDecoding) { |
171 return false; | 170 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
189 | 188 |
190 target.fAddr = tmp.getPixels(); | 189 target.fAddr = tmp.getPixels(); |
191 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target
); | 190 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target
); |
192 if (fErrorInDecoding) { | 191 if (fErrorInDecoding) { |
193 return false; | 192 return false; |
194 } | 193 } |
195 | 194 |
196 *bitmap = tmp; | 195 *bitmap = tmp; |
197 return true; | 196 return true; |
198 } | 197 } |
OLD | NEW |