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

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

Issue 1406223002: Create an SkAndroidCodec API separate from SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Win bot fix Created 5 years, 1 month 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 | « src/codec/SkWebpAdapterCodec.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkCodec.h"
9 #include "SkCodecPriv.h"
10 #include "SkWebpAdapterCodec.h"
11
12 SkWebpAdapterCodec::SkWebpAdapterCodec(SkWebpCodec* codec)
13 : INHERITED(codec->getInfo())
14 , fCodec(codec)
15 {}
16
17 SkISize SkWebpAdapterCodec::onGetSampledDimensions(int sampleSize) const {
18 float scale = get_scale_from_sample_size(sampleSize);
19 return fCodec->getScaledDimensions(scale);
20 }
21
22 bool SkWebpAdapterCodec::onGetSupportedSubset(SkIRect* desiredSubset) const {
23 return fCodec->getValidSubset(desiredSubset);
24 }
25
26 SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info, void* pixels,
27 size_t rowBytes, AndroidOptions& options) {
28 // SkWebpCodec will support pretty much any dimensions that we provide, but we want
29 // to be stricter about the type of scaling that we allow, so we will add an extra
30 // check here.
31 SkISize supportedSize;
32 if (!options.fSubset) {
33 supportedSize = this->onGetSampledDimensions(options.fSampleSize);
34 } else {
35 supportedSize = this->getSampledSubsetDimensions(options.fSampleSize, *o ptions.fSubset);
36 }
37 if (supportedSize != info.dimensions()) {
38 return SkCodec::kInvalidParameters;
39 }
40
41 SkCodec::Options codecOptions;
42 codecOptions.fZeroInitialized = options.fZeroInitialized;
43 codecOptions.fSubset = options.fSubset;
44 return fCodec->getPixels(info, pixels, rowBytes, &codecOptions, options.fCol orPtr,
45 options.fColorCount);
46 }
OLDNEW
« no previous file with comments | « src/codec/SkWebpAdapterCodec.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698