Chromium Code Reviews| Index: src/codec/SkWebpAdapterCodec.cpp |
| diff --git a/src/codec/SkWebpAdapterCodec.cpp b/src/codec/SkWebpAdapterCodec.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a045cd3095adaf1e7fab49ad36b92785489e425 |
| --- /dev/null |
| +++ b/src/codec/SkWebpAdapterCodec.cpp |
| @@ -0,0 +1,41 @@ |
| +/* |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "SkCodec.h" |
| +#include "SkCodecPriv.h" |
| +#include "SkWebpAdapterCodec.h" |
| + |
| +SkWebpAdapterCodec::SkWebpAdapterCodec(SkWebpCodec* codec) |
| + : INHERITED(codec->getInfo()) |
| + , fCodec(codec) |
| +{} |
| + |
| +SkISize SkWebpAdapterCodec::onGetSampledDimensions(int sampleSize) const { |
| + float scale = get_scale_from_sample_size(sampleSize); |
| + return fCodec->getScaledDimensions(scale); |
| +} |
| + |
| +bool SkWebpAdapterCodec::onGetSubset(SkIRect* desiredSubset) const { |
| + return fCodec->getValidSubset(desiredSubset); |
| +} |
| + |
| +SkISize SkWebpAdapterCodec::onGetSampledSubsetDimensions(int sampleSize, const SkIRect& subset) |
| + const { |
| + float scale = get_scale_from_sample_size(sampleSize); |
| + 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
|
| + int height = SkTMax(1, SkScalarRoundToInt(scale * (float) subset.height())); |
| + return SkISize::Make(width, height); |
| +} |
| + |
| +SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info, void* pixels, |
| + size_t rowBytes, AndroidOptions& options) { |
| + SkCodec::Options codecOptions; |
| + codecOptions.fZeroInitialized = options.fZeroInitialized; |
| + codecOptions.fSubset = options.fSubset; |
| + return fCodec->getPixels(info, pixels, rowBytes, &codecOptions, options.fColorPtr, |
| + options.fColorCount); |
| +} |