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

Side by Side Diff: src/images/SkImageDecoder.cpp

Issue 14565005: Provide a function to print the name of a Format. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « include/images/SkImageDecoder.h ('k') | no next file » | 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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 SkSafeUnref(fPeeker); 47 SkSafeUnref(fPeeker);
48 SkSafeUnref(fChooser); 48 SkSafeUnref(fChooser);
49 SkSafeUnref(fAllocator); 49 SkSafeUnref(fAllocator);
50 } 50 }
51 51
52 SkImageDecoder::Format SkImageDecoder::getFormat() const { 52 SkImageDecoder::Format SkImageDecoder::getFormat() const {
53 return kUnknown_Format; 53 return kUnknown_Format;
54 } 54 }
55 55
56 const char* SkImageDecoder::getFormatName() const { 56 const char* SkImageDecoder::getFormatName() const {
57 switch (this->getFormat()) { 57 return GetFormatName(this->getFormat());
58 }
59
60 const char* SkImageDecoder::GetFormatName(Format format) {
61 switch (format) {
58 case kUnknown_Format: 62 case kUnknown_Format:
59 return "Unknown Format"; 63 return "Unknown Format";
60 case kBMP_Format: 64 case kBMP_Format:
61 return "BMP"; 65 return "BMP";
62 case kGIF_Format: 66 case kGIF_Format:
63 return "GIF"; 67 return "GIF";
64 case kICO_Format: 68 case kICO_Format:
65 return "ICO"; 69 return "ICO";
66 case kJPEG_Format: 70 case kJPEG_Format:
67 return "JPEG"; 71 return "JPEG";
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 316
313 // SkBitmapToImageInfo will return false if Index8 is used. kIndex8 317 // SkBitmapToImageInfo will return false if Index8 is used. kIndex8
314 // is not supported by the Info/Target model, since kIndex8 requires 318 // is not supported by the Info/Target model, since kIndex8 requires
315 // an SkColorTable, which this model does not keep track of. 319 // an SkColorTable, which this model does not keep track of.
316 SkASSERT(bm.config() != SkBitmap::kIndex8_Config); 320 SkASSERT(bm.config() != SkBitmap::kIndex8_Config);
317 321
318 if (NULL == target) { 322 if (NULL == target) {
319 return true; 323 return true;
320 } 324 }
321 325
322 if (target->fRowBytes != (uint32_t) bm.rowBytes()) { 326 if (target->fRowBytes != SkToU32(bm.rowBytes())) {
323 if (target->fRowBytes < SkImageMinRowBytes(*info)) { 327 if (target->fRowBytes < SkImageMinRowBytes(*info)) {
324 SkASSERT(!"Desired row bytes is too small"); 328 SkASSERT(!"Desired row bytes is too small");
325 return false; 329 return false;
326 } 330 }
327 bm.setConfig(bm.config(), bm.width(), bm.height(), target->fRowBytes ); 331 bm.setConfig(bm.config(), bm.width(), bm.height(), target->fRowBytes );
328 } 332 }
329 333
330 TargetAllocator allocator(target->fAddr); 334 TargetAllocator allocator(target->fAddr);
331 decoder->setAllocator(&allocator); 335 decoder->setAllocator(&allocator);
332 stream.rewind(); 336 stream.rewind();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 CreateICOImageDecoder(); 382 CreateICOImageDecoder();
379 CreateWBMPImageDecoder(); 383 CreateWBMPImageDecoder();
380 // Only link GIF and PNG on platforms that build them. See images.gyp 384 // Only link GIF and PNG on platforms that build them. See images.gyp
381 #if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUIL D_FOR_NACL) 385 #if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUIL D_FOR_NACL)
382 CreateGIFImageDecoder(); 386 CreateGIFImageDecoder();
383 #endif 387 #endif
384 #if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) 388 #if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN)
385 CreatePNGImageDecoder(); 389 CreatePNGImageDecoder();
386 #endif 390 #endif
387 } 391 }
OLDNEW
« no previous file with comments | « include/images/SkImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698