xref: /aosp_15_r20/external/skia/src/codec/SkAndroidCodecAdapter.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 SkAndroidCodecAdapter_DEFINED
8 #define SkAndroidCodecAdapter_DEFINED
9 
10 #include "include/codec/SkAndroidCodec.h"
11 #include "include/codec/SkCodec.h"
12 #include "include/core/SkSize.h"
13 
14 #include <cstddef>
15 
16 struct SkIRect;
17 struct SkImageInfo;
18 
19 /**
20  *  This class wraps SkCodec to implement the functionality of SkAndroidCodec.
21  *  The underlying SkCodec implements sampled decodes.  SkCodec's that do not
22  *  implement that are wrapped with SkSampledCodec instead.
23  */
24 class SkAndroidCodecAdapter : public SkAndroidCodec {
25 public:
26 
27     explicit SkAndroidCodecAdapter(SkCodec*);
28 
~SkAndroidCodecAdapter()29     ~SkAndroidCodecAdapter() override {}
30 
31 protected:
32 
33     SkISize onGetSampledDimensions(int sampleSize) const override;
34 
35     bool onGetSupportedSubset(SkIRect* desiredSubset) const override;
36 
37     SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
38             const AndroidOptions& options) override;
39 
40 private:
41 
42     using INHERITED = SkAndroidCodec;
43 };
44 #endif // SkAndroidCodecAdapter_DEFINED
45