| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmapRegionCanvas.h" | 8 #include "SkBitmapRegionCanvas.h" |
| 9 #include "SkBitmapRegionCodec.h" | 9 #include "SkBitmapRegionCodec.h" |
| 10 #include "SkBitmapRegionDecoder.h" | 10 #include "SkBitmapRegionDecoder.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 case SkEncodedFormat::kJPEG_SkEncodedFormat: | 34 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
| 35 case SkEncodedFormat::kPNG_SkEncodedFormat: | 35 case SkEncodedFormat::kPNG_SkEncodedFormat: |
| 36 break; | 36 break; |
| 37 default: | 37 default: |
| 38 // FIXME: Support webp using a special case. Webp does not
support | 38 // FIXME: Support webp using a special case. Webp does not
support |
| 39 // scanline decoding. | 39 // scanline decoding. |
| 40 return nullptr; | 40 return nullptr; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // If the image is a jpeg or a png, the scanline ordering should alw
ays be | 43 // If the image is a jpeg or a png, the scanline ordering should alw
ays be |
| 44 // kTopDown or kNone. It is relevant to check because this implemen
tation | 44 // kTopDown. It is relevant to check because this implementation on
ly |
| 45 // only supports these two scanline orderings. | 45 // supports this scanline ordering. |
| 46 SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrde
r() || | 46 SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrde
r()); |
| 47 SkCodec::kNone_SkScanlineOrder == codec->getScanlineOrder())
; | |
| 48 | 47 |
| 49 return new SkBitmapRegionCanvas(codec.release()); | 48 return new SkBitmapRegionCanvas(codec.release()); |
| 50 } | 49 } |
| 51 case kAndroidCodec_Strategy: { | 50 case kAndroidCodec_Strategy: { |
| 52 SkAutoTDelete<SkAndroidCodec> codec = | 51 SkAutoTDelete<SkAndroidCodec> codec = |
| 53 SkAndroidCodec::NewFromStream(streamDeleter.release()); | 52 SkAndroidCodec::NewFromStream(streamDeleter.release()); |
| 54 if (nullptr == codec) { | 53 if (nullptr == codec) { |
| 55 SkCodecPrintf("Error: Failed to create codec.\n"); | 54 SkCodecPrintf("Error: Failed to create codec.\n"); |
| 56 return NULL; | 55 return NULL; |
| 57 } | 56 } |
| 58 | 57 |
| 59 SkEncodedFormat format = codec->getEncodedFormat(); | 58 SkEncodedFormat format = codec->getEncodedFormat(); |
| 60 switch (format) { | 59 switch (format) { |
| 61 case SkEncodedFormat::kJPEG_SkEncodedFormat: | 60 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
| 62 case SkEncodedFormat::kPNG_SkEncodedFormat: | 61 case SkEncodedFormat::kPNG_SkEncodedFormat: |
| 63 case SkEncodedFormat::kWEBP_SkEncodedFormat: | 62 case SkEncodedFormat::kWEBP_SkEncodedFormat: |
| 64 break; | 63 break; |
| 65 default: | 64 default: |
| 66 return nullptr; | 65 return nullptr; |
| 67 } | 66 } |
| 68 | 67 |
| 69 return new SkBitmapRegionCodec(codec.release()); | 68 return new SkBitmapRegionCodec(codec.release()); |
| 70 } | 69 } |
| 71 default: | 70 default: |
| 72 SkASSERT(false); | 71 SkASSERT(false); |
| 73 return nullptr; | 72 return nullptr; |
| 74 } | 73 } |
| 75 } | 74 } |
| OLD | NEW |