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

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

Issue 1487583003: Allow SkAndroidCodec to use SkPngChunkReader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments on Patch Set 2 Created 5 years 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 | « include/codec/SkCodec.h ('k') | no next file » | 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 #include "SkSampledCodec.h" 11 #include "SkSampledCodec.h"
12 #include "SkWebpAdapterCodec.h" 12 #include "SkWebpAdapterCodec.h"
13 13
14 static bool is_valid_sample_size(int sampleSize) { 14 static bool is_valid_sample_size(int sampleSize) {
15 // FIXME: As Leon has mentioned elsewhere, surely there is also a maximum sa mpleSize? 15 // FIXME: As Leon has mentioned elsewhere, surely there is also a maximum sa mpleSize?
16 return sampleSize > 0; 16 return sampleSize > 0;
17 } 17 }
18 18
19 SkAndroidCodec::SkAndroidCodec(const SkImageInfo& info) 19 SkAndroidCodec::SkAndroidCodec(const SkImageInfo& info)
20 : fInfo(info) 20 : fInfo(info)
21 {} 21 {}
22 22
23 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream) { 23 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader * chunkReader) {
24 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream)); 24 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
25 if (nullptr == codec) { 25 if (nullptr == codec) {
26 return nullptr; 26 return nullptr;
27 } 27 }
28 28
29 switch (codec->getEncodedFormat()) { 29 switch (codec->getEncodedFormat()) {
30 case kWEBP_SkEncodedFormat: 30 case kWEBP_SkEncodedFormat:
31 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach()); 31 return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
32 case kPNG_SkEncodedFormat: 32 case kPNG_SkEncodedFormat:
33 case kJPEG_SkEncodedFormat: 33 case kJPEG_SkEncodedFormat:
34 case kWBMP_SkEncodedFormat: 34 case kWBMP_SkEncodedFormat:
35 case kBMP_SkEncodedFormat: 35 case kBMP_SkEncodedFormat:
36 case kGIF_SkEncodedFormat: 36 case kGIF_SkEncodedFormat:
37 return new SkSampledCodec(codec.detach()); 37 return new SkSampledCodec(codec.detach());
38 default: 38 default:
39 // FIXME: SkSampledCodec is temporarily disabled for other formats 39 // FIXME: SkSampledCodec is temporarily disabled for other formats
40 // while focusing on the formats that are supported by 40 // while focusing on the formats that are supported by
41 // BitmapRegionDecoder. 41 // BitmapRegionDecoder.
42 return nullptr; 42 return nullptr;
43 } 43 }
44 } 44 }
45 45
46 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data) { 46 SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun kReader) {
47 if (!data) { 47 if (!data) {
48 return nullptr; 48 return nullptr;
49 } 49 }
50 50
51 return NewFromStream(new SkMemoryStream(data)); 51 return NewFromStream(new SkMemoryStream(data), chunkReader);
52 } 52 }
53 53
54 SkISize SkAndroidCodec::getSampledDimensions(int sampleSize) const { 54 SkISize SkAndroidCodec::getSampledDimensions(int sampleSize) const {
55 if (!is_valid_sample_size(sampleSize)) { 55 if (!is_valid_sample_size(sampleSize)) {
56 return SkISize::Make(0, 0); 56 return SkISize::Make(0, 0);
57 } 57 }
58 58
59 // Fast path for when we are not scaling. 59 // Fast path for when we are not scaling.
60 if (1 == sampleSize) { 60 if (1 == sampleSize) {
61 return fInfo.dimensions(); 61 return fInfo.dimensions();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 } 124 }
125 125
126 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); 126 return this->onGetAndroidPixels(info, pixels, rowBytes, *options);
127 } 127 }
128 128
129 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels, 129 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels,
130 size_t rowBytes) { 130 size_t rowBytes) {
131 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); 131 return this->getAndroidPixels(info, pixels, rowBytes, nullptr);
132 } 132 }
OLDNEW
« no previous file with comments | « include/codec/SkCodec.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698