blob: 18e1a549114f4fc0f8147a18ba314fe038336c3b [file] [log] [blame]
msarett3d9d7a72015-10-21 10:27:10 -07001/*
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
12SkWebpAdapterCodec::SkWebpAdapterCodec(SkWebpCodec* codec)
msarett90c4d5f2015-12-10 13:09:24 -080013 : INHERITED(codec)
msarett3d9d7a72015-10-21 10:27:10 -070014{}
15
16SkISize SkWebpAdapterCodec::onGetSampledDimensions(int sampleSize) const {
17 float scale = get_scale_from_sample_size(sampleSize);
msarett90c4d5f2015-12-10 13:09:24 -080018 return this->codec()->getScaledDimensions(scale);
msarett3d9d7a72015-10-21 10:27:10 -070019}
20
21bool SkWebpAdapterCodec::onGetSupportedSubset(SkIRect* desiredSubset) const {
msarett90c4d5f2015-12-10 13:09:24 -080022 return this->codec()->getValidSubset(desiredSubset);
msarett3d9d7a72015-10-21 10:27:10 -070023}
24
25SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info, void* pixels,
scroggoe95a0682015-11-04 04:31:12 -080026 size_t rowBytes, const AndroidOptions& options) {
msarett3d9d7a72015-10-21 10:27:10 -070027 SkCodec::Options codecOptions;
28 codecOptions.fZeroInitialized = options.fZeroInitialized;
29 codecOptions.fSubset = options.fSubset;
Matt Sarettcf3f2342017-03-23 15:32:25 -040030 codecOptions.fPremulBehavior = SkTransferFunctionBehavior::kIgnore;
Leon Scroggins571b30f2017-07-11 17:35:31 +000031 return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions);
msarett3d9d7a72015-10-21 10:27:10 -070032}