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

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

Issue 1502253003: Allow LCD text to batch across colorchanges. This will always use (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years 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/GrDistanceFieldGeoProc.h ('k') | no next file » | 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 "GrDistanceFieldGeoProc.h" 8 #include "GrDistanceFieldGeoProc.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathG eoProc>(); 410 const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathG eoProc>();
411 411
412 if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp. viewMatrix())) { 412 if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp. viewMatrix())) {
413 fViewMatrix = dfpgp.viewMatrix(); 413 fViewMatrix = dfpgp.viewMatrix();
414 float viewMatrix[3 * 3]; 414 float viewMatrix[3 * 3];
415 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); 415 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
416 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); 416 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
417 } 417 }
418 418
419 if (dfpgp.color() != fColor) { 419 if (dfpgp.color() != fColor && !dfpgp.hasVertexColor()) {
420 float c[4]; 420 float c[4];
421 GrColorToRGBAFloat(dfpgp.color(), c); 421 GrColorToRGBAFloat(dfpgp.color(), c);
422 pdman.set4fv(fColorUniform, 1, c); 422 pdman.set4fv(fColorUniform, 1, c);
423 fColor = dfpgp.color(); 423 fColor = dfpgp.color();
424 } 424 }
425 } 425 }
426 426
427 static inline void GenKey(const GrGeometryProcessor& gp, 427 static inline void GenKey(const GrGeometryProcessor& gp,
428 const GrGLSLCaps&, 428 const GrGLSLCaps&,
429 GrProcessorKeyBuilder* b) { 429 GrProcessorKeyBuilder* b) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; 528 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
529 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 529 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
530 530
531 // emit attributes 531 // emit attributes
532 varyingHandler->emitAttributes(dfTexEffect); 532 varyingHandler->emitAttributes(dfTexEffect);
533 533
534 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 534 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
535 535
536 // setup pass through color 536 // setup pass through color
537 if (!dfTexEffect.colorIgnored()) { 537 if (!dfTexEffect.colorIgnored()) {
538 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputCol or, &fColorUniform); 538 if (dfTexEffect.hasVertexColor()) {
539 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), a rgs.fOutputColor);
540 } else {
541 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu tColor,
542 &fColorUniform);
543 }
539 } 544 }
540 545
541 // Setup position 546 // Setup position
542 this->setupPosition(vertBuilder, 547 this->setupPosition(vertBuilder,
543 uniformHandler, 548 uniformHandler,
544 gpArgs, 549 gpArgs,
545 dfTexEffect.inPosition()->fName, 550 dfTexEffect.inPosition()->fName,
546 dfTexEffect.viewMatrix(), 551 dfTexEffect.viewMatrix(),
547 &fViewMatrixUniform); 552 &fViewMatrixUniform);
548 553
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 fDistanceAdjust = wa; 694 fDistanceAdjust = wa;
690 } 695 }
691 696
692 if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd. viewMatrix())) { 697 if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd. viewMatrix())) {
693 fViewMatrix = dflcd.viewMatrix(); 698 fViewMatrix = dflcd.viewMatrix();
694 float viewMatrix[3 * 3]; 699 float viewMatrix[3 * 3];
695 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); 700 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
696 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); 701 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
697 } 702 }
698 703
699 if (dflcd.color() != fColor) { 704 if (dflcd.color() != fColor && !dflcd.hasVertexColor()) {
700 float c[4]; 705 float c[4];
701 GrColorToRGBAFloat(dflcd.color(), c); 706 GrColorToRGBAFloat(dflcd.color(), c);
702 pdman.set4fv(fColorUniform, 1, c); 707 pdman.set4fv(fColorUniform, 1, c);
703 fColor = dflcd.color(); 708 fColor = dflcd.color();
704 } 709 }
705 } 710 }
706 711
707 static inline void GenKey(const GrGeometryProcessor& gp, 712 static inline void GenKey(const GrGeometryProcessor& gp,
708 const GrGLSLCaps&, 713 const GrGLSLCaps&,
709 GrProcessorKeyBuilder* b) { 714 GrProcessorKeyBuilder* b) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 : fColor(color) 748 : fColor(color)
744 , fViewMatrix(viewMatrix) 749 , fViewMatrix(viewMatrix)
745 , fTextureAccess(texture, params) 750 , fTextureAccess(texture, params)
746 , fDistanceAdjust(distanceAdjust) 751 , fDistanceAdjust(distanceAdjust)
747 , fFlags(flags & kLCD_DistanceFieldEffectMask) 752 , fFlags(flags & kLCD_DistanceFieldEffectMask)
748 , fUsesLocalCoords(usesLocalCoords) { 753 , fUsesLocalCoords(usesLocalCoords) {
749 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan ceFieldEffectFlag)); 754 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan ceFieldEffectFlag));
750 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); 755 this->initClassID<GrDistanceFieldLCDTextGeoProc>();
751 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType, 756 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType,
752 kHigh_GrSLPrecision)); 757 kHigh_GrSLPrecision));
758 if (flags & kColorAttr_DistanceFieldEffectFlag) {
759 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
760 }
753 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", 761 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
754 kVec2s_GrVertexAttribTyp e)); 762 kVec2s_GrVertexAttribTyp e));
755 this->addTextureAccess(&fTextureAccess); 763 this->addTextureAccess(&fTextureAccess);
756 } 764 }
757 765
758 void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, 766 void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
759 GrProcessorKeyBuilder* b ) const { 767 GrProcessorKeyBuilder* b ) const {
760 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b); 768 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b);
761 } 769 }
762 770
(...skipping 23 matching lines...) Expand all
786 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; 794 uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
787 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; 795 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0;
788 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; 796 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
789 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), 797 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom),
790 GrTest::TestMatrix(d->fRandom), 798 GrTest::TestMatrix(d->fRandom),
791 d->fTextures[texIdx], params, 799 d->fTextures[texIdx], params,
792 wa, 800 wa,
793 flags, 801 flags,
794 d->fRandom->nextBool()); 802 d->fRandom->nextBool());
795 } 803 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldGeoProc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698