Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: src/codec/SkAndroidCodec.cpp

Issue 1702533004: Individually enable and disable SkCodecs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « public.bzl ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 11 #include "SkRawAdapterCodec.h"
13 #endif
14 #include "SkSampledCodec.h" 12 #include "SkSampledCodec.h"
15 #include "SkWebpAdapterCodec.h" 13 #include "SkWebpAdapterCodec.h"
16 14
17 static bool is_valid_sample_size(int sampleSize) { 15 static bool is_valid_sample_size(int sampleSize) {
18 // 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?
19 return sampleSize > 0; 17 return sampleSize > 0;
20 } 18 }
21 19
22 SkAndroidCodec::SkAndroidCodec(SkCodec* codec) 20 SkAndroidCodec::SkAndroidCodec(SkCodec* codec)
23 : fInfo(codec->getInfo()) 21 : fInfo(codec->getInfo())
24 , fCodec(codec) 22 , fCodec(codec)
25 {} 23 {}
26 24
27 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader * chunkReader) { 25 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader * chunkReader) {
28 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader)); 26 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
29 if (nullptr == codec) { 27 if (nullptr == codec) {
30 return nullptr; 28 return nullptr;
31 } 29 }
32 30
33 switch (codec->getEncodedFormat()) { 31 switch (codec->getEncodedFormat()) {
32 #ifdef SK_CODEC_DECODES_PNG
33 case kPNG_SkEncodedFormat:
34 case kICO_SkEncodedFormat:
35 #endif
36 #ifdef SK_CODEC_DECODES_JPEG
37 case kJPEG_SkEncodedFormat:
38 #endif
39 #ifdef SK_CODEC_DECODES_GIF
40 case kGIF_SkEncodedFormat:
41 #endif
42 case kBMP_SkEncodedFormat:
43 case kWBMP_SkEncodedFormat:
44 return new SkSampledCodec(codec.detach());
45 #ifdef SK_CODEC_DECODES_WEBP
34 case kWEBP_SkEncodedFormat: 46 case kWEBP_SkEncodedFormat:
35 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach()); 47 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
36 case kPNG_SkEncodedFormat: 48 #endif
37 case kJPEG_SkEncodedFormat:
38 case kWBMP_SkEncodedFormat:
39 case kBMP_SkEncodedFormat:
40 case kGIF_SkEncodedFormat:
41 case kICO_SkEncodedFormat:
42 return new SkSampledCodec(codec.detach());
43 #ifdef SK_CODEC_DECODES_RAW 49 #ifdef SK_CODEC_DECODES_RAW
44 case kRAW_SkEncodedFormat: 50 case kRAW_SkEncodedFormat:
45 return new SkRawAdapterCodec((SkRawCodec*)codec.detach()); 51 return new SkRawAdapterCodec((SkRawCodec*)codec.detach());
46 #endif 52 #endif
47 default: 53 default:
48 return nullptr; 54 return nullptr;
49 } 55 }
50 } 56 }
51 57
52 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun kReader) { 58 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun kReader) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 188 }
183 } 189 }
184 190
185 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); 191 return this->onGetAndroidPixels(info, pixels, rowBytes, *options);
186 } 192 }
187 193
188 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels, 194 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels,
189 size_t rowBytes) { 195 size_t rowBytes) {
190 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); 196 return this->getAndroidPixels(info, pixels, rowBytes, nullptr);
191 } 197 }
OLDNEW
« no previous file with comments | « public.bzl ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698