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

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

Issue 1520403003: Prototype of RAW decoding in Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Addrees comments from current & old CLs Created 4 years, 11 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
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 #include "SkRawAndroidCodec.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())
21 , fCodec(codec) 22 , fCodec(codec)
22 {} 23 {
msarett 2016/01/06 22:50:24 nit: Please change back.
yujieqin 2016/01/07 09:22:25 Done.
24 }
23 25
24 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader * chunkReader) { 26 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader * chunkReader) {
25 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader)); 27 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
26 if (nullptr == codec) { 28 if (nullptr == codec) {
27 return nullptr; 29 return nullptr;
28 } 30 }
29 31
30 switch (codec->getEncodedFormat()) { 32 switch (codec->getEncodedFormat()) {
31 case kWEBP_SkEncodedFormat: 33 case kWEBP_SkEncodedFormat:
32 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach()); 34 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
33 case kPNG_SkEncodedFormat: 35 case kPNG_SkEncodedFormat:
34 case kJPEG_SkEncodedFormat: 36 case kJPEG_SkEncodedFormat:
35 case kWBMP_SkEncodedFormat: 37 case kWBMP_SkEncodedFormat:
36 case kBMP_SkEncodedFormat: 38 case kBMP_SkEncodedFormat:
37 case kGIF_SkEncodedFormat: 39 case kGIF_SkEncodedFormat:
38 case kICO_SkEncodedFormat: 40 case kICO_SkEncodedFormat:
39 return new SkSampledCodec(codec.detach()); 41 return new SkSampledCodec(codec.detach());
42 case kRAW_SkEncodedFormat:
43 return new SkRawAndroidCodec((SkRawCodec*)codec.detach());
40 default: 44 default:
41 return nullptr; 45 return nullptr;
42 } 46 }
43 } 47 }
44 48
45 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun kReader) { 49 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun kReader) {
46 if (!data) { 50 if (!data) {
47 return nullptr; 51 return nullptr;
48 } 52 }
49 53
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 179 }
176 } 180 }
177 181
178 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); 182 return this->onGetAndroidPixels(info, pixels, rowBytes, *options);
179 } 183 }
180 184
181 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels, 185 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels,
182 size_t rowBytes) { 186 size_t rowBytes) {
183 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); 187 return this->getAndroidPixels(info, pixels, rowBytes, nullptr);
184 } 188 }
189
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698