OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkImageRef.h" | 8 #include "SkImageRef.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 codec = fFactory->newDecoder(fStream); | 114 codec = fFactory->newDecoder(fStream); |
115 } else { | 115 } else { |
116 codec = SkImageDecoder::Factory(fStream); | 116 codec = SkImageDecoder::Factory(fStream); |
117 } | 117 } |
118 | 118 |
119 if (codec) { | 119 if (codec) { |
120 SkAutoTDelete<SkImageDecoder> ad(codec); | 120 SkAutoTDelete<SkImageDecoder> ad(codec); |
121 | 121 |
122 codec->setSampleSize(fSampleSize); | 122 codec->setSampleSize(fSampleSize); |
123 codec->setDitherImage(fDoDither); | 123 codec->setDitherImage(fDoDither); |
| 124 codec->setRequireUnpremultipliedColors(this->info().fAlphaType == kUnpre
mul_SkAlphaType); |
124 if (this->onDecode(codec, fStream, &fBitmap, fBitmap.config(), mode)) { | 125 if (this->onDecode(codec, fStream, &fBitmap, fBitmap.config(), mode)) { |
125 if (kOpaque_SkAlphaType == fBitmap.alphaType()) { | 126 if (kOpaque_SkAlphaType == fBitmap.alphaType()) { |
126 this->changeAlphaType(kOpaque_SkAlphaType); | 127 this->changeAlphaType(kOpaque_SkAlphaType); |
127 } | 128 } |
128 SkASSERT(this->info().fColorType == fBitmap.colorType()); | 129 SkASSERT(this->info() == fBitmap.info()); |
129 SkASSERT(this->info().fWidth == fBitmap.width()); | |
130 SkASSERT(this->info().fHeight == fBitmap.height()); | |
131 return true; | 130 return true; |
132 } | 131 } |
133 } | 132 } |
134 | 133 |
135 #ifdef DUMP_IMAGEREF_LIFECYCLE | 134 #ifdef DUMP_IMAGEREF_LIFECYCLE |
136 if (NULL == codec) { | 135 if (NULL == codec) { |
137 SkDebugf("--- ImageRef: <%s> failed to find codec\n", this->getURI()); | 136 SkDebugf("--- ImageRef: <%s> failed to find codec\n", this->getURI()); |
138 } else { | 137 } else { |
139 SkDebugf("--- ImageRef: <%s> failed in codec for %d mode\n", | 138 SkDebugf("--- ImageRef: <%s> failed in codec for %d mode\n", |
140 this->getURI(), mode); | 139 this->getURI(), mode); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // now. | 203 // now. |
205 if (!fStream->rewind()) { | 204 if (!fStream->rewind()) { |
206 SkDEBUGF(("Failed to rewind SkImageRef stream!")); | 205 SkDEBUGF(("Failed to rewind SkImageRef stream!")); |
207 buffer.write32(0); | 206 buffer.write32(0); |
208 } else { | 207 } else { |
209 // FIXME: Handle getLength properly here. Perhaps this class should | 208 // FIXME: Handle getLength properly here. Perhaps this class should |
210 // take an SkStreamAsset. | 209 // take an SkStreamAsset. |
211 buffer.writeStream(fStream, fStream->getLength()); | 210 buffer.writeStream(fStream, fStream->getLength()); |
212 } | 211 } |
213 } | 212 } |
OLD | NEW |