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 #include "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 82 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
83 bool usesLocalCoords() const { return fUsesLocalCoords; } | 83 bool usesLocalCoords() const { return fUsesLocalCoords; } |
84 virtual ~CircleEdgeEffect() {} | 84 virtual ~CircleEdgeEffect() {} |
85 | 85 |
86 const char* name() const override { return "CircleEdge"; } | 86 const char* name() const override { return "CircleEdge"; } |
87 | 87 |
88 inline bool isStroked() const { return fStroke; } | 88 inline bool isStroked() const { return fStroke; } |
89 | 89 |
90 class GLProcessor : public GrGLGeometryProcessor { | 90 class GLProcessor : public GrGLGeometryProcessor { |
91 public: | 91 public: |
92 GLProcessor(const GrGeometryProcessor&, | 92 GLProcessor() |
93 const GrBatchTracker&) | |
94 : fColor(GrColor_ILLEGAL) {} | 93 : fColor(GrColor_ILLEGAL) {} |
95 | 94 |
96 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 95 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
97 const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); | 96 const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); |
98 GrGLGPBuilder* pb = args.fPB; | 97 GrGLGPBuilder* pb = args.fPB; |
99 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 98 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
100 | 99 |
101 // emit attributes | 100 // emit attributes |
102 vsBuilder->emitAttributes(ce); | 101 vsBuilder->emitAttributes(ce); |
103 | 102 |
(...skipping 19 matching lines...) Expand all Loading... |
123 if (ce.isStroked()) { | 122 if (ce.isStroked()) { |
124 fsBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - %s.
w), 0.0, 1.0);", | 123 fsBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - %s.
w), 0.0, 1.0);", |
125 v.fsIn(), v.fsIn()); | 124 v.fsIn(), v.fsIn()); |
126 fsBuilder->codeAppend("edgeAlpha *= innerAlpha;"); | 125 fsBuilder->codeAppend("edgeAlpha *= innerAlpha;"); |
127 } | 126 } |
128 | 127 |
129 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 128 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
130 } | 129 } |
131 | 130 |
132 static void GenKey(const GrGeometryProcessor& gp, | 131 static void GenKey(const GrGeometryProcessor& gp, |
133 const GrBatchTracker& bt, | |
134 const GrGLSLCaps&, | 132 const GrGLSLCaps&, |
135 GrProcessorKeyBuilder* b) { | 133 GrProcessorKeyBuilder* b) { |
136 const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>(); | 134 const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>(); |
137 uint16_t key = ce.isStroked() ? 0x1 : 0x0; | 135 uint16_t key = ce.isStroked() ? 0x1 : 0x0; |
138 key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0
x2 : 0x0; | 136 key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0
x2 : 0x0; |
139 key |= ce.colorIgnored() ? 0x4 : 0x0; | 137 key |= ce.colorIgnored() ? 0x4 : 0x0; |
140 b->add32(key); | 138 b->add32(key); |
141 } | 139 } |
142 | 140 |
143 virtual void setData(const GrGLProgramDataManager& pdman, | 141 void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProce
ssor& gp) override { |
144 const GrPrimitiveProcessor& gp, | |
145 const GrBatchTracker& bt) override { | |
146 const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>(); | 142 const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>(); |
147 if (ce.color() != fColor) { | 143 if (ce.color() != fColor) { |
148 GrGLfloat c[4]; | 144 GrGLfloat c[4]; |
149 GrColorToRGBAFloat(ce.color(), c); | 145 GrColorToRGBAFloat(ce.color(), c); |
150 pdman.set4fv(fColorUniform, 1, c); | 146 pdman.set4fv(fColorUniform, 1, c); |
151 fColor = ce.color(); | 147 fColor = ce.color(); |
152 } | 148 } |
153 } | 149 } |
154 | 150 |
155 void setTransformData(const GrPrimitiveProcessor& primProc, | 151 void setTransformData(const GrPrimitiveProcessor& primProc, |
156 const GrGLProgramDataManager& pdman, | 152 const GrGLProgramDataManager& pdman, |
157 int index, | 153 int index, |
158 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { | 154 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { |
159 this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, inde
x, transforms); | 155 this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, inde
x, transforms); |
160 } | 156 } |
161 | 157 |
162 private: | 158 private: |
163 GrColor fColor; | 159 GrColor fColor; |
164 UniformHandle fColorUniform; | 160 UniformHandle fColorUniform; |
165 typedef GrGLGeometryProcessor INHERITED; | 161 typedef GrGLGeometryProcessor INHERITED; |
166 }; | 162 }; |
167 | 163 |
168 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 164 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { |
169 const GrGLSLCaps& caps, | 165 GLProcessor::GenKey(*this, caps, b); |
170 GrProcessorKeyBuilder* b) const override { | |
171 GLProcessor::GenKey(*this, bt, caps, b); | |
172 } | 166 } |
173 | 167 |
174 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 168 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override { |
175 const GrGLSLCaps&) const ov
erride { | 169 return new GLProcessor(); |
176 return new GLProcessor(*this, bt); | |
177 } | 170 } |
178 | 171 |
179 private: | 172 private: |
180 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bo
ol usesLocalCoords) | 173 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bo
ol usesLocalCoords) |
181 : fColor(color) | 174 : fColor(color) |
182 , fLocalMatrix(localMatrix) | 175 , fLocalMatrix(localMatrix) |
183 , fUsesLocalCoords(usesLocalCoords) { | 176 , fUsesLocalCoords(usesLocalCoords) { |
184 this->initClassID<CircleEdgeEffect>(); | 177 this->initClassID<CircleEdgeEffect>(); |
185 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, | 178 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, |
186 kHigh_GrSLPrecision)); | 179 kHigh_GrSLPrecision)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } | 229 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } |
237 GrColor color() const { return fColor; } | 230 GrColor color() const { return fColor; } |
238 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 231 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
239 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 232 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
240 bool usesLocalCoords() const { return fUsesLocalCoords; } | 233 bool usesLocalCoords() const { return fUsesLocalCoords; } |
241 | 234 |
242 inline bool isStroked() const { return fStroke; } | 235 inline bool isStroked() const { return fStroke; } |
243 | 236 |
244 class GLProcessor : public GrGLGeometryProcessor { | 237 class GLProcessor : public GrGLGeometryProcessor { |
245 public: | 238 public: |
246 GLProcessor(const GrGeometryProcessor&, | 239 GLProcessor() |
247 const GrBatchTracker&) | |
248 : fColor(GrColor_ILLEGAL) {} | 240 : fColor(GrColor_ILLEGAL) {} |
249 | 241 |
250 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 242 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
251 const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); | 243 const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); |
252 GrGLGPBuilder* pb = args.fPB; | 244 GrGLGPBuilder* pb = args.fPB; |
253 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 245 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
254 | 246 |
255 // emit attributes | 247 // emit attributes |
256 vsBuilder->emitAttributes(ee); | 248 vsBuilder->emitAttributes(ee); |
257 | 249 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 fsBuilder->codeAppendf("grad = 2.0*scaledOffset*%s.zw;", | 290 fsBuilder->codeAppendf("grad = 2.0*scaledOffset*%s.zw;", |
299 ellipseRadii.fsIn()); | 291 ellipseRadii.fsIn()); |
300 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); | 292 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); |
301 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); | 293 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); |
302 } | 294 } |
303 | 295 |
304 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 296 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
305 } | 297 } |
306 | 298 |
307 static void GenKey(const GrGeometryProcessor& gp, | 299 static void GenKey(const GrGeometryProcessor& gp, |
308 const GrBatchTracker& bt, | |
309 const GrGLSLCaps&, | 300 const GrGLSLCaps&, |
310 GrProcessorKeyBuilder* b) { | 301 GrProcessorKeyBuilder* b) { |
311 const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>(); | 302 const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>(); |
312 uint16_t key = ee.isStroked() ? 0x1 : 0x0; | 303 uint16_t key = ee.isStroked() ? 0x1 : 0x0; |
313 key |= ee.usesLocalCoords() && ee.localMatrix().hasPerspective() ? 0
x2 : 0x0; | 304 key |= ee.usesLocalCoords() && ee.localMatrix().hasPerspective() ? 0
x2 : 0x0; |
314 key |= ee.colorIgnored() ? 0x4 : 0x0; | 305 key |= ee.colorIgnored() ? 0x4 : 0x0; |
315 b->add32(key); | 306 b->add32(key); |
316 } | 307 } |
317 | 308 |
318 virtual void setData(const GrGLProgramDataManager& pdman, | 309 void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProce
ssor& gp) override { |
319 const GrPrimitiveProcessor& gp, | |
320 const GrBatchTracker& bt) override { | |
321 const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>(); | 310 const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>(); |
322 if (ee.color() != fColor) { | 311 if (ee.color() != fColor) { |
323 GrGLfloat c[4]; | 312 GrGLfloat c[4]; |
324 GrColorToRGBAFloat(ee.color(), c); | 313 GrColorToRGBAFloat(ee.color(), c); |
325 pdman.set4fv(fColorUniform, 1, c); | 314 pdman.set4fv(fColorUniform, 1, c); |
326 fColor = ee.color(); | 315 fColor = ee.color(); |
327 } | 316 } |
328 } | 317 } |
329 | 318 |
330 void setTransformData(const GrPrimitiveProcessor& primProc, | 319 void setTransformData(const GrPrimitiveProcessor& primProc, |
331 const GrGLProgramDataManager& pdman, | 320 const GrGLProgramDataManager& pdman, |
332 int index, | 321 int index, |
333 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { | 322 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { |
334 this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, ind
ex, transforms); | 323 this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, ind
ex, transforms); |
335 } | 324 } |
336 | 325 |
337 private: | 326 private: |
338 GrColor fColor; | 327 GrColor fColor; |
339 UniformHandle fColorUniform; | 328 UniformHandle fColorUniform; |
340 | 329 |
341 typedef GrGLGeometryProcessor INHERITED; | 330 typedef GrGLGeometryProcessor INHERITED; |
342 }; | 331 }; |
343 | 332 |
344 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 333 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { |
345 const GrGLSLCaps& caps, | 334 GLProcessor::GenKey(*this, caps, b); |
346 GrProcessorKeyBuilder* b) const override { | |
347 GLProcessor::GenKey(*this, bt, caps, b); | |
348 } | 335 } |
349 | 336 |
350 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 337 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override { |
351 const GrGLSLCaps&) const ov
erride { | 338 return new GLProcessor(); |
352 return new GLProcessor(*this, bt); | |
353 } | 339 } |
354 | 340 |
355 private: | 341 private: |
356 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, | 342 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, |
357 bool usesLocalCoords) | 343 bool usesLocalCoords) |
358 : fColor(color) | 344 : fColor(color) |
359 , fLocalMatrix(localMatrix) | 345 , fLocalMatrix(localMatrix) |
360 , fUsesLocalCoords(usesLocalCoords) { | 346 , fUsesLocalCoords(usesLocalCoords) { |
361 this->initClassID<EllipseEdgeEffect>(); | 347 this->initClassID<EllipseEdgeEffect>(); |
362 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 348 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
363 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", | 349 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", |
364 kVec2f_GrVertexAtt
ribType)); | 350 kVec2f_GrVertexAttri
bType)); |
365 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", | 351 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", |
366 kVec4f_GrVertexAttr
ibType)); | 352 kVec4f_GrVertexAttrib
Type)); |
367 fStroke = stroke; | 353 fStroke = stroke; |
368 } | 354 } |
369 | 355 |
370 const Attribute* fInPosition; | 356 const Attribute* fInPosition; |
371 const Attribute* fInEllipseOffset; | 357 const Attribute* fInEllipseOffset; |
372 const Attribute* fInEllipseRadii; | 358 const Attribute* fInEllipseRadii; |
373 GrColor fColor; | 359 GrColor fColor; |
374 SkMatrix fLocalMatrix; | 360 SkMatrix fLocalMatrix; |
375 bool fStroke; | 361 bool fStroke; |
376 bool fUsesLocalCoords; | 362 bool fUsesLocalCoords; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } | 404 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } |
419 GrColor color() const { return fColor; } | 405 GrColor color() const { return fColor; } |
420 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 406 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
421 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 407 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
422 bool usesLocalCoords() const { return fUsesLocalCoords; } | 408 bool usesLocalCoords() const { return fUsesLocalCoords; } |
423 | 409 |
424 inline Mode getMode() const { return fMode; } | 410 inline Mode getMode() const { return fMode; } |
425 | 411 |
426 class GLProcessor : public GrGLGeometryProcessor { | 412 class GLProcessor : public GrGLGeometryProcessor { |
427 public: | 413 public: |
428 GLProcessor(const GrGeometryProcessor&, | 414 GLProcessor() |
429 const GrBatchTracker&) | |
430 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) {} | 415 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) {} |
431 | 416 |
432 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 417 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
433 const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>()
; | 418 const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>()
; |
434 GrGLGPBuilder* pb = args.fPB; | 419 GrGLGPBuilder* pb = args.fPB; |
435 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 420 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
436 | 421 |
437 // emit attributes | 422 // emit attributes |
438 vsBuilder->emitAttributes(ee); | 423 vsBuilder->emitAttributes(ee); |
439 | 424 |
440 GrGLVertToFrag offsets0(kVec2f_GrSLType); | 425 GrGLVertToFrag offsets0(kVec2f_GrSLType); |
441 args.fPB->addVarying("EllipseOffsets0", &offsets0); | 426 args.fPB->addVarying("EllipseOffsets0", &offsets0); |
442 vsBuilder->codeAppendf("%s = %s;", offsets0.vsOut(), | 427 vsBuilder->codeAppendf("%s = %s;", offsets0.vsOut(), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 offsets1.fsIn(), offsets1.fsIn(), offsets
1.fsIn(), | 480 offsets1.fsIn(), offsets1.fsIn(), offsets
1.fsIn(), |
496 offsets1.fsIn()); | 481 offsets1.fsIn()); |
497 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); | 482 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); |
498 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); | 483 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); |
499 } | 484 } |
500 | 485 |
501 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 486 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
502 } | 487 } |
503 | 488 |
504 static void GenKey(const GrGeometryProcessor& gp, | 489 static void GenKey(const GrGeometryProcessor& gp, |
505 const GrBatchTracker& bt, | |
506 const GrGLSLCaps&, | 490 const GrGLSLCaps&, |
507 GrProcessorKeyBuilder* b) { | 491 GrProcessorKeyBuilder* b) { |
508 const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffe
ct>(); | 492 const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffe
ct>(); |
509 uint16_t key = ellipseEffect.getMode(); | 493 uint16_t key = ellipseEffect.getMode(); |
510 key |= ellipseEffect.colorIgnored() << 9; | 494 key |= ellipseEffect.colorIgnored() << 9; |
511 key |= ComputePosKey(ellipseEffect.viewMatrix()) << 10; | 495 key |= ComputePosKey(ellipseEffect.viewMatrix()) << 10; |
512 b->add32(key); | 496 b->add32(key); |
513 } | 497 } |
514 | 498 |
515 virtual void setData(const GrGLProgramDataManager& pdman, | 499 void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProce
ssor& gp) override { |
516 const GrPrimitiveProcessor& gp, | |
517 const GrBatchTracker& bt) override { | |
518 const DIEllipseEdgeEffect& dee = gp.cast<DIEllipseEdgeEffect>(); | 500 const DIEllipseEdgeEffect& dee = gp.cast<DIEllipseEdgeEffect>(); |
519 | 501 |
520 if (!dee.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dee.
viewMatrix())) { | 502 if (!dee.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dee.
viewMatrix())) { |
521 fViewMatrix = dee.viewMatrix(); | 503 fViewMatrix = dee.viewMatrix(); |
522 GrGLfloat viewMatrix[3 * 3]; | 504 GrGLfloat viewMatrix[3 * 3]; |
523 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 505 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
524 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 506 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
525 } | 507 } |
526 | 508 |
527 if (dee.color() != fColor) { | 509 if (dee.color() != fColor) { |
528 GrGLfloat c[4]; | 510 GrGLfloat c[4]; |
529 GrColorToRGBAFloat(dee.color(), c); | 511 GrColorToRGBAFloat(dee.color(), c); |
530 pdman.set4fv(fColorUniform, 1, c); | 512 pdman.set4fv(fColorUniform, 1, c); |
531 fColor = dee.color(); | 513 fColor = dee.color(); |
532 } | 514 } |
533 } | 515 } |
534 | 516 |
535 private: | 517 private: |
536 SkMatrix fViewMatrix; | 518 SkMatrix fViewMatrix; |
537 GrColor fColor; | 519 GrColor fColor; |
538 UniformHandle fColorUniform; | 520 UniformHandle fColorUniform; |
539 UniformHandle fViewMatrixUniform; | 521 UniformHandle fViewMatrixUniform; |
540 | 522 |
541 typedef GrGLGeometryProcessor INHERITED; | 523 typedef GrGLGeometryProcessor INHERITED; |
542 }; | 524 }; |
543 | 525 |
544 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 526 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { |
545 const GrGLSLCaps& caps, | 527 GLProcessor::GenKey(*this, caps, b); |
546 GrProcessorKeyBuilder* b) const override { | |
547 GLProcessor::GenKey(*this, bt, caps, b); | |
548 } | 528 } |
549 | 529 |
550 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 530 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override { |
551 const GrGLSLCaps&) const ov
erride { | 531 return new GLProcessor(); |
552 return new GLProcessor(*this, bt); | |
553 } | 532 } |
554 | 533 |
555 private: | 534 private: |
556 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode, | 535 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode, |
557 bool usesLocalCoords) | 536 bool usesLocalCoords) |
558 : fColor(color) | 537 : fColor(color) |
559 , fViewMatrix(viewMatrix) | 538 , fViewMatrix(viewMatrix) |
560 , fUsesLocalCoords(usesLocalCoords) { | 539 , fUsesLocalCoords(usesLocalCoords) { |
561 this->initClassID<DIEllipseEdgeEffect>(); | 540 this->initClassID<DIEllipseEdgeEffect>(); |
562 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, | 541 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 } | 2012 } |
2034 | 2013 |
2035 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 2014 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
2036 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2015 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
2037 GrColor color = GrRandomColor(random); | 2016 GrColor color = GrRandomColor(random); |
2038 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2017 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
2039 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2018 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
2040 } | 2019 } |
2041 | 2020 |
2042 #endif | 2021 #endif |
OLD | NEW |