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 #include "GrDefaultGeoProcFactory.h" | 8 #include "GrDefaultGeoProcFactory.h" |
9 | 9 |
10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 key |= def.coverageWillBeIgnored() << 9; | 124 key |= def.coverageWillBeIgnored() << 9; |
125 key |= def.hasVertexColor() << 10; | 125 key |= def.hasVertexColor() << 10; |
126 key |= def.hasVertexCoverage() << 11; | 126 key |= def.hasVertexCoverage() << 11; |
127 key |= def.coverage() == 0xff ? 0x1 << 12 : 0; | 127 key |= def.coverage() == 0xff ? 0x1 << 12 : 0; |
128 key |= def.localCoordsWillBeRead() && def.localMatrix().hasPerspecti
ve() ? 0x1 << 24 : | 128 key |= def.localCoordsWillBeRead() && def.localMatrix().hasPerspecti
ve() ? 0x1 << 24 : |
129
0x0; | 129
0x0; |
130 key |= ComputePosKey(def.viewMatrix()) << 25; | 130 key |= ComputePosKey(def.viewMatrix()) << 25; |
131 b->add32(key); | 131 b->add32(key); |
132 } | 132 } |
133 | 133 |
134 void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProce
ssor& gp) override { | 134 void setData(const GrGLSLProgramDataManager& pdman, |
| 135 const GrPrimitiveProcessor& gp) override { |
135 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>(); | 136 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>(); |
136 | 137 |
137 if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.
viewMatrix())) { | 138 if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.
viewMatrix())) { |
138 fViewMatrix = dgp.viewMatrix(); | 139 fViewMatrix = dgp.viewMatrix(); |
139 GrGLfloat viewMatrix[3 * 3]; | 140 float viewMatrix[3 * 3]; |
140 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 141 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
141 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 142 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
142 } | 143 } |
143 | 144 |
144 if (dgp.color() != fColor && !dgp.hasVertexColor()) { | 145 if (dgp.color() != fColor && !dgp.hasVertexColor()) { |
145 GrGLfloat c[4]; | 146 float c[4]; |
146 GrColorToRGBAFloat(dgp.color(), c); | 147 GrColorToRGBAFloat(dgp.color(), c); |
147 pdman.set4fv(fColorUniform, 1, c); | 148 pdman.set4fv(fColorUniform, 1, c); |
148 fColor = dgp.color(); | 149 fColor = dgp.color(); |
149 } | 150 } |
150 | 151 |
151 if (!dgp.coverageWillBeIgnored() && | 152 if (!dgp.coverageWillBeIgnored() && |
152 dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) { | 153 dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) { |
153 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverag
e())); | 154 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverag
e())); |
154 fCoverage = dgp.coverage(); | 155 fCoverage = dgp.coverage(); |
155 } | 156 } |
156 } | 157 } |
157 | 158 |
158 void setTransformData(const GrPrimitiveProcessor& primProc, | 159 void setTransformData(const GrPrimitiveProcessor& primProc, |
159 const GrGLProgramDataManager& pdman, | 160 const GrGLSLProgramDataManager& pdman, |
160 int index, | 161 int index, |
161 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { | 162 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { |
162 this->setTransformDataHelper<DefaultGeoProc>(primProc, pdman, index,
transforms); | 163 this->setTransformDataHelper<DefaultGeoProc>(primProc, pdman, index,
transforms); |
163 } | 164 } |
164 | 165 |
165 private: | 166 private: |
166 SkMatrix fViewMatrix; | 167 SkMatrix fViewMatrix; |
167 GrColor fColor; | 168 GrColor fColor; |
168 uint8_t fCoverage; | 169 uint8_t fCoverage; |
169 UniformHandle fViewMatrixUniform; | 170 UniformHandle fViewMatrixUniform; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 310 } |
310 | 311 |
311 if (localCoords.hasLocalMatrix()) { | 312 if (localCoords.hasLocalMatrix()) { |
312 invert.preConcat(*localCoords.fMatrix); | 313 invert.preConcat(*localCoords.fMatrix); |
313 } | 314 } |
314 } | 315 } |
315 | 316 |
316 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); | 317 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); |
317 return Create(color, coverage, inverted, SkMatrix::I()); | 318 return Create(color, coverage, inverted, SkMatrix::I()); |
318 } | 319 } |
OLD | NEW |