| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #ifndef SkSampledCodec_DEFINED | 7 #ifndef SkSampledCodec_DEFINED |
| 8 #define SkSampledCodec_DEFINED | 8 #define SkSampledCodec_DEFINED |
| 9 | 9 |
| 10 #include "SkAndroidCodec.h" | 10 #include "SkAndroidCodec.h" |
| 11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * This class implements the functionality of SkAndroidCodec. Scaling will | 14 * This class implements the functionality of SkAndroidCodec. Scaling will |
| 15 * be provided by sampling if it cannot be provided by fCodec. | 15 * be provided by sampling if it cannot be provided by fCodec. |
| 16 */ | 16 */ |
| 17 class SkSampledCodec : public SkAndroidCodec { | 17 class SkSampledCodec : public SkAndroidCodec { |
| 18 public: | 18 public: |
| 19 | 19 |
| 20 explicit SkSampledCodec(SkCodec*); | 20 explicit SkSampledCodec(SkCodec*); |
| 21 | 21 |
| 22 virtual ~SkSampledCodec() {} | 22 virtual ~SkSampledCodec() {} |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 | 25 |
| 26 SkEncodedFormat onGetEncodedFormat() const override { return fCodec->getEnco
dedFormat(); }; | |
| 27 | |
| 28 SkISize onGetSampledDimensions(int sampleSize) const override; | 26 SkISize onGetSampledDimensions(int sampleSize) const override; |
| 29 | 27 |
| 30 bool onGetSupportedSubset(SkIRect* desiredSubset) const override { return tr
ue; } | 28 bool onGetSupportedSubset(SkIRect* desiredSubset) const override { return tr
ue; } |
| 31 | 29 |
| 32 SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels, si
ze_t rowBytes, | 30 SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels, si
ze_t rowBytes, |
| 33 const AndroidOptions& options) override; | 31 const AndroidOptions& options) override; |
| 34 | 32 |
| 35 private: | 33 private: |
| 36 /** | 34 /** |
| 37 * Find the best way to account for native scaling. | 35 * Find the best way to account for native scaling. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 /** | 48 /** |
| 51 * This fulfills the same contract as onGetAndroidPixels(). | 49 * This fulfills the same contract as onGetAndroidPixels(). |
| 52 * | 50 * |
| 53 * We call this function from onGetAndroidPixels() if we have determined | 51 * We call this function from onGetAndroidPixels() if we have determined |
| 54 * that fCodec does not support the requested scale, and we need to | 52 * that fCodec does not support the requested scale, and we need to |
| 55 * provide the scale by sampling. | 53 * provide the scale by sampling. |
| 56 */ | 54 */ |
| 57 SkCodec::Result sampledDecode(const SkImageInfo& info, void* pixels, size_t
rowBytes, | 55 SkCodec::Result sampledDecode(const SkImageInfo& info, void* pixels, size_t
rowBytes, |
| 58 const AndroidOptions& options); | 56 const AndroidOptions& options); |
| 59 | 57 |
| 60 SkAutoTDelete<SkCodec> fCodec; | |
| 61 | |
| 62 typedef SkAndroidCodec INHERITED; | 58 typedef SkAndroidCodec INHERITED; |
| 63 }; | 59 }; |
| 64 #endif // SkSampledCodec_DEFINED | 60 #endif // SkSampledCodec_DEFINED |
| OLD | NEW |