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 "GrConvexPolyEffect.h" | 8 #include "GrConvexPolyEffect.h" |
9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "SkPathPriv.h" | 10 #include "SkPathPriv.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 SkRect fPrevRect; | 97 SkRect fPrevRect; |
98 | 98 |
99 typedef GrGLSLFragmentProcessor INHERITED; | 99 typedef GrGLSLFragmentProcessor INHERITED; |
100 }; | 100 }; |
101 | 101 |
102 void GLAARectEffect::emitCode(EmitArgs& args) { | 102 void GLAARectEffect::emitCode(EmitArgs& args) { |
103 const AARectEffect& aare = args.fFp.cast<AARectEffect>(); | 103 const AARectEffect& aare = args.fFp.cast<AARectEffect>(); |
104 const char *rectName; | 104 const char *rectName; |
105 // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bot
tom - 0.5), | 105 // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bot
tom - 0.5), |
106 // respectively. | 106 // respectively. |
107 fRectUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragm
ent_Visibility, | 107 fRectUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, |
108 kVec4f_GrSLType, | 108 kVec4f_GrSLType, |
109 kDefault_GrSLPrecision, | 109 kDefault_GrSLPrecision, |
110 "rect", | 110 "rect", |
111 &rectName); | 111 &rectName); |
112 | 112 |
113 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 113 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
114 const char* fragmentPos = fragBuilder->fragmentPosition(); | 114 const char* fragmentPos = fragBuilder->fragmentPosition(); |
115 if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) { | 115 if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) { |
116 // The amount of coverage removed in x and y by the edges is computed as
a pair of negative | 116 // The amount of coverage removed in x and y by the edges is computed as
a pair of negative |
117 // numbers, xSub and ySub. | 117 // numbers, xSub and ySub. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 private: | 181 private: |
182 GrGLSLProgramDataManager::UniformHandle fEdgeUniform; | 182 GrGLSLProgramDataManager::UniformHandle fEdgeUniform; |
183 SkScalar fPrevEdges[3 * GrConvexPolyEffect::k
MaxEdges]; | 183 SkScalar fPrevEdges[3 * GrConvexPolyEffect::k
MaxEdges]; |
184 typedef GrGLSLFragmentProcessor INHERITED; | 184 typedef GrGLSLFragmentProcessor INHERITED; |
185 }; | 185 }; |
186 | 186 |
187 void GrGLConvexPolyEffect::emitCode(EmitArgs& args) { | 187 void GrGLConvexPolyEffect::emitCode(EmitArgs& args) { |
188 const GrConvexPolyEffect& cpe = args.fFp.cast<GrConvexPolyEffect>(); | 188 const GrConvexPolyEffect& cpe = args.fFp.cast<GrConvexPolyEffect>(); |
189 | 189 |
190 const char *edgeArrayName; | 190 const char *edgeArrayName; |
191 fEdgeUniform = args.fUniformHandler->addUniformArray(GrGLSLUniformHandler::k
Fragment_Visibility, | 191 fEdgeUniform = args.fUniformHandler->addUniformArray(kFragment_GrShaderFlag, |
192 kVec3f_GrSLType, | 192 kVec3f_GrSLType, |
193 kDefault_GrSLPrecision, | 193 kDefault_GrSLPrecision, |
194 "edges", | 194 "edges", |
195 cpe.getEdgeCount(), | 195 cpe.getEdgeCount(), |
196 &edgeArrayName); | 196 &edgeArrayName); |
197 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 197 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
198 fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); | 198 fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); |
199 fragBuilder->codeAppend("\t\tfloat edge;\n"); | 199 fragBuilder->codeAppend("\t\tfloat edge;\n"); |
200 const char* fragmentPos = fragBuilder->fragmentPosition(); | 200 const char* fragmentPos = fragBuilder->fragmentPosition(); |
201 for (int i = 0; i < cpe.getEdgeCount(); ++i) { | 201 for (int i = 0; i < cpe.getEdgeCount(); ++i) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 | 344 |
345 GrFragmentProcessor* fp; | 345 GrFragmentProcessor* fp; |
346 do { | 346 do { |
347 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 347 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
348 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 348 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
349 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 349 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
350 } while (nullptr == fp); | 350 } while (nullptr == fp); |
351 return fp; | 351 return fp; |
352 } | 352 } |
OLD | NEW |