| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |