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

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

Issue 827973002: ViewMatrix uniform upload moved to GeometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@vm-on-gp
Patch Set: feedback inc Created 5 years, 11 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/GrDashingEffect.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.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 "GrDistanceFieldTextureEffect.h" 8 #include "GrDistanceFieldTextureEffect.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); 47 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
48 GrGLVertToFrag v(kVec2f_GrSLType); 48 GrGLVertToFrag v(kVec2f_GrSLType);
49 args.fPB->addVarying("TextureCoords", &v); 49 args.fPB->addVarying("TextureCoords", &v);
50 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord s()->fName); 50 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord s()->fName);
51 51
52 // Setup pass through color 52 // Setup pass through color
53 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , 53 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor ,
54 dfTexEffect.inColor(), &fColorUniform); 54 dfTexEffect.inColor(), &fColorUniform);
55 55
56 // setup uniform viewMatrix
57 this->addUniformViewMatrix(pb);
58
56 // setup position varying 59 // setup position varying
57 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition() , 60 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition() ,
58 vsBuilder->uViewM(), dfTexEffect.inPosition()->fN ame); 61 this->uViewM(), dfTexEffect.inPosition()->fName);
59 62
60 // setup output coords 63 // setup output coords
61 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), 64 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(),
62 dfTexEffect.inPosition()->fName); 65 dfTexEffect.inPosition()->fName);
63 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), 66 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(),
64 dfTexEffect.inPosition()->fName); 67 dfTexEffect.inPosition()->fName);
65 68
66 const char* textureSizeUniName = NULL; 69 const char* textureSizeUniName = NULL;
67 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis ibility, 70 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis ibility,
68 kVec2f_GrSLType, kDefault_GrSLPre cision, 71 kVec2f_GrSLType, kDefault_GrSLPre cision,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 #ifdef SK_GAMMA_APPLY_TO_A8 146 #ifdef SK_GAMMA_APPLY_TO_A8
144 const GrDistanceFieldTextureEffect& dfTexEffect = 147 const GrDistanceFieldTextureEffect& dfTexEffect =
145 proc.cast<GrDistanceFieldTextureEffect>(); 148 proc.cast<GrDistanceFieldTextureEffect>();
146 float luminance = dfTexEffect.getLuminance(); 149 float luminance = dfTexEffect.getLuminance();
147 if (luminance != fLuminance) { 150 if (luminance != fLuminance) {
148 pdman.set1f(fLuminanceUni, luminance); 151 pdman.set1f(fLuminanceUni, luminance);
149 fLuminance = luminance; 152 fLuminance = luminance;
150 } 153 }
151 #endif 154 #endif
152 155
156 this->setUniformViewMatrix(pdman, proc.viewMatrix());
157
153 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack er>(); 158 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack er>();
154 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 159 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
155 GrGLfloat c[4]; 160 GrGLfloat c[4];
156 GrColorToRGBAFloat(local.fColor, c); 161 GrColorToRGBAFloat(local.fColor, c);
157 pdman.set4fv(fColorUniform, 1, c); 162 pdman.set4fv(fColorUniform, 1, c);
158 fColor = local.fColor; 163 fColor = local.fColor;
159 } 164 }
160 } 165 }
161 166
162 static inline void GenKey(const GrGeometryProcessor& processor, 167 static inline void GenKey(const GrGeometryProcessor& processor,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 dfTexEffect.inColor(), &fColorUniform); 341 dfTexEffect.inColor(), &fColorUniform);
337 342
338 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord s()->fName); 343 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord s()->fName);
339 344
340 // setup coord outputs 345 // setup coord outputs
341 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), 346 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(),
342 dfTexEffect.inPosition()->fName); 347 dfTexEffect.inPosition()->fName);
343 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), 348 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(),
344 dfTexEffect.inPosition()->fName); 349 dfTexEffect.inPosition()->fName);
345 350
351 // setup uniform viewMatrix
352 this->addUniformViewMatrix(pb);
353
346 // setup position varying 354 // setup position varying
347 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition() , 355 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition() ,
348 vsBuilder->uViewM(), dfTexEffect.inPosition()->fN ame); 356 this->uViewM(), dfTexEffect.inPosition()->fName);
349 357
350 const char* textureSizeUniName = NULL; 358 const char* textureSizeUniName = NULL;
351 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis ibility, 359 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis ibility,
352 kVec2f_GrSLType, kDefault_GrSLPrec ision, 360 kVec2f_GrSLType, kDefault_GrSLPrec ision,
353 "TextureSize", &textureSizeUniName ); 361 "TextureSize", &textureSizeUniName );
354 362
355 fsBuilder->codeAppend("vec4 texColor = "); 363 fsBuilder->codeAppend("vec4 texColor = ");
356 fsBuilder->appendTextureLookup(args.fSamplers[0], 364 fsBuilder->appendTextureLookup(args.fSamplers[0],
357 v.fsIn(), 365 v.fsIn(),
358 kVec2f_GrSLType); 366 kVec2f_GrSLType);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 411
404 GrTexture* texture = proc.texture(0); 412 GrTexture* texture = proc.texture(0);
405 if (texture->width() != fTextureSize.width() || 413 if (texture->width() != fTextureSize.width() ||
406 texture->height() != fTextureSize.height()) { 414 texture->height() != fTextureSize.height()) {
407 fTextureSize = SkISize::Make(texture->width(), texture->height()); 415 fTextureSize = SkISize::Make(texture->width(), texture->height());
408 pdman.set2f(fTextureSizeUni, 416 pdman.set2f(fTextureSizeUni,
409 SkIntToScalar(fTextureSize.width()), 417 SkIntToScalar(fTextureSize.width()),
410 SkIntToScalar(fTextureSize.height())); 418 SkIntToScalar(fTextureSize.height()));
411 } 419 }
412 420
421 this->setUniformViewMatrix(pdman, proc.viewMatrix());
422
413 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG ammaBatchTracker>(); 423 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG ammaBatchTracker>();
414 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 424 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
415 GrGLfloat c[4]; 425 GrGLfloat c[4];
416 GrColorToRGBAFloat(local.fColor, c); 426 GrColorToRGBAFloat(local.fColor, c);
417 pdman.set4fv(fColorUniform, 1, c); 427 pdman.set4fv(fColorUniform, 1, c);
418 fColor = local.fColor; 428 fColor = local.fColor;
419 } 429 }
420 } 430 }
421 431
422 static inline void GenKey(const GrGeometryProcessor& proc, 432 static inline void GenKey(const GrGeometryProcessor& proc,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // setup pass through color 576 // setup pass through color
567 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , NULL, 577 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , NULL,
568 &fColorUniform); 578 &fColorUniform);
569 579
570 // setup coord outputs 580 // setup coord outputs
571 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), 581 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(),
572 dfTexEffect.inPosition()->fName); 582 dfTexEffect.inPosition()->fName);
573 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), 583 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(),
574 dfTexEffect.inPosition()->fName); 584 dfTexEffect.inPosition()->fName);
575 585
586 // setup uniform viewMatrix
587 this->addUniformViewMatrix(pb);
588
576 // setup position varying 589 // setup position varying
577 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition() , 590 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition() , this->uViewM(),
578 vsBuilder->uViewM(), dfTexEffect.inPosition()->fN ame); 591 dfTexEffect.inPosition()->fName);
579 592
580 const char* textureSizeUniName = NULL; 593 const char* textureSizeUniName = NULL;
581 // width, height, 1/(3*width) 594 // width, height, 1/(3*width)
582 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis ibility, 595 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis ibility,
583 kVec3f_GrSLType, kDefault_GrSLPrec ision, 596 kVec3f_GrSLType, kDefault_GrSLPrec ision,
584 "TextureSize", &textureSizeUniName ); 597 "TextureSize", &textureSizeUniName );
585 598
586 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 599 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
587 600
588 SkAssertResult(fsBuilder->enableFeature( 601 SkAssertResult(fsBuilder->enableFeature(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 GrColor textColor = dfTexEffect.getTextColor(); 723 GrColor textColor = dfTexEffect.getTextColor();
711 if (textColor != fTextColor) { 724 if (textColor != fTextColor) {
712 static const float ONE_OVER_255 = 1.f / 255.f; 725 static const float ONE_OVER_255 = 1.f / 255.f;
713 pdman.set3f(fTextColorUni, 726 pdman.set3f(fTextColorUni,
714 GrColorUnpackR(textColor) * ONE_OVER_255, 727 GrColorUnpackR(textColor) * ONE_OVER_255,
715 GrColorUnpackG(textColor) * ONE_OVER_255, 728 GrColorUnpackG(textColor) * ONE_OVER_255,
716 GrColorUnpackB(textColor) * ONE_OVER_255); 729 GrColorUnpackB(textColor) * ONE_OVER_255);
717 fTextColor = textColor; 730 fTextColor = textColor;
718 } 731 }
719 732
733 this->setUniformViewMatrix(pdman, processor.viewMatrix());
734
720 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc hTracker>(); 735 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc hTracker>();
721 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 736 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
722 GrGLfloat c[4]; 737 GrGLfloat c[4];
723 GrColorToRGBAFloat(local.fColor, c); 738 GrColorToRGBAFloat(local.fColor, c);
724 pdman.set4fv(fColorUniform, 1, c); 739 pdman.set4fv(fColorUniform, 1, c);
725 fColor = local.fColor; 740 fColor = local.fColor;
726 } 741 }
727 } 742 }
728 743
729 static inline void GenKey(const GrGeometryProcessor& processor, 744 static inline void GenKey(const GrGeometryProcessor& processor,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; 860 uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
846 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; 861 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0;
847 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; 862 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
848 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), 863 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random),
849 GrProcessorUnitTest::TestMatr ix(random), 864 GrProcessorUnitTest::TestMatr ix(random),
850 textures[texIdx], params, 865 textures[texIdx], params,
851 textures[texIdx2], params2, 866 textures[texIdx2], params2,
852 textColor, 867 textColor,
853 flags); 868 flags);
854 } 869 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDashingEffect.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698