xref: /aosp_15_r20/external/skia/include/gpu/graphite/precompile/PrecompileBlender.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 
8 #ifndef skgpu_graphite_precompile_PrecompileBlender_DEFINED
9 #define skgpu_graphite_precompile_PrecompileBlender_DEFINED
10 
11 #include "include/core/SkBlendMode.h"
12 #include "include/gpu/graphite/precompile/PrecompileBase.h"
13 
14 #include <optional>
15 
16 namespace skgpu::graphite {
17 
18 class PrecompileBlenderPriv;
19 
20 /** \class PrecompileBlender
21     This class corresponds to the SkBlender class in the main API.
22 */
23 class SK_API PrecompileBlender : public PrecompileBase {
24 public:
25     // Provides access to functions that aren't part of the public API.
26     PrecompileBlenderPriv priv();
27     const PrecompileBlenderPriv priv() const;  // NOLINT(readability-const-return-type)
28 
29 protected:
30     friend class PrecompileBlenderPriv;
31 
asBlendMode()32     virtual std::optional<SkBlendMode> asBlendMode() const { return {}; }
33 
PrecompileBlender()34     PrecompileBlender() : PrecompileBase(Type::kBlender) {}
35     ~PrecompileBlender() override;
36 };
37 
38 //--------------------------------------------------------------------------------------------------
39 // This is the Precompile correlate to the SkBlenders namespace in the main API
40 namespace PrecompileBlenders {
41 
42     // This factory creates a Precompilation object that represents the Arithmetic SkBlender from
43     // the main API. Note that the actual Arithmetic parameters (i.e., k1, k2, k3 and k4) are
44     // abstracted away since they do not impact the generated shader.
45     SK_API sk_sp<PrecompileBlender> Arithmetic();
46 
47     // This is the Precompilation correlate to the SkBlender::Mode factory in the main API. It
48     // creates an object that represents SkBlendMode-based blending.
49     SK_API sk_sp<PrecompileBlender> Mode(SkBlendMode);
50 
51 } // namespace PrecompileBlenders
52 
53 
54 } // namespace skgpu::graphite
55 
56 #endif // skgpu_graphite_precompile_PrecompileBlender_DEFINED
57