OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrDefaultGeoProcFactory_DEFINED | 8 #ifndef GrDefaultGeoProcFactory_DEFINED |
9 #define GrDefaultGeoProcFactory_DEFINED | 9 #define GrDefaultGeoProcFactory_DEFINED |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 Coverage(Type type) : fType(type), fCoverage(0xff) { | 104 Coverage(Type type) : fType(type), fCoverage(0xff) { |
105 SkASSERT(type != kUniform_Type); | 105 SkASSERT(type != kUniform_Type); |
106 } | 106 } |
107 | 107 |
108 Type fType; | 108 Type fType; |
109 uint8_t fCoverage; | 109 uint8_t fCoverage; |
110 }; | 110 }; |
111 | 111 |
112 struct LocalCoords { | 112 struct LocalCoords { |
113 enum Type { | 113 enum Type { |
114 kNone_Type, | 114 kUnused_Type, |
115 kUsePosition_Type, | 115 kUsePosition_Type, |
116 kHasExplicit_Type, | 116 kHasExplicit_Type, |
117 }; | 117 }; |
118 LocalCoords(Type type) : fType(type), fMatrix(NULL) {} | |
119 LocalCoords(Type type, const SkMatrix* matrix) : fType(type), fMatrix(ma trix) { | |
120 SkASSERT(kUnused_Type != type); | |
121 } | |
122 bool hasLocalMatrix() const { return NULL != fMatrix; } | |
123 | |
124 Type fType; | |
125 const SkMatrix* fMatrix; | |
118 }; | 126 }; |
119 | 127 |
120 static const GrGeometryProcessor* Create(const Color&, | 128 static const GrGeometryProcessor* Create(const Color&, |
121 const Coverage&, | 129 const Coverage&, |
122 LocalCoords::Type, | 130 const LocalCoords&, |
123 const SkMatrix& viewMatrix = SkMatr ix::I(), | 131 const SkMatrix& viewMatrix = SkMatr ix::I()); |
124 const SkMatrix& localMatrix = SkMat rix::I()); | 132 |
133 // can fail if the viewmatrix is noninvertible | |
bsalomon
2015/07/28 14:39:08
I think this needs a little bit of explanation. "U
| |
134 static const GrGeometryProcessor* CreateForDeviceSpace(const Color&, | |
135 const Coverage&, | |
136 const LocalCoords&, | |
137 const SkMatrix& viewM atrix); | |
125 | 138 |
126 /* | 139 /* |
127 * The following functions are used to create default GPs. If you just need to create | 140 * The following functions are used to create default GPs. If you just need to create |
128 * attributes separately from creating the default GP, use the SetAttribs fu nction followed | 141 * attributes separately from creating the default GP, use the SetAttribs fu nction followed |
129 * by the Create function. Otherwise use CreateAndSetAttribs to do both at o nce. | 142 * by the Create function. Otherwise use CreateAndSetAttribs to do both at o nce. |
130 * | 143 * |
131 * You must unref the return from Create. | 144 * You must unref the return from Create. |
132 */ | 145 */ |
133 // TODO clean this up | 146 // TODO clean this up |
134 static const GrGeometryProcessor* Create(uint32_t gpTypeFlags, | 147 static const GrGeometryProcessor* Create(uint32_t gpTypeFlags, |
135 GrColor, | 148 GrColor, |
136 bool localCoordsWillBeRead, | 149 bool localCoordsWillBeRead, |
137 bool coverageWillBeIgnored, | 150 bool coverageWillBeIgnored, |
138 const SkMatrix& viewMatrix = SkMatr ix::I(), | 151 const SkMatrix& viewMatrix = SkMatr ix::I(), |
139 const SkMatrix& localMatrix = SkMat rix::I(), | 152 const SkMatrix& localMatrix = SkMat rix::I(), |
140 uint8_t coverage = 0xff); | 153 uint8_t coverage = 0xff); |
141 | 154 |
142 static size_t DefaultVertexStride() { return sizeof(PositionAttr); } | 155 static size_t DefaultVertexStride() { return sizeof(PositionAttr); } |
143 }; | 156 }; |
144 | 157 |
145 #endif | 158 #endif |
OLD | NEW |