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