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 "SkAndroidCodecAdapter.h"
9 #include "SkCodecPriv.h"
10
SkAndroidCodecAdapter(SkCodec * codec,ExifOrientationBehavior behavior)11 SkAndroidCodecAdapter::SkAndroidCodecAdapter(SkCodec* codec, ExifOrientationBehavior behavior)
12 : INHERITED(codec, behavior)
13 {}
14
onGetSampledDimensions(int sampleSize) const15 SkISize SkAndroidCodecAdapter::onGetSampledDimensions(int sampleSize) const {
16 float scale = get_scale_from_sample_size(sampleSize);
17 return this->codec()->getScaledDimensions(scale);
18 }
19
onGetSupportedSubset(SkIRect * desiredSubset) const20 bool SkAndroidCodecAdapter::onGetSupportedSubset(SkIRect* desiredSubset) const {
21 return this->codec()->getValidSubset(desiredSubset);
22 }
23
onGetAndroidPixels(const SkImageInfo & info,void * pixels,size_t rowBytes,const AndroidOptions & options)24 SkCodec::Result SkAndroidCodecAdapter::onGetAndroidPixels(const SkImageInfo& info, void* pixels,
25 size_t rowBytes, const AndroidOptions& options) {
26 SkCodec::Options codecOptions;
27 codecOptions.fZeroInitialized = options.fZeroInitialized;
28 codecOptions.fSubset = options.fSubset;
29 return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions);
30 }
31