OLD | NEW |
(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 #ifndef SkSampledCodec_DEFINED |
| 8 #define SkSampledCodec_DEFINED |
| 9 |
| 10 #include "SkAndroidCodec.h" |
| 11 #include "SkCodec.h" |
| 12 |
| 13 /** |
| 14 * This class implements the functionality of SkAndroidCodec. Scaling will |
| 15 * be provided by sampling if it cannot be provided by fCodec. |
| 16 */ |
| 17 class SkSampledCodec : public SkAndroidCodec { |
| 18 public: |
| 19 |
| 20 explicit SkSampledCodec(SkCodec*); |
| 21 |
| 22 virtual ~SkSampledCodec() {} |
| 23 |
| 24 protected: |
| 25 |
| 26 SkEncodedFormat onGetEncodedFormat() const override { return fCodec->getEnco
dedFormat(); }; |
| 27 |
| 28 SkISize onGetSampledDimensions(int sampleSize) const override; |
| 29 |
| 30 bool onGetSupportedSubset(SkIRect* desiredSubset) const override { return tr
ue; } |
| 31 |
| 32 SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels, si
ze_t rowBytes, |
| 33 AndroidOptions& options) override; |
| 34 |
| 35 private: |
| 36 |
| 37 /** |
| 38 * This fulfills the same contract as onGetAndroidPixels(). |
| 39 * |
| 40 * We call this function from onGetAndroidPixels() if we have determined |
| 41 * that fCodec does not support the requested scale, and we need to |
| 42 * provide the scale by sampling. |
| 43 */ |
| 44 SkCodec::Result sampledDecode(const SkImageInfo& info, void* pixels, size_t
rowBytes, |
| 45 AndroidOptions& options); |
| 46 |
| 47 SkAutoTDelete<SkCodec> fCodec; |
| 48 |
| 49 typedef SkAndroidCodec INHERITED; |
| 50 }; |
| 51 #endif // SkSampledCodec_DEFINED |
OLD | NEW |