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

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: Created 5 years, 2 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
(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::onGetSubset(SkIRect* desiredSubset) const {
23 return fCodec->getValidSubset(desiredSubset);
24 }
25
26 SkISize SkWebpAdapterCodec::onGetSampledSubsetDimensions(int sampleSize, const S kIRect& subset)
27 const {
28 float scale = get_scale_from_sample_size(sampleSize);
29 int width = SkTMax(1, SkScalarRoundToInt(scale * (float) subset.width()));
msarett 2015/10/16 18:42:16 Alternatively, we could use get_scaled_dimension()
scroggo 2015/10/16 21:13:55 I suppose this mimics the old behavior? I don't ha
msarett 2015/10/19 16:06:10 Using get_scaled_dimension() would actually be con
30 int height = SkTMax(1, SkScalarRoundToInt(scale * (float) subset.height()));
31 return SkISize::Make(width, height);
32 }
33
34 SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info, void* pixels,
35 size_t rowBytes, AndroidOptions& options) {
36 SkCodec::Options codecOptions;
37 codecOptions.fZeroInitialized = options.fZeroInitialized;
38 codecOptions.fSubset = options.fSubset;
39 return fCodec->getPixels(info, pixels, rowBytes, &codecOptions, options.fCol orPtr,
40 options.fColorCount);
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698