Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: src/ports/SkImageDecoder_CG.cpp

Issue 14363003: Updates to skimage tool to use it for testing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: GetFormat -> GetStreamFormat Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_wbmp.cpp ('k') | src/ports/SkImageDecoder_WIC.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
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 8
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 case SkImageEncoder::kJPEG_Type: 238 case SkImageEncoder::kJPEG_Type:
239 case SkImageEncoder::kPNG_Type: 239 case SkImageEncoder::kPNG_Type:
240 break; 240 break;
241 default: 241 default:
242 return NULL; 242 return NULL;
243 } 243 }
244 return SkNEW_ARGS(SkImageEncoder_CG, (t)); 244 return SkNEW_ARGS(SkImageEncoder_CG, (t));
245 } 245 }
246 246
247 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_imageencoder_ cg_factory); 247 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_imageencoder_ cg_factory);
248
249 struct FormatConversion {
250 CFStringRef fUTType;
251 SkImageDecoder::Format fFormat;
252 };
253
254 // Array of the types supported by the decoder.
255 static const FormatConversion gFormatConversions[] = {
256 { kUTTypeBMP, SkImageDecoder::kBMP_Format },
257 { kUTTypeGIF, SkImageDecoder::kGIF_Format },
258 { kUTTypeICO, SkImageDecoder::kICO_Format },
259 { kUTTypeJPEG, SkImageDecoder::kJPEG_Format },
260 // Also include JPEG2000
261 { kUTTypeJPEG2000, SkImageDecoder::kJPEG_Format },
262 { kUTTypePNG, SkImageDecoder::kPNG_Format },
263 };
264
265 static SkImageDecoder::Format UTType_to_Format(const CFStringRef uttype) {
266 for (size_t i = 0; i < SK_ARRAY_COUNT(gFormatConversions); i++) {
267 if (CFStringCompare(uttype, gFormatConversions[i].fUTType, 0) == kCFComp areEqualTo) {
268 return gFormatConversions[i].fFormat;
269 }
270 }
271 return SkImageDecoder::kUnknown_Format;
272 }
273
274 static SkImageDecoder::Format get_format_cg(SkStream *stream) {
275 CGImageSourceRef imageSrc = SkStreamToCGImageSource(stream);
276
277 if (NULL == imageSrc) {
278 return SkImageDecoder::kUnknown_Format;
279 }
280
281 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc);
282 const CFStringRef name = CGImageSourceGetType(imageSrc);
283 if (NULL == name) {
284 return SkImageDecoder::kUnknown_Format;
285 }
286 return UTType_to_Format(name);
287 }
288
289 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_cg);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_wbmp.cpp ('k') | src/ports/SkImageDecoder_WIC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698