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 GrGLSLPrimitiveProcessor_DEFINED |
9 #define GrGLPrimitiveProcessor_DEFINED | 9 #define GrGLSLPrimitiveProcessor_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 GrGLSLGPBuilder; | 18 class GrGLSLGPBuilder; |
19 | 19 |
20 class GrGLPrimitiveProcessor { | 20 class GrGLSLPrimitiveProcessor { |
21 public: | 21 public: |
22 virtual ~GrGLPrimitiveProcessor() {} | 22 virtual ~GrGLSLPrimitiveProcessor() {} |
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(GrGLSLGPBuilder* pb, | 32 EmitArgs(GrGLSLGPBuilder* pb, |
(...skipping 19 matching lines...) Expand all Loading... |
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. |
57 * This allows the effect subclass to emit vertex code. | 57 * This allows the effect subclass to emit vertex code. |
58 */ | 58 */ |
59 virtual void emitCode(EmitArgs&) = 0; | 59 virtual void emitCode(EmitArgs&) = 0; |
60 | 60 |
61 | 61 |
62 /** A GrGLPrimitiveProcessor instance can be reused with any GrGLPrimitivePr
ocessor that | 62 /** A GrGLSLPrimitiveProcessor instance can be reused with any GrGLSLPrimiti
veProcessor that |
63 produces the same stage key; this function reads data from a GrGLPrimiti
veProcessor and | 63 produces the same stage key; this function reads data from a GrGLSLPrimi
tiveProcessor and |
64 uploads any uniform variables required by the shaders created in emitCo
de(). The | 64 uploads any uniform variables required by the shaders created in emitCo
de(). The |
65 GrPrimitiveProcessor parameter is guaranteed to be of the same type that
created this | 65 GrPrimitiveProcessor parameter is guaranteed to be of the same type that
created this |
66 GrGLPrimitiveProcessor and to have an identical processor key as the one
that created this | 66 GrGLSLPrimitiveProcessor and to have an identical processor key as the o
ne that created this |
67 GrGLPrimitiveProcessor. */ | 67 GrGLSLPrimitiveProcessor. */ |
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(GrGLSLGPBuilder* pb, | 78 void setupUniformColor(GrGLSLGPBuilder* pb, |
79 const char* outputName, | 79 const char* outputName, |
80 UniformHandle* colorUniform); | 80 UniformHandle* colorUniform); |
81 | 81 |
82 struct Transform { | 82 struct Transform { |
83 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } | 83 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } |
84 UniformHandle fHandle; | 84 UniformHandle fHandle; |
85 SkMatrix fCurrentValue; | 85 SkMatrix fCurrentValue; |
86 GrSLType fType; | 86 GrSLType fType; |
87 }; | 87 }; |
88 | 88 |
89 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; | 89 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; |
90 }; | 90 }; |
91 | 91 |
92 #endif | 92 #endif |
OLD | NEW |