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

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

Issue 2437063002: re-re-land of skslc now automatically turns on derivatives support (Closed)
Patch Set: Created 4 years, 2 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.cpp ('k') | src/gpu/gl/builders/GrGLShaderStringBuilder.cpp » ('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 "GrDistanceFieldGeoProc.h" 8 #include "GrDistanceFieldGeoProc.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
(...skipping 17 matching lines...) Expand all
28 : fViewMatrix(SkMatrix::InvalidMatrix()) 28 : fViewMatrix(SkMatrix::InvalidMatrix())
29 #ifdef SK_GAMMA_APPLY_TO_A8 29 #ifdef SK_GAMMA_APPLY_TO_A8
30 , fDistanceAdjust(-1.0f) 30 , fDistanceAdjust(-1.0f)
31 #endif 31 #endif
32 {} 32 {}
33 33
34 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ 34 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
35 const GrDistanceFieldA8TextGeoProc& dfTexEffect = 35 const GrDistanceFieldA8TextGeoProc& dfTexEffect =
36 args.fGP.cast<GrDistanceFieldA8TextGeoProc>(); 36 args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
37 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; 37 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
38 SkAssertResult(fragBuilder->enableFeature(
39 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
40 38
41 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 39 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
42 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; 40 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
43 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 41 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
44 42
45 // emit attributes 43 // emit attributes
46 varyingHandler->emitAttributes(dfTexEffect); 44 varyingHandler->emitAttributes(dfTexEffect);
47 45
48 #ifdef SK_GAMMA_APPLY_TO_A8 46 #ifdef SK_GAMMA_APPLY_TO_A8
49 // adjust based on gamma 47 // adjust based on gamma
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 class GrGLDistanceFieldPathGeoProc : public GrGLSLGeometryProcessor { 304 class GrGLDistanceFieldPathGeoProc : public GrGLSLGeometryProcessor {
307 public: 305 public:
308 GrGLDistanceFieldPathGeoProc() 306 GrGLDistanceFieldPathGeoProc()
309 : fViewMatrix(SkMatrix::InvalidMatrix()) 307 : fViewMatrix(SkMatrix::InvalidMatrix())
310 , fTextureSize(SkISize::Make(-1, -1)) {} 308 , fTextureSize(SkISize::Make(-1, -1)) {}
311 309
312 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ 310 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
313 const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistance FieldPathGeoProc>(); 311 const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistance FieldPathGeoProc>();
314 312
315 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; 313 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
316 SkAssertResult(fragBuilder->enableFeature(
317 GrGLSLFragmentShaderBuilder::kStandardDeriv atives_GLSLFeature));
318 314
319 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 315 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
320 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; 316 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
321 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 317 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
322 318
323 // emit attributes 319 // emit attributes
324 varyingHandler->emitAttributes(dfTexEffect); 320 varyingHandler->emitAttributes(dfTexEffect);
325 321
326 GrGLSLVertToFrag v(kVec2f_GrSLType); 322 GrGLSLVertToFrag v(kVec2f_GrSLType);
327 varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision); 323 varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ; 599 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ;
604 600
605 GrGLSLVertToFrag st(kVec2f_GrSLType); 601 GrGLSLVertToFrag st(kVec2f_GrSLType);
606 varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision) ; 602 varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision) ;
607 vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(), 603 vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
608 atlas->width(), atlas->height(), 604 atlas->width(), atlas->height(),
609 dfTexEffect.inTextureCoords()->fName); 605 dfTexEffect.inTextureCoords()->fName);
610 606
611 // add frag shader code 607 // add frag shader code
612 608
613 SkAssertResult(fragBuilder->enableFeature(
614 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
615
616 // create LCD offset adjusted by inverse of transform 609 // create LCD offset adjusted by inverse of transform
617 // Use highp to work around aliasing issues 610 // Use highp to work around aliasing issues
618 fragBuilder->appendPrecisionModifier(kHigh_GrSLPrecision); 611 fragBuilder->appendPrecisionModifier(kHigh_GrSLPrecision);
619 fragBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn()); 612 fragBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
620 fragBuilder->appendPrecisionModifier(kHigh_GrSLPrecision); 613 fragBuilder->appendPrecisionModifier(kHigh_GrSLPrecision);
621 614
622 SkScalar lcdDelta = 1.0f / (3.0f * atlas->width()); 615 SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
623 if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) { 616 if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
624 fragBuilder->codeAppendf("float delta = -%.*f;\n", SK_FLT_DECIMAL_DI G, lcdDelta); 617 fragBuilder->codeAppendf("float delta = -%.*f;\n", SK_FLT_DECIMAL_DI G, lcdDelta);
625 } else { 618 } else {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ; 834 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ;
842 } 835 }
843 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; 836 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
844 return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom), 837 return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom),
845 GrTest::TestMatrix(d->fRandom), 838 GrTest::TestMatrix(d->fRandom),
846 d->fTextures[texIdx], params, 839 d->fTextures[texIdx], params,
847 wa, 840 wa,
848 flags, 841 flags,
849 d->fRandom->nextBool()); 842 d->fRandom->nextBool());
850 } 843 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/gl/builders/GrGLShaderStringBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698