OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLFragmentProcessor_DEFINED | 8 #ifndef GrGLFragmentProcessor_DEFINED |
9 #define GrGLFragmentProcessor_DEFINED | 9 #define GrGLFragmentProcessor_DEFINED |
10 | 10 |
11 #include "GrGLProgramDataManager.h" | 11 #include "GrGLProgramDataManager.h" |
12 #include "GrGLProcessor.h" | 12 #include "GrGLProcessor.h" |
13 #include "GrTextureAccess.h" | 13 #include "GrTextureAccess.h" |
14 | 14 |
15 class GrGLFPBuilder; | 15 class GrGLFPBuilder; |
16 | 16 |
17 class GrGLFragmentProcessor { | 17 class GrGLFragmentProcessor { |
18 public: | 18 public: |
19 GrGLFragmentProcessor() {} | 19 GrGLFragmentProcessor() {} |
20 | 20 |
21 virtual ~GrGLFragmentProcessor() {} | 21 virtual ~GrGLFragmentProcessor() { |
| 22 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 23 SkDELETE(fChildProcessors[i]); |
| 24 } |
| 25 } |
22 | 26 |
23 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 27 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
24 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; | 28 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; |
25 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; | 29 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; |
26 | 30 |
27 /** Called when the program stage should insert its code into the shaders. T
he code in each | 31 /** Called when the program stage should insert its code into the shaders. T
he code in each |
28 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 32 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
29 stages. | 33 stages. |
30 | 34 |
31 @param builder Interface used to emit code in the shaders. | 35 @param builder Interface used to emit code in the shaders. |
(...skipping 27 matching lines...) Expand all Loading... |
59 GrGLFPBuilder* fBuilder; | 63 GrGLFPBuilder* fBuilder; |
60 const GrFragmentProcessor& fFp; | 64 const GrFragmentProcessor& fFp; |
61 const char* fOutputColor; | 65 const char* fOutputColor; |
62 const char* fInputColor; | 66 const char* fInputColor; |
63 const TransformedCoordsArray& fCoords; | 67 const TransformedCoordsArray& fCoords; |
64 const TextureSamplerArray& fSamplers; | 68 const TextureSamplerArray& fSamplers; |
65 }; | 69 }; |
66 | 70 |
67 virtual void emitCode(EmitArgs&) = 0; | 71 virtual void emitCode(EmitArgs&) = 0; |
68 | 72 |
69 /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProces
sor that produces | 73 void setData(const GrGLProgramDataManager& pdman, const GrFragmentProcessor&
processor); |
70 the same stage key; this function reads data from a GrFragmentProcessor
and uploads any | |
71 uniform variables required by the shaders created in emitCode(). The GrF
ragmentProcessor | |
72 parameter is guaranteed to be of the same type that created this GrGLFra
gmentProcessor and | |
73 to have an identical processor key as the one that created this GrGLFrag
mentProcessor. */ | |
74 // TODO update this to pass in GrFragmentProcessor | |
75 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} | |
76 | 74 |
77 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | 75 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
78 | 76 |
| 77 int numChildProcessors() const { return fChildProcessors.count(); } |
| 78 |
| 79 GrGLFragmentProcessor* childProcessor(int index) const { |
| 80 return fChildProcessors[index]; |
| 81 } |
| 82 |
| 83 protected: |
| 84 /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProces
sor that produces |
| 85 the same stage key; this function reads data from a GrFragmentProcessor and
uploads any |
| 86 uniform variables required by the shaders created in emitCode(). The GrFragm
entProcessor |
| 87 parameter is guaranteed to be of the same type that created this GrGLFragmen
tProcessor and |
| 88 to have an identical processor key as the one that created this GrGLFragment
Processor. */ |
| 89 // TODO update this to pass in GrFragmentProcessor |
| 90 virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {} |
| 91 |
79 private: | 92 private: |
| 93 SkTArray<GrGLFragmentProcessor*, true> fChildProcessors; |
| 94 |
| 95 friend class GrFragmentProcessor; |
80 typedef GrGLProcessor INHERITED; | 96 typedef GrGLProcessor INHERITED; |
81 }; | 97 }; |
82 | 98 |
83 #endif | 99 #endif |
OLD | NEW |