msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 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 | |
Nigel Tao | 612a65d | 2018-11-09 10:10:31 +1100 | [diff] [blame] | 8 | #include "SkAndroidCodecAdapter.h" |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 9 | #include "SkCodecPriv.h" |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 10 | |
Nigel Tao | 612a65d | 2018-11-09 10:10:31 +1100 | [diff] [blame] | 11 | SkAndroidCodecAdapter::SkAndroidCodecAdapter(SkCodec* codec, ExifOrientationBehavior behavior) |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 12 | : INHERITED(codec, behavior) |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 13 | {} |
| 14 | |
Nigel Tao | 612a65d | 2018-11-09 10:10:31 +1100 | [diff] [blame] | 15 | SkISize SkAndroidCodecAdapter::onGetSampledDimensions(int sampleSize) const { |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 16 | float scale = get_scale_from_sample_size(sampleSize); |
msarett | 90c4d5f | 2015-12-10 13:09:24 -0800 | [diff] [blame] | 17 | return this->codec()->getScaledDimensions(scale); |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 18 | } |
| 19 | |
Nigel Tao | 612a65d | 2018-11-09 10:10:31 +1100 | [diff] [blame] | 20 | bool SkAndroidCodecAdapter::onGetSupportedSubset(SkIRect* desiredSubset) const { |
msarett | 90c4d5f | 2015-12-10 13:09:24 -0800 | [diff] [blame] | 21 | return this->codec()->getValidSubset(desiredSubset); |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Nigel Tao | 612a65d | 2018-11-09 10:10:31 +1100 | [diff] [blame] | 24 | SkCodec::Result SkAndroidCodecAdapter::onGetAndroidPixels(const SkImageInfo& info, void* pixels, |
scroggo | e95a068 | 2015-11-04 04:31:12 -0800 | [diff] [blame] | 25 | size_t rowBytes, const AndroidOptions& options) { |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 26 | SkCodec::Options codecOptions; |
| 27 | codecOptions.fZeroInitialized = options.fZeroInitialized; |
| 28 | codecOptions.fSubset = options.fSubset; |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 29 | return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions); |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 30 | } |