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 "SkBitmapRegionDecoderInterface.h" | 9 #include "SkBitmapRegionDecoderInterface.h" |
10 #include "SkBitmapRegionSampler.h" | 10 #include "SkBitmapRegionSampler.h" |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
13 | 13 |
14 SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
onDecoder( | 14 SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
onDecoder( |
15 SkStreamRewindable* stream, Strategy strategy) { | 15 SkStreamRewindable* stream, Strategy strategy) { |
16 switch (strategy) { | 16 switch (strategy) { |
17 case kOriginal_Strategy: { | 17 case kOriginal_Strategy: { |
18 SkImageDecoder* decoder = SkImageDecoder::Factory(stream); | 18 SkImageDecoder* decoder = SkImageDecoder::Factory(stream); |
19 int width, height; | 19 int width, height; |
20 if (nullptr == decoder) { | 20 if (nullptr == decoder) { |
21 SkDebugf("Error: Could not create image decoder.\n"); | |
22 return nullptr; | 21 return nullptr; |
23 } | 22 } |
24 if (!decoder->buildTileIndex(stream, &width, &height)) { | 23 if (!decoder->buildTileIndex(stream, &width, &height)) { |
25 SkDebugf("Error: Could not build tile index.\n"); | |
26 delete decoder; | 24 delete decoder; |
27 return nullptr; | 25 return nullptr; |
28 } | 26 } |
29 return new SkBitmapRegionSampler(decoder, width, height); | 27 return new SkBitmapRegionSampler(decoder, width, height); |
30 } | 28 } |
31 case kCanvas_Strategy: { | 29 case kCanvas_Strategy: { |
32 SkCodec* decoder = SkCodec::NewFromStream(stream); | 30 SkCodec* decoder = SkCodec::NewFromStream(stream); |
33 if (nullptr == decoder) { | 31 if (nullptr == decoder) { |
34 SkDebugf("Error: Failed to create decoder.\n"); | |
35 return nullptr; | 32 return nullptr; |
36 } | 33 } |
37 switch (decoder->getScanlineOrder()) { | 34 switch (decoder->getScanlineOrder()) { |
38 case SkCodec::kTopDown_SkScanlineOrder: | 35 case SkCodec::kTopDown_SkScanlineOrder: |
39 case SkCodec::kNone_SkScanlineOrder: | 36 case SkCodec::kNone_SkScanlineOrder: |
40 break; | 37 break; |
41 default: | 38 default: |
42 SkDebugf("Error: Scanline ordering not supported.\n"); | |
43 return nullptr; | 39 return nullptr; |
44 } | 40 } |
45 return new SkBitmapRegionCanvas(decoder); | 41 return new SkBitmapRegionCanvas(decoder); |
46 } | 42 } |
47 default: | 43 default: |
48 SkASSERT(false); | 44 SkASSERT(false); |
49 return nullptr; | 45 return nullptr; |
50 } | 46 } |
51 } | 47 } |
OLD | NEW |