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 GrGLGeometryProcessor_DEFINED | 8 #ifndef GrGLGeometryProcessor_DEFINED |
9 #define GrGLGeometryProcessor_DEFINED | 9 #define GrGLGeometryProcessor_DEFINED |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 template <class GeometryProcessor> | 34 template <class GeometryProcessor> |
35 void setTransformDataHelper(const GrPrimitiveProcessor& primProc, | 35 void setTransformDataHelper(const GrPrimitiveProcessor& primProc, |
36 const GrGLProgramDataManager& pdman, | 36 const GrGLProgramDataManager& pdman, |
37 int index, | 37 int index, |
38 const SkTArray<const GrCoordTransform*, true>& t
ransforms) { | 38 const SkTArray<const GrCoordTransform*, true>& t
ransforms) { |
39 const GeometryProcessor& gp = primProc.cast<GeometryProcessor>(); | 39 const GeometryProcessor& gp = primProc.cast<GeometryProcessor>(); |
40 this->setTransformDataMatrix(gp.localMatrix(), pdman, index, transforms)
; | 40 this->setTransformDataMatrix(gp.localMatrix(), pdman, index, transforms)
; |
41 } | 41 } |
42 | 42 |
43 protected: | 43 protected: |
44 // A helper for subclasses which don't have an explicit local matrix | 44 // Emit a uniform matrix for each coord transform. |
45 void emitTransforms(GrGLGPBuilder* gp, | 45 void emitTransforms(GrGLGPBuilder* gp, |
46 const GrShaderVar& posVar, | 46 const GrShaderVar& posVar, |
47 const char* localCoords, | 47 const char* localCoords, |
48 const TransformsIn& tin, | 48 const TransformsIn& tin, |
49 TransformsOut* tout) { | 49 TransformsOut* tout) { |
50 this->emitTransforms(gp, posVar, localCoords, SkMatrix::I(), tin, tout); | 50 this->emitTransforms(gp, posVar, localCoords, SkMatrix::I(), tin, tout); |
51 } | 51 } |
52 | 52 |
| 53 // Emit pre-transformed coords as a vertex attribute per coord-transform. |
53 void emitTransforms(GrGLGPBuilder*, | 54 void emitTransforms(GrGLGPBuilder*, |
54 const GrShaderVar& posVar, | 55 const GrShaderVar& posVar, |
55 const char* localCoords, | 56 const char* localCoords, |
56 const SkMatrix& localMatrix, | 57 const SkMatrix& localMatrix, |
57 const TransformsIn&, | 58 const TransformsIn&, |
58 TransformsOut*); | 59 TransformsOut*); |
59 | 60 |
| 61 // caller has emitted transforms via attributes |
| 62 void emitTransforms(GrGLGPBuilder*, |
| 63 const char* localCoords, |
| 64 const TransformsIn& tin, |
| 65 TransformsOut* tout); |
| 66 |
60 struct GrGPArgs { | 67 struct GrGPArgs { |
61 // The variable used by a GP to store its position. It can be | 68 // The variable used by a GP to store its position. It can be |
62 // either a vec2 or a vec3 depending on the presence of perspective. | 69 // either a vec2 or a vec3 depending on the presence of perspective. |
63 GrShaderVar fPositionVar; | 70 GrShaderVar fPositionVar; |
64 }; | 71 }; |
65 | 72 |
66 // Create the correct type of position variable given the CTM | 73 // Create the correct type of position variable given the CTM |
67 void setupPosition(GrGLGPBuilder*, GrGPArgs*, const char* posName); | 74 void setupPosition(GrGLGPBuilder*, GrGPArgs*, const char* posName); |
68 void setupPosition(GrGLGPBuilder*, GrGPArgs*, const char* posName, const SkM
atrix& mat, | 75 void setupPosition(GrGLGPBuilder*, GrGPArgs*, const char* posName, const SkM
atrix& mat, |
69 UniformHandle* viewMatrixUniform); | 76 UniformHandle* viewMatrixUniform); |
(...skipping 24 matching lines...) Expand all Loading... |
94 } | 101 } |
95 } | 102 } |
96 } | 103 } |
97 | 104 |
98 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; | 105 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; |
99 | 106 |
100 typedef GrGLPrimitiveProcessor INHERITED; | 107 typedef GrGLPrimitiveProcessor INHERITED; |
101 }; | 108 }; |
102 | 109 |
103 #endif | 110 #endif |
OLD | NEW |