OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLXferProcessor_DEFINED | 8 #ifndef GrGLSLXferProcessor_DEFINED |
9 #define GrGLXferProcessor_DEFINED | 9 #define GrGLSLXferProcessor_DEFINED |
10 | 10 |
11 #include "glsl/GrGLSLProgramDataManager.h" | 11 #include "glsl/GrGLSLProgramDataManager.h" |
12 #include "glsl/GrGLSLTextureSampler.h" | 12 #include "glsl/GrGLSLTextureSampler.h" |
13 | 13 |
14 class GrGLSLXPBuilder; | 14 class GrGLSLXPBuilder; |
15 class GrXferProcessor; | 15 class GrXferProcessor; |
16 | 16 |
17 class GrGLXferProcessor { | 17 class GrGLSLXferProcessor { |
18 public: | 18 public: |
19 GrGLXferProcessor() {} | 19 GrGLSLXferProcessor() {} |
20 virtual ~GrGLXferProcessor() {} | 20 virtual ~GrGLSLXferProcessor() {} |
21 | 21 |
22 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; | 22 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; |
23 struct EmitArgs { | 23 struct EmitArgs { |
24 EmitArgs(GrGLSLXPBuilder* pb, | 24 EmitArgs(GrGLSLXPBuilder* pb, |
25 const GrXferProcessor& xp, | 25 const GrXferProcessor& xp, |
26 const char* inputColor, | 26 const char* inputColor, |
27 const char* inputCoverage, | 27 const char* inputCoverage, |
28 const char* outputPrimary, | 28 const char* outputPrimary, |
29 const char* outputSecondary, | 29 const char* outputSecondary, |
30 const TextureSamplerArray& samplers) | 30 const TextureSamplerArray& samplers) |
(...skipping 12 matching lines...) Expand all Loading... |
43 const char* fOutputPrimary; | 43 const char* fOutputPrimary; |
44 const char* fOutputSecondary; | 44 const char* fOutputSecondary; |
45 const TextureSamplerArray& fSamplers; | 45 const TextureSamplerArray& fSamplers; |
46 }; | 46 }; |
47 /** | 47 /** |
48 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. | 48 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. |
49 * This allows the effect subclass to emit vertex code. | 49 * This allows the effect subclass to emit vertex code. |
50 */ | 50 */ |
51 void emitCode(const EmitArgs&); | 51 void emitCode(const EmitArgs&); |
52 | 52 |
53 /** A GrGLXferProcessor instance can be reused with any GrGLXferProcessor th
at produces | 53 /** A GrGLSLXferProcessor instance can be reused with any GrGLSLXferProcesso
r that produces |
54 the same stage key; this function reads data from a GrGLXferProcessor an
d uploads any | 54 the same stage key; this function reads data from a GrGLSLXferProcessor
and uploads any |
55 uniform variables required by the shaders created in emitCode(). The Gr
XferProcessor | 55 uniform variables required by the shaders created in emitCode(). The Gr
XferProcessor |
56 parameter is guaranteed to be of the same type that created this GrGLXfe
rProcessor and | 56 parameter is guaranteed to be of the same type that created this GrGLSLX
ferProcessor and |
57 to have an identical processor key as the one that created this GrGLXfer
Processor. This | 57 to have an identical processor key as the one that created this GrGLSLXf
erProcessor. This |
58 function calls onSetData on the subclass of GrGLXferProcessor | 58 function calls onSetData on the subclass of GrGLSLXferProcessor |
59 */ | 59 */ |
60 void setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp)
; | 60 void setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp)
; |
61 | 61 |
62 private: | 62 private: |
63 /** | 63 /** |
64 * Called by emitCode() when the XP will not be performing a dst read. This
method is | 64 * Called by emitCode() when the XP will not be performing a dst read. This
method is |
65 * responsible for both blending and coverage. A subclass only needs to impl
ement this method if | 65 * responsible for both blending and coverage. A subclass only needs to impl
ement this method if |
66 * it can construct a GrXferProcessor that will not read the dst color. | 66 * it can construct a GrXferProcessor that will not read the dst color. |
67 */ | 67 */ |
68 virtual void emitOutputsForBlendState(const EmitArgs&) { | 68 virtual void emitOutputsForBlendState(const EmitArgs&) { |
(...skipping 12 matching lines...) Expand all Loading... |
81 const GrXferProcessor&) { | 81 const GrXferProcessor&) { |
82 SkFAIL("emitBlendCodeForDstRead not implemented."); | 82 SkFAIL("emitBlendCodeForDstRead not implemented."); |
83 } | 83 } |
84 | 84 |
85 virtual void onSetData(const GrGLSLProgramDataManager&, const GrXferProcesso
r&) = 0; | 85 virtual void onSetData(const GrGLSLProgramDataManager&, const GrXferProcesso
r&) = 0; |
86 | 86 |
87 GrGLSLProgramDataManager::UniformHandle fDstTopLeftUni; | 87 GrGLSLProgramDataManager::UniformHandle fDstTopLeftUni; |
88 GrGLSLProgramDataManager::UniformHandle fDstScaleUni; | 88 GrGLSLProgramDataManager::UniformHandle fDstScaleUni; |
89 }; | 89 }; |
90 #endif | 90 #endif |
OLD | NEW |