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

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

Issue 1111603004: removing equality / compute invariant loops from GrGeometryProcessors (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup1
Patch Set: tweaks 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
« no previous file with comments | « src/gpu/effects/GrBezierEffect.h ('k') | src/gpu/effects/GrBitmapTextGeoProc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 GrPrimitiveEdgeType edgeType, const SkMatrix& local Matrix) 193 GrPrimitiveEdgeType edgeType, const SkMatrix& local Matrix)
194 : INHERITED(color, viewMatrix, localMatrix) 194 : INHERITED(color, viewMatrix, localMatrix)
195 , fCoverageScale(coverage) 195 , fCoverageScale(coverage)
196 , fEdgeType(edgeType) { 196 , fEdgeType(edgeType) {
197 this->initClassID<GrConicEffect>(); 197 this->initClassID<GrConicEffect>();
198 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 198 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
199 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs", 199 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs",
200 kVec4f_GrVertexAttribTyp e)); 200 kVec4f_GrVertexAttribTyp e));
201 } 201 }
202 202
203 bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const {
204 const GrConicEffect& ce = other.cast<GrConicEffect>();
205 return (ce.fEdgeType == fEdgeType);
206 }
207
208 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const { 203 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const {
209 ConicBatchTracker* local = bt->cast<ConicBatchTracker>(); 204 ConicBatchTracker* local = bt->cast<ConicBatchTracker>();
210 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 205 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
211 local->fCoverageScale = fCoverageScale; 206 local->fCoverageScale = fCoverageScale;
212 local->fUsesLocalCoords = init.fUsesLocalCoords; 207 local->fUsesLocalCoords = init.fUsesLocalCoords;
213 } 208 }
214 209
215 bool GrConicEffect::onCanMakeEqual(const GrBatchTracker& m,
216 const GrGeometryProcessor& that,
217 const GrBatchTracker& t) const {
218 const ConicBatchTracker& mine = m.cast<ConicBatchTracker>();
219 const ConicBatchTracker& theirs = t.cast<ConicBatchTracker>();
220 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
221 that, theirs.fUsesLocalCoords) &&
222 CanCombineOutput(mine.fInputColorType, mine.fColor,
223 theirs.fInputColorType, theirs.fColor) &&
224 mine.fCoverageScale == theirs.fCoverageScale;
225 }
226
227 ////////////////////////////////////////////////////////////////////////////// 210 //////////////////////////////////////////////////////////////////////////////
228 211
229 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); 212 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
230 213
231 GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, 214 GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
232 GrContext*, 215 GrContext*,
233 const GrDrawTargetCaps& caps, 216 const GrDrawTargetCaps& caps,
234 GrTexture*[]) { 217 GrTexture*[]) {
235 GrGeometryProcessor* gp; 218 GrGeometryProcessor* gp;
236 do { 219 do {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa trix) 397 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa trix)
415 : INHERITED(color, viewMatrix, localMatrix) 398 : INHERITED(color, viewMatrix, localMatrix)
416 , fCoverageScale(coverage) 399 , fCoverageScale(coverage)
417 , fEdgeType(edgeType) { 400 , fEdgeType(edgeType) {
418 this->initClassID<GrQuadEffect>(); 401 this->initClassID<GrQuadEffect>();
419 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 402 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
420 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge", 403 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge",
421 kVec4f_GrVertexAttribTyp e)); 404 kVec4f_GrVertexAttribTyp e));
422 } 405 }
423 406
424 bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const {
425 const GrQuadEffect& ce = other.cast<GrQuadEffect>();
426 return (ce.fEdgeType == fEdgeType);
427 }
428
429 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in it) const { 407 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in it) const {
430 QuadBatchTracker* local = bt->cast<QuadBatchTracker>(); 408 QuadBatchTracker* local = bt->cast<QuadBatchTracker>();
431 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 409 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
432 local->fCoverageScale = fCoverageScale; 410 local->fCoverageScale = fCoverageScale;
433 local->fUsesLocalCoords = init.fUsesLocalCoords; 411 local->fUsesLocalCoords = init.fUsesLocalCoords;
434 } 412 }
435 413
436 bool GrQuadEffect::onCanMakeEqual(const GrBatchTracker& m,
437 const GrGeometryProcessor& that,
438 const GrBatchTracker& t) const {
439 const QuadBatchTracker& mine = m.cast<QuadBatchTracker>();
440 const QuadBatchTracker& theirs = t.cast<QuadBatchTracker>();
441 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
442 that, theirs.fUsesLocalCoords) &&
443 CanCombineOutput(mine.fInputColorType, mine.fColor,
444 theirs.fInputColorType, theirs.fColor) &&
445 mine.fCoverageScale == theirs.fCoverageScale;
446 }
447
448 ////////////////////////////////////////////////////////////////////////////// 414 //////////////////////////////////////////////////////////////////////////////
449 415
450 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); 416 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
451 417
452 GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, 418 GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
453 GrContext*, 419 GrContext*,
454 const GrDrawTargetCaps& caps, 420 const GrDrawTargetCaps& caps,
455 GrTexture*[]) { 421 GrTexture*[]) {
456 GrGeometryProcessor* gp; 422 GrGeometryProcessor* gp;
457 do { 423 do {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 622
657 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, 623 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix,
658 GrPrimitiveEdgeType edgeType) 624 GrPrimitiveEdgeType edgeType)
659 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { 625 : INHERITED(color, viewMatrix), fEdgeType(edgeType) {
660 this->initClassID<GrCubicEffect>(); 626 this->initClassID<GrCubicEffect>();
661 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 627 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
662 fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs", 628 fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs",
663 kVec4f_GrVertexAttribTyp e)); 629 kVec4f_GrVertexAttribTyp e));
664 } 630 }
665 631
666 bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const {
667 const GrCubicEffect& ce = other.cast<GrCubicEffect>();
668 return (ce.fEdgeType == fEdgeType);
669 }
670
671 void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const { 632 void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i nit) const {
672 CubicBatchTracker* local = bt->cast<CubicBatchTracker>(); 633 CubicBatchTracker* local = bt->cast<CubicBatchTracker>();
673 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 634 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
674 local->fUsesLocalCoords = init.fUsesLocalCoords; 635 local->fUsesLocalCoords = init.fUsesLocalCoords;
675 } 636 }
676 637
677 bool GrCubicEffect::onCanMakeEqual(const GrBatchTracker& m,
678 const GrGeometryProcessor& that,
679 const GrBatchTracker& t) const {
680 const CubicBatchTracker& mine = m.cast<CubicBatchTracker>();
681 const CubicBatchTracker& theirs = t.cast<CubicBatchTracker>();
682 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
683 that, theirs.fUsesLocalCoords) &&
684 CanCombineOutput(mine.fInputColorType, mine.fColor,
685 theirs.fInputColorType, theirs.fColor);
686 }
687
688 ////////////////////////////////////////////////////////////////////////////// 638 //////////////////////////////////////////////////////////////////////////////
689 639
690 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); 640 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
691 641
692 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, 642 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random,
693 GrContext*, 643 GrContext*,
694 const GrDrawTargetCaps& caps, 644 const GrDrawTargetCaps& caps,
695 GrTexture*[]) { 645 GrTexture*[]) {
696 GrGeometryProcessor* gp; 646 GrGeometryProcessor* gp;
697 do { 647 do {
698 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 648 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
699 random->nextULessThan(kGrPro cessorEdgeTypeCnt)); 649 random->nextULessThan(kGrPro cessorEdgeTypeCnt));
700 gp = GrCubicEffect::Create(GrRandomColor(random), 650 gp = GrCubicEffect::Create(GrRandomColor(random),
701 GrTest::TestMatrix(random), edgeType, caps); 651 GrTest::TestMatrix(random), edgeType, caps);
702 } while (NULL == gp); 652 } while (NULL == gp);
703 return gp; 653 return gp;
704 } 654 }
705 655
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.h ('k') | src/gpu/effects/GrBitmapTextGeoProc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698