xref: /aosp_15_r20/external/skia/experimental/rust_png/encoder/SkPngRustEncoder.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2024 Google LLC.
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 SkPngRustEncoder_DEFINED
8 #define SkPngRustEncoder_DEFINED
9 
10 #include <memory>
11 
12 #include "include/private/base/SkAPI.h"
13 
14 class SkEncoder;
15 class SkPixmap;
16 class SkWStream;
17 
18 namespace SkPngRustEncoder {
19 
20 /**
21  *  Encode the |src| pixels to the |dst| stream.
22  *  |options| may be used to control the encoding behavior.
23  *
24  *  Returns true on success.  Returns false on an invalid or unsupported |src|.
25  *
26  *  TODO(https://crbug.com/379312510): Add support for `SkPngEncoder::Options`
27  *  like:
28  *  * Comments - `tEXt` chunks.
29  *  * Color profile - `iCCP` chunk.
30  *  * Filter choice and compression level
31  */
32 SK_API bool Encode(SkWStream* dst, const SkPixmap& src);
33 
34 /**
35  *  Create a png encoder that will encode the |src| pixels to the |dst| stream.
36  *  |options| may be used to control the encoding behavior.
37  *
38  *  The primary use of this is incremental encoding of the pixels.
39  *
40  *  |dst| is unowned but must remain valid for the lifetime of the object.
41  *
42  *  This returns nullptr on an invalid or unsupported |src|.
43  *
44  *  TODO(https://crbug.com/379312510): Add support for `SkPngEncoder::Options`.
45  */
46 SK_API std::unique_ptr<SkEncoder> Make(SkWStream* dst, const SkPixmap& src);
47 
48 }  // namespace SkPngRustEncoder
49 
50 #endif  // SkPngRustEncoder_DEFINED
51