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 "SkAndroidCodec.h" | 8 #include "SkAndroidCodec.h" |
9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
10 #include "SkCodecPriv.h" | 10 #include "SkCodecPriv.h" |
| 11 #ifdef SK_CODEC_DECODES_RAW |
| 12 #include "SkRawAdapterCodec.h" |
| 13 #endif |
11 #include "SkSampledCodec.h" | 14 #include "SkSampledCodec.h" |
12 #include "SkWebpAdapterCodec.h" | 15 #include "SkWebpAdapterCodec.h" |
13 | 16 |
14 static bool is_valid_sample_size(int sampleSize) { | 17 static bool is_valid_sample_size(int sampleSize) { |
15 // FIXME: As Leon has mentioned elsewhere, surely there is also a maximum sa
mpleSize? | 18 // FIXME: As Leon has mentioned elsewhere, surely there is also a maximum sa
mpleSize? |
16 return sampleSize > 0; | 19 return sampleSize > 0; |
17 } | 20 } |
18 | 21 |
19 SkAndroidCodec::SkAndroidCodec(SkCodec* codec) | 22 SkAndroidCodec::SkAndroidCodec(SkCodec* codec) |
20 : fInfo(codec->getInfo()) | 23 : fInfo(codec->getInfo()), fCodec(codec) {} |
21 , fCodec(codec) | |
22 {} | |
23 | 24 |
24 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader
* chunkReader) { | 25 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader
* chunkReader) { |
25 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader)); | 26 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader)); |
26 if (nullptr == codec) { | 27 if (nullptr == codec) { |
27 return nullptr; | 28 return nullptr; |
28 } | 29 } |
29 | 30 |
30 switch (codec->getEncodedFormat()) { | 31 switch (codec->getEncodedFormat()) { |
31 case kWEBP_SkEncodedFormat: | 32 case kWEBP_SkEncodedFormat: |
32 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach()); | 33 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach()); |
33 case kPNG_SkEncodedFormat: | 34 case kPNG_SkEncodedFormat: |
34 case kJPEG_SkEncodedFormat: | 35 case kJPEG_SkEncodedFormat: |
35 case kWBMP_SkEncodedFormat: | 36 case kWBMP_SkEncodedFormat: |
36 case kBMP_SkEncodedFormat: | 37 case kBMP_SkEncodedFormat: |
37 case kGIF_SkEncodedFormat: | 38 case kGIF_SkEncodedFormat: |
38 case kICO_SkEncodedFormat: | 39 case kICO_SkEncodedFormat: |
39 return new SkSampledCodec(codec.detach()); | 40 return new SkSampledCodec(codec.detach()); |
| 41 #ifdef SK_CODEC_DECODES_RAW |
| 42 case kRAW_SkEncodedFormat: |
| 43 return new SkRawAdapterCodec((SkRawCodec*)codec.detach()); |
| 44 #endif |
40 default: | 45 default: |
41 return nullptr; | 46 return nullptr; |
42 } | 47 } |
43 } | 48 } |
44 | 49 |
45 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun
kReader) { | 50 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun
kReader) { |
46 if (!data) { | 51 if (!data) { |
47 return nullptr; | 52 return nullptr; |
48 } | 53 } |
49 | 54 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 180 } |
176 } | 181 } |
177 | 182 |
178 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); | 183 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); |
179 } | 184 } |
180 | 185 |
181 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void*
pixels, | 186 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void*
pixels, |
182 size_t rowBytes) { | 187 size_t rowBytes) { |
183 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); | 188 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); |
184 } | 189 } |
| 190 |
OLD | NEW |