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 GrGLPrimitiveProcessor_DEFINED | 8 #ifndef GrGLPrimitiveProcessor_DEFINED |
9 #define GrGLPrimitiveProcessor_DEFINED | 9 #define GrGLPrimitiveProcessor_DEFINED |
10 | 10 |
11 #include "GrPrimitiveProcessor.h" | 11 #include "GrPrimitiveProcessor.h" |
12 #include "glsl/GrGLSLProcessorTypes.h" | 12 #include "glsl/GrGLSLProcessorTypes.h" |
13 #include "glsl/GrGLSLProgramDataManager.h" | 13 #include "glsl/GrGLSLProgramDataManager.h" |
14 #include "glsl/GrGLSLTextureSampler.h" | 14 #include "glsl/GrGLSLTextureSampler.h" |
15 | 15 |
16 class GrBatchTracker; | 16 class GrBatchTracker; |
17 class GrPrimitiveProcessor; | 17 class GrPrimitiveProcessor; |
18 class GrGLGPBuilder; | 18 class GrGLSLGPBuilder; |
19 | 19 |
20 class GrGLPrimitiveProcessor { | 20 class GrGLPrimitiveProcessor { |
21 public: | 21 public: |
22 virtual ~GrGLPrimitiveProcessor() {} | 22 virtual ~GrGLPrimitiveProcessor() {} |
23 | 23 |
24 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 24 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
25 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; | 25 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; |
26 | 26 |
27 typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords; | 27 typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords; |
28 typedef SkSTArray<8, ProcCoords> TransformsIn; | 28 typedef SkSTArray<8, ProcCoords> TransformsIn; |
29 typedef SkSTArray<8, GrGLSLTransformedCoordsArray> TransformsOut; | 29 typedef SkSTArray<8, GrGLSLTransformedCoordsArray> TransformsOut; |
30 | 30 |
31 struct EmitArgs { | 31 struct EmitArgs { |
32 EmitArgs(GrGLGPBuilder* pb, | 32 EmitArgs(GrGLSLGPBuilder* pb, |
33 const GrPrimitiveProcessor& gp, | 33 const GrPrimitiveProcessor& gp, |
34 const char* outputColor, | 34 const char* outputColor, |
35 const char* outputCoverage, | 35 const char* outputCoverage, |
36 const TextureSamplerArray& samplers, | 36 const TextureSamplerArray& samplers, |
37 const TransformsIn& transformsIn, | 37 const TransformsIn& transformsIn, |
38 TransformsOut* transformsOut) | 38 TransformsOut* transformsOut) |
39 : fPB(pb) | 39 : fPB(pb) |
40 , fGP(gp) | 40 , fGP(gp) |
41 , fOutputColor(outputColor) | 41 , fOutputColor(outputColor) |
42 , fOutputCoverage(outputCoverage) | 42 , fOutputCoverage(outputCoverage) |
43 , fSamplers(samplers) | 43 , fSamplers(samplers) |
44 , fTransformsIn(transformsIn) | 44 , fTransformsIn(transformsIn) |
45 , fTransformsOut(transformsOut) {} | 45 , fTransformsOut(transformsOut) {} |
46 GrGLGPBuilder* fPB; | 46 GrGLSLGPBuilder* fPB; |
47 const GrPrimitiveProcessor& fGP; | 47 const GrPrimitiveProcessor& fGP; |
48 const char* fOutputColor; | 48 const char* fOutputColor; |
49 const char* fOutputCoverage; | 49 const char* fOutputCoverage; |
50 const TextureSamplerArray& fSamplers; | 50 const TextureSamplerArray& fSamplers; |
51 const TransformsIn& fTransformsIn; | 51 const TransformsIn& fTransformsIn; |
52 TransformsOut* fTransformsOut; | 52 TransformsOut* fTransformsOut; |
53 }; | 53 }; |
54 | 54 |
55 /** | 55 /** |
56 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. | 56 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. |
(...skipping 11 matching lines...) Expand all Loading... |
68 virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProce
ssor&) = 0; | 68 virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProce
ssor&) = 0; |
69 | 69 |
70 static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoor
dTransform&); | 70 static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoor
dTransform&); |
71 | 71 |
72 virtual void setTransformData(const GrPrimitiveProcessor&, | 72 virtual void setTransformData(const GrPrimitiveProcessor&, |
73 const GrGLSLProgramDataManager& pdman, | 73 const GrGLSLProgramDataManager& pdman, |
74 int index, | 74 int index, |
75 const SkTArray<const GrCoordTransform*, true>&
transforms) = 0; | 75 const SkTArray<const GrCoordTransform*, true>&
transforms) = 0; |
76 | 76 |
77 protected: | 77 protected: |
78 void setupUniformColor(GrGLGPBuilder* pb, const char* outputName, UniformHan
dle* colorUniform); | 78 void setupUniformColor(GrGLSLGPBuilder* pb, const char* outputName, UniformH
andle* colorUniform); |
79 | 79 |
80 struct Transform { | 80 struct Transform { |
81 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } | 81 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } |
82 UniformHandle fHandle; | 82 UniformHandle fHandle; |
83 SkMatrix fCurrentValue; | 83 SkMatrix fCurrentValue; |
84 GrSLType fType; | 84 GrSLType fType; |
85 }; | 85 }; |
86 | 86 |
87 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; | 87 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; |
88 }; | 88 }; |
89 | 89 |
90 #endif | 90 #endif |
OLD | NEW |