Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 SkStreamRewindable* stream, Strategy strategy) { | 23 SkStreamRewindable* stream, Strategy strategy) { |
| 24 SkAutoTDelete<SkStreamRewindable> streamDeleter(stream); | 24 SkAutoTDelete<SkStreamRewindable> streamDeleter(stream); |
| 25 switch (strategy) { | 25 switch (strategy) { |
| 26 case kCanvas_Strategy: { | 26 case kCanvas_Strategy: { |
| 27 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.de tach())); | 27 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.de tach())); |
| 28 if (nullptr == codec) { | 28 if (nullptr == codec) { |
| 29 SkCodecPrintf("Error: Failed to create decoder.\n"); | 29 SkCodecPrintf("Error: Failed to create decoder.\n"); |
| 30 return nullptr; | 30 return nullptr; |
| 31 } | 31 } |
| 32 | 32 |
| 33 if (SkEncodedFormat::kWEBP_SkEncodedFormat == codec->getEncodedForma t()) { | 33 SkEncodedFormat format = codec->getEncodedFormat(); |
| 34 // FIXME: Support webp using a special case. Webp does not supp ort | 34 switch (format) { |
| 35 // scanline decoding. | 35 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
| 36 return nullptr; | 36 case SkEncodedFormat::kPNG_SkEncodedFormat: |
| 37 break; | |
| 38 default: | |
| 39 // FIXME: Support webp using a special case. Webp does not support | |
| 40 // scanline decoding. | |
| 41 return nullptr; | |
| 37 } | 42 } |
| 38 | 43 |
| 39 switch (codec->getScanlineOrder()) { | |
|
scroggo
2015/11/16 14:20:06
I suppose you took this out because we should neve
msarett
2015/11/16 14:27:51
Yes you're right. Sounds good to me.
| |
| 40 case SkCodec::kTopDown_SkScanlineOrder: | |
| 41 case SkCodec::kNone_SkScanlineOrder: | |
| 42 break; | |
| 43 default: | |
| 44 SkCodecPrintf("Error: Scanline ordering not supported.\n"); | |
| 45 return nullptr; | |
| 46 } | |
| 47 return new SkBitmapRegionCanvas(codec.detach()); | 44 return new SkBitmapRegionCanvas(codec.detach()); |
| 48 } | 45 } |
| 49 case kAndroidCodec_Strategy: { | 46 case kAndroidCodec_Strategy: { |
| 50 SkAutoTDelete<SkAndroidCodec> codec = | 47 SkAutoTDelete<SkAndroidCodec> codec = |
| 51 SkAndroidCodec::NewFromStream(streamDeleter.detach()); | 48 SkAndroidCodec::NewFromStream(streamDeleter.detach()); |
| 52 if (NULL == codec) { | 49 if (nullptr == codec) { |
| 53 SkCodecPrintf("Error: Failed to create codec.\n"); | 50 SkCodecPrintf("Error: Failed to create codec.\n"); |
| 54 return NULL; | 51 return NULL; |
| 55 } | 52 } |
| 53 | |
| 54 SkEncodedFormat format = codec->getEncodedFormat(); | |
| 55 switch (format) { | |
| 56 case SkEncodedFormat::kJPEG_SkEncodedFormat: | |
| 57 case SkEncodedFormat::kPNG_SkEncodedFormat: | |
| 58 case SkEncodedFormat::kWEBP_SkEncodedFormat: | |
| 59 break; | |
| 60 default: | |
| 61 return nullptr; | |
| 62 } | |
| 63 | |
| 56 return new SkBitmapRegionCodec(codec.detach()); | 64 return new SkBitmapRegionCodec(codec.detach()); |
| 57 } | 65 } |
| 58 default: | 66 default: |
| 59 SkASSERT(false); | 67 SkASSERT(false); |
| 60 return nullptr; | 68 return nullptr; |
| 61 } | 69 } |
| 62 } | 70 } |
| OLD | NEW |