OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2014 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 GrGLXferProcessor_DEFINED | |
9 #define GrGLXferProcessor_DEFINED | |
10 | |
11 #include "glsl/GrGLSLProgramDataManager.h" | |
12 #include "glsl/GrGLSLTextureSampler.h" | |
13 | |
14 class GrGLSLXPBuilder; | |
15 class GrXferProcessor; | |
16 | |
17 class GrGLXferProcessor { | |
18 public: | |
19 GrGLXferProcessor() {} | |
20 virtual ~GrGLXferProcessor() {} | |
21 | |
22 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; | |
23 struct EmitArgs { | |
24 EmitArgs(GrGLSLXPBuilder* pb, | |
25 const GrXferProcessor& xp, | |
26 const char* inputColor, | |
27 const char* inputCoverage, | |
28 const char* outputPrimary, | |
29 const char* outputSecondary, | |
30 const TextureSamplerArray& samplers) | |
31 : fPB(pb) | |
32 , fXP(xp) | |
33 , fInputColor(inputColor) | |
34 , fInputCoverage(inputCoverage) | |
35 , fOutputPrimary(outputPrimary) | |
36 , fOutputSecondary(outputSecondary) | |
37 , fSamplers(samplers) {} | |
38 | |
39 GrGLSLXPBuilder* fPB; | |
40 const GrXferProcessor& fXP; | |
41 const char* fInputColor; | |
42 const char* fInputCoverage; | |
43 const char* fOutputPrimary; | |
44 const char* fOutputSecondary; | |
45 const TextureSamplerArray& fSamplers; | |
46 }; | |
47 /** | |
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. | |
50 */ | |
51 void emitCode(const EmitArgs&); | |
52 | |
53 /** A GrGLXferProcessor instance can be reused with any GrGLXferProcessor th
at produces | |
54 the same stage key; this function reads data from a GrGLXferProcessor an
d uploads any | |
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 | |
57 to have an identical processor key as the one that created this GrGLXfer
Processor. This | |
58 function calls onSetData on the subclass of GrGLXferProcessor | |
59 */ | |
60 void setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp)
; | |
61 | |
62 private: | |
63 /** | |
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 | |
66 * it can construct a GrXferProcessor that will not read the dst color. | |
67 */ | |
68 virtual void emitOutputsForBlendState(const EmitArgs&) { | |
69 SkFAIL("emitOutputsForBlendState not implemented."); | |
70 } | |
71 | |
72 /** | |
73 * Called by emitCode() when the XP will perform a dst read. This method onl
y needs to supply | |
74 * the blending logic. The base class applies coverage. A subclass only need
s to implement this | |
75 * method if it can construct a GrXferProcessor that reads the dst color. | |
76 */ | |
77 virtual void emitBlendCodeForDstRead(GrGLSLXPBuilder*, | |
78 const char* srcColor, | |
79 const char* dstColor, | |
80 const char* outColor, | |
81 const GrXferProcessor&) { | |
82 SkFAIL("emitBlendCodeForDstRead not implemented."); | |
83 } | |
84 | |
85 virtual void onSetData(const GrGLSLProgramDataManager&, const GrXferProcesso
r&) = 0; | |
86 | |
87 GrGLSLProgramDataManager::UniformHandle fDstTopLeftUni; | |
88 GrGLSLProgramDataManager::UniformHandle fDstScaleUni; | |
89 }; | |
90 #endif | |
OLD | NEW |