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" |
11 #include "gl/GrGLGeometryProcessor.h" | 11 #include "gl/GrGLGeometryProcessor.h" |
12 #include "gl/GrGLUtil.h" | |
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 12 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
14 #include "glsl/GrGLSLProgramBuilder.h" | 13 #include "glsl/GrGLSLProgramBuilder.h" |
15 #include "glsl/GrGLSLVertexShaderBuilder.h" | 14 #include "glsl/GrGLSLVertexShaderBuilder.h" |
| 15 #include "glsl/GrGLSLUtil.h" |
16 | 16 |
17 /* | 17 /* |
18 * The default Geometry Processor simply takes position and multiplies it by the
uniform view | 18 * The default Geometry Processor simply takes position and multiplies it by the
uniform view |
19 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per
vertex color or | 19 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per
vertex color or |
20 * local coords. | 20 * local coords. |
21 */ | 21 */ |
22 | 22 |
23 enum GPFlag { | 23 enum GPFlag { |
24 kColor_GPFlag = 0x1, | 24 kColor_GPFlag = 0x1, |
25 kLocalCoord_GPFlag = 0x2, | 25 kLocalCoord_GPFlag = 0x2, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 b->add32(key); | 133 b->add32(key); |
134 } | 134 } |
135 | 135 |
136 void setData(const GrGLSLProgramDataManager& pdman, | 136 void setData(const GrGLSLProgramDataManager& pdman, |
137 const GrPrimitiveProcessor& gp) override { | 137 const GrPrimitiveProcessor& gp) override { |
138 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>(); | 138 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>(); |
139 | 139 |
140 if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.
viewMatrix())) { | 140 if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.
viewMatrix())) { |
141 fViewMatrix = dgp.viewMatrix(); | 141 fViewMatrix = dgp.viewMatrix(); |
142 float viewMatrix[3 * 3]; | 142 float viewMatrix[3 * 3]; |
143 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 143 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); |
144 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 144 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
145 } | 145 } |
146 | 146 |
147 if (dgp.color() != fColor && !dgp.hasVertexColor()) { | 147 if (dgp.color() != fColor && !dgp.hasVertexColor()) { |
148 float c[4]; | 148 float c[4]; |
149 GrColorToRGBAFloat(dgp.color(), c); | 149 GrColorToRGBAFloat(dgp.color(), c); |
150 pdman.set4fv(fColorUniform, 1, c); | 150 pdman.set4fv(fColorUniform, 1, c); |
151 fColor = dgp.color(); | 151 fColor = dgp.color(); |
152 } | 152 } |
153 | 153 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 if (localCoords.hasLocalMatrix()) { | 314 if (localCoords.hasLocalMatrix()) { |
315 invert.preConcat(*localCoords.fMatrix); | 315 invert.preConcat(*localCoords.fMatrix); |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); | 319 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); |
320 return Create(color, coverage, inverted, SkMatrix::I()); | 320 return Create(color, coverage, inverted, SkMatrix::I()); |
321 } | 321 } |
OLD | NEW |