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