xref: /aosp_15_r20/external/skia/src/gpu/ganesh/glsl/GrGLSLBlend.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 
8 #ifndef GrGLBlend_DEFINED
9 #define GrGLBlend_DEFINED
10 
11 #include "src/gpu/ganesh/glsl/GrGLSLProgramDataManager.h"
12 
13 #include <string>
14 
15 class GrGLSLUniformHandler;
16 class GrProcessor;
17 enum class SkBlendMode;
18 
19 namespace GrGLSLBlend {
20 
21 /**
22  * Returns an SkSL expression that blends the passed-in srcColor and dstColor values.
23  * Matching calls to SetBlendModeUniformData and BlendKey must be made from your GrProcessor.
24  */
25 std::string BlendExpression(const GrProcessor* processor,
26                             GrGLSLUniformHandler* uniformHandler,
27                             GrGLSLProgramDataManager::UniformHandle* uniform,
28                             const char* srcColor,
29                             const char* dstColor,
30                             SkBlendMode mode);
31 
32 /**
33  * Returns a key, for use in onAddToKey from any GrProcessor. You must pass the same blend mode that
34  * was passed to BlendExpression
35  */
36 int BlendKey(SkBlendMode mode);
37 
38 /**
39  * Sets up uniforms, for use in onSetData from any GrProcessor. You must pass the same uniform and
40  * blend mode that were passed to BlendExpression.
41  */
42 void SetBlendModeUniformData(const GrGLSLProgramDataManager& pdman,
43                              GrGLSLProgramDataManager::UniformHandle uniform,
44                              SkBlendMode mode);
45 
46 }  // namespace GrGLSLBlend
47 
48 #endif
49