Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: src/gpu/effects/GrBezierEffect.cpp

Issue 1127953003: Remove viewmatrix from GrGeometryProcessor base class (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup3
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "GrBezierEffect.h" 8 #include "GrBezierEffect.h"
9 9
10 #include "gl/GrGLProcessor.h" 10 #include "gl/GrGLProcessor.h"
(...skipping 16 matching lines...) Expand all
27 void onEmitCode(EmitArgs&, GrGPArgs*) override; 27 void onEmitCode(EmitArgs&, GrGPArgs*) override;
28 28
29 static inline void GenKey(const GrGeometryProcessor&, 29 static inline void GenKey(const GrGeometryProcessor&,
30 const GrBatchTracker&, 30 const GrBatchTracker&,
31 const GrGLSLCaps&, 31 const GrGLSLCaps&,
32 GrProcessorKeyBuilder*); 32 GrProcessorKeyBuilder*);
33 33
34 virtual void setData(const GrGLProgramDataManager& pdman, 34 virtual void setData(const GrGLProgramDataManager& pdman,
35 const GrPrimitiveProcessor& primProc, 35 const GrPrimitiveProcessor& primProc,
36 const GrBatchTracker& bt) override { 36 const GrBatchTracker& bt) override {
37 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); 37 const GrConicEffect& ce = primProc.cast<GrConicEffect>();
38 this->setUniformViewMatrix(pdman, ce.viewMatrix());
38 39
39 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>(); 40 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
40 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 41 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
41 GrGLfloat c[4]; 42 GrGLfloat c[4];
42 GrColorToRGBAFloat(local.fColor, c); 43 GrColorToRGBAFloat(local.fColor, c);
43 pdman.set4fv(fColorUniform, 1, c); 44 pdman.set4fv(fColorUniform, 1, c);
44 fColor = local.fColor; 45 fColor = local.fColor;
45 } 46 }
46 if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageSca le) { 47 if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageSca le) {
47 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov erageScale)); 48 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov erageScale));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp, 164 void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp,
164 const GrBatchTracker& bt, 165 const GrBatchTracker& bt,
165 const GrGLSLCaps&, 166 const GrGLSLCaps&,
166 GrProcessorKeyBuilder* b) { 167 GrProcessorKeyBuilder* b) {
167 const GrConicEffect& ce = gp.cast<GrConicEffect>(); 168 const GrConicEffect& ce = gp.cast<GrConicEffect>();
168 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>(); 169 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
169 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 170 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
170 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0; 171 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
171 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0; 172 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
172 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0; 173 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0;
173 key |= ComputePosKey(gp.viewMatrix()) << 5; 174 key |= ComputePosKey(ce.viewMatrix()) << 5;
174 b->add32(key); 175 b->add32(key);
175 } 176 }
176 177
177 ////////////////////////////////////////////////////////////////////////////// 178 //////////////////////////////////////////////////////////////////////////////
178 179
179 GrConicEffect::~GrConicEffect() {} 180 GrConicEffect::~GrConicEffect() {}
180 181
181 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, 182 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt,
182 const GrGLSLCaps& caps, 183 const GrGLSLCaps& caps,
183 GrProcessorKeyBuilder* b) const { 184 GrProcessorKeyBuilder* b) const {
184 GrGLConicEffect::GenKey(*this, bt, caps, b); 185 GrGLConicEffect::GenKey(*this, bt, caps, b);
185 } 186 }
186 187
187 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt , 188 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt ,
188 const GrGLSLCaps&) const { 189 const GrGLSLCaps&) const {
189 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); 190 return SkNEW_ARGS(GrGLConicEffect, (*this, bt));
190 } 191 }
191 192
192 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage, 193 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
193 GrPrimitiveEdgeType edgeType, const SkMatrix& local Matrix) 194 GrPrimitiveEdgeType edgeType, const SkMatrix& local Matrix)
194 : INHERITED(viewMatrix, localMatrix) 195 : INHERITED(localMatrix)
195 , fColor(color) 196 , fColor(color)
197 , fViewMatrix(viewMatrix)
196 , fCoverageScale(coverage) 198 , fCoverageScale(coverage)
197 , fEdgeType(edgeType) { 199 , fEdgeType(edgeType) {
198 this->initClassID<GrConicEffect>(); 200 this->initClassID<GrConicEffect>();
199 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 201 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
200 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs", 202 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs",
201 kVec4f_GrVertexAttribTyp e)); 203 kVec4f_GrVertexAttribTyp e));
202 } 204 }
203 205
204 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const { 206 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const {
205 ConicBatchTracker* local = bt->cast<ConicBatchTracker>(); 207 ConicBatchTracker* local = bt->cast<ConicBatchTracker>();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 void onEmitCode(EmitArgs&, GrGPArgs*) override; 248 void onEmitCode(EmitArgs&, GrGPArgs*) override;
247 249
248 static inline void GenKey(const GrGeometryProcessor&, 250 static inline void GenKey(const GrGeometryProcessor&,
249 const GrBatchTracker&, 251 const GrBatchTracker&,
250 const GrGLSLCaps&, 252 const GrGLSLCaps&,
251 GrProcessorKeyBuilder*); 253 GrProcessorKeyBuilder*);
252 254
253 virtual void setData(const GrGLProgramDataManager& pdman, 255 virtual void setData(const GrGLProgramDataManager& pdman,
254 const GrPrimitiveProcessor& primProc, 256 const GrPrimitiveProcessor& primProc,
255 const GrBatchTracker& bt) override { 257 const GrBatchTracker& bt) override {
256 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); 258 const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
259 this->setUniformViewMatrix(pdman, qe.viewMatrix());
257 260
258 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>(); 261 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
259 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 262 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
260 GrGLfloat c[4]; 263 GrGLfloat c[4];
261 GrColorToRGBAFloat(local.fColor, c); 264 GrColorToRGBAFloat(local.fColor, c);
262 pdman.set4fv(fColorUniform, 1, c); 265 pdman.set4fv(fColorUniform, 1, c);
263 fColor = local.fColor; 266 fColor = local.fColor;
264 } 267 }
265 if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageSca le) { 268 if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageSca le) {
266 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov erageScale)); 269 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov erageScale));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp, 371 void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp,
369 const GrBatchTracker& bt, 372 const GrBatchTracker& bt,
370 const GrGLSLCaps&, 373 const GrGLSLCaps&,
371 GrProcessorKeyBuilder* b) { 374 GrProcessorKeyBuilder* b) {
372 const GrQuadEffect& ce = gp.cast<GrQuadEffect>(); 375 const GrQuadEffect& ce = gp.cast<GrQuadEffect>();
373 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>(); 376 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
374 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 377 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
375 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0; 378 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
376 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0; 379 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
377 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0; 380 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0;
378 key |= ComputePosKey(gp.viewMatrix()) << 5; 381 key |= ComputePosKey(ce.viewMatrix()) << 5;
379 b->add32(key); 382 b->add32(key);
380 } 383 }
381 384
382 ////////////////////////////////////////////////////////////////////////////// 385 //////////////////////////////////////////////////////////////////////////////
383 386
384 GrQuadEffect::~GrQuadEffect() {} 387 GrQuadEffect::~GrQuadEffect() {}
385 388
386 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, 389 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt,
387 const GrGLSLCaps& caps, 390 const GrGLSLCaps& caps,
388 GrProcessorKeyBuilder* b) const { 391 GrProcessorKeyBuilder* b) const {
389 GrGLQuadEffect::GenKey(*this, bt, caps, b); 392 GrGLQuadEffect::GenKey(*this, bt, caps, b);
390 } 393 }
391 394
392 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt, 395 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt,
393 const GrGLSLCaps&) const { 396 const GrGLSLCaps&) const {
394 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); 397 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt));
395 } 398 }
396 399
397 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co verage, 400 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co verage,
398 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa trix) 401 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa trix)
399 : INHERITED(viewMatrix, localMatrix) 402 : INHERITED(localMatrix)
400 , fColor(color) 403 , fColor(color)
404 , fViewMatrix(viewMatrix)
401 , fCoverageScale(coverage) 405 , fCoverageScale(coverage)
402 , fEdgeType(edgeType) { 406 , fEdgeType(edgeType) {
403 this->initClassID<GrQuadEffect>(); 407 this->initClassID<GrQuadEffect>();
404 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 408 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
405 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge", 409 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge",
406 kVec4f_GrVertexAttribTyp e)); 410 kVec4f_GrVertexAttribTyp e));
407 } 411 }
408 412
409 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in it) const { 413 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in it) const {
410 QuadBatchTracker* local = bt->cast<QuadBatchTracker>(); 414 QuadBatchTracker* local = bt->cast<QuadBatchTracker>();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 void onEmitCode(EmitArgs&, GrGPArgs*) override; 455 void onEmitCode(EmitArgs&, GrGPArgs*) override;
452 456
453 static inline void GenKey(const GrGeometryProcessor&, 457 static inline void GenKey(const GrGeometryProcessor&,
454 const GrBatchTracker&, 458 const GrBatchTracker&,
455 const GrGLSLCaps&, 459 const GrGLSLCaps&,
456 GrProcessorKeyBuilder*); 460 GrProcessorKeyBuilder*);
457 461
458 virtual void setData(const GrGLProgramDataManager& pdman, 462 virtual void setData(const GrGLProgramDataManager& pdman,
459 const GrPrimitiveProcessor& primProc, 463 const GrPrimitiveProcessor& primProc,
460 const GrBatchTracker& bt) override { 464 const GrBatchTracker& bt) override {
461 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); 465 const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
466 this->setUniformViewMatrix(pdman, ce.viewMatrix());
462 467
463 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>(); 468 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
464 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 469 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
465 GrGLfloat c[4]; 470 GrGLfloat c[4];
466 GrColorToRGBAFloat(local.fColor, c); 471 GrColorToRGBAFloat(local.fColor, c);
467 pdman.set4fv(fColorUniform, 1, c); 472 pdman.set4fv(fColorUniform, 1, c);
468 fColor = local.fColor; 473 fColor = local.fColor;
469 } 474 }
470 } 475 }
471 476
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 601
597 void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp, 602 void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
598 const GrBatchTracker& bt, 603 const GrBatchTracker& bt,
599 const GrGLSLCaps&, 604 const GrGLSLCaps&,
600 GrProcessorKeyBuilder* b) { 605 GrProcessorKeyBuilder* b) {
601 const GrCubicEffect& ce = gp.cast<GrCubicEffect>(); 606 const GrCubicEffect& ce = gp.cast<GrCubicEffect>();
602 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>(); 607 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
603 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 608 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
604 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8; 609 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8;
605 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0; 610 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0;
606 key |= ComputePosKey(gp.viewMatrix()) << 5; 611 key |= ComputePosKey(ce.viewMatrix()) << 5;
607 b->add32(key); 612 b->add32(key);
608 } 613 }
609 614
610 ////////////////////////////////////////////////////////////////////////////// 615 //////////////////////////////////////////////////////////////////////////////
611 616
612 GrCubicEffect::~GrCubicEffect() {} 617 GrCubicEffect::~GrCubicEffect() {}
613 618
614 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, 619 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt,
615 const GrGLSLCaps& caps, 620 const GrGLSLCaps& caps,
616 GrProcessorKeyBuilder* b) const { 621 GrProcessorKeyBuilder* b) const {
617 GrGLCubicEffect::GenKey(*this, bt, caps, b); 622 GrGLCubicEffect::GenKey(*this, bt, caps, b);
618 } 623 }
619 624
620 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt , 625 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt ,
621 const GrGLSLCaps&) const { 626 const GrGLSLCaps&) const {
622 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); 627 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt));
623 } 628 }
624 629
625 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, 630 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix,
626 GrPrimitiveEdgeType edgeType) 631 GrPrimitiveEdgeType edgeType)
627 : INHERITED(viewMatrix) 632 : fColor(color)
628 , fColor(color) 633 , fViewMatrix(viewMatrix)
629 , fEdgeType(edgeType) { 634 , fEdgeType(edgeType) {
630 this->initClassID<GrCubicEffect>(); 635 this->initClassID<GrCubicEffect>();
631 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 636 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
632 fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs", 637 fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs",
633 kVec4f_GrVertexAttribTyp e)); 638 kVec4f_GrVertexAttribTyp e));
634 } 639 }
635 640
636 void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const { 641 void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const {
637 CubicBatchTracker* local = bt->cast<CubicBatchTracker>(); 642 CubicBatchTracker* local = bt->cast<CubicBatchTracker>();
638 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 643 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
(...skipping 11 matching lines...) Expand all
650 GrGeometryProcessor* gp; 655 GrGeometryProcessor* gp;
651 do { 656 do {
652 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 657 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
653 random->nextULessThan(kGrPro cessorEdgeTypeCnt)); 658 random->nextULessThan(kGrPro cessorEdgeTypeCnt));
654 gp = GrCubicEffect::Create(GrRandomColor(random), 659 gp = GrCubicEffect::Create(GrRandomColor(random),
655 GrTest::TestMatrix(random), edgeType, caps); 660 GrTest::TestMatrix(random), edgeType, caps);
656 } while (NULL == gp); 661 } while (NULL == gp);
657 return gp; 662 return gp;
658 } 663 }
659 664
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698