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 "SkDecodingImageGenerator.h" | 8 #include "SkDecodingImageGenerator.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkDiscardablePixelRef.h" | 10 #include "SkDiscardablePixelRef.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return false; | 112 return false; |
113 } | 113 } |
114 SkBitmap bitmap; | 114 SkBitmap bitmap; |
115 if (!decoder->decode(fStream, &bitmap, | 115 if (!decoder->decode(fStream, &bitmap, |
116 SkImageDecoder::kDecodeBounds_Mode)) { | 116 SkImageDecoder::kDecodeBounds_Mode)) { |
117 return false; | 117 return false; |
118 } | 118 } |
119 if (bitmap.config() == SkBitmap::kNo_Config) { | 119 if (bitmap.config() == SkBitmap::kNo_Config) { |
120 return false; | 120 return false; |
121 } | 121 } |
122 if (!SkBitmapToImageInfo(bitmap, &fInfo)) { | 122 if (!bitmap.asImageInfo(&fInfo)) { |
123 // We can't use bitmap.config() as is. | 123 // We can't use bitmap.config() as is. |
124 // Must be kARGB_4444_Config. | |
125 if (!bitmap.canCopyTo(SkBitmap::kARGB_8888_Config)) { | 124 if (!bitmap.canCopyTo(SkBitmap::kARGB_8888_Config)) { |
126 // kARGB_4444_Config can copy to kARGB_8888. | |
127 SkDEBUGFAIL("!bitmap->canCopyTo(SkBitmap::kARGB_8888_Config)"); | 125 SkDEBUGFAIL("!bitmap->canCopyTo(SkBitmap::kARGB_8888_Config)"); |
128 return false; | 126 return false; |
129 } | 127 } |
130 fDoCopyTo = true; | 128 fDoCopyTo = true; |
131 fInfo.fWidth = bitmap.width(); | 129 fInfo.fWidth = bitmap.width(); |
132 fInfo.fHeight = bitmap.height(); | 130 fInfo.fHeight = bitmap.height(); |
133 fInfo.fColorType = kPMColor_SkColorType; | 131 fInfo.fColorType = kPMColor_SkColorType; |
134 fInfo.fAlphaType = bitmap.alphaType(); | 132 fInfo.fAlphaType = bitmap.alphaType(); |
135 } | 133 } |
136 if (info != NULL) { | 134 if (info != NULL) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 SkASSERT(stream != NULL); | 200 SkASSERT(stream != NULL); |
203 SkASSERT(dst != NULL); | 201 SkASSERT(dst != NULL); |
204 if ((stream == NULL) || !stream->unique()) { | 202 if ((stream == NULL) || !stream->unique()) { |
205 SkSafeUnref(stream); | 203 SkSafeUnref(stream); |
206 return false; | 204 return false; |
207 } | 205 } |
208 SkImageGenerator* gen(SkNEW_ARGS(SkDecodingImageGenerator, (stream))); | 206 SkImageGenerator* gen(SkNEW_ARGS(SkDecodingImageGenerator, (stream))); |
209 return SkDiscardablePixelRef::Install(gen, dst, factory); | 207 return SkDiscardablePixelRef::Install(gen, dst, factory); |
210 } | 208 } |
211 | 209 |
OLD | NEW |