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

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

Issue 1276383003: fixup precision with configurable atlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add asserts Created 5 years, 4 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/GrBitmapTextGeoProc.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.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 "GrDistanceFieldGeoProc.h" 8 #include "GrDistanceFieldGeoProc.h"
9 #include "GrFontAtlasSizes.h" 9 #include "GrFontAtlasSizes.h"
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // add varyings 73 // add varyings
74 GrGLVertToFrag recipScale(kFloat_GrSLType); 74 GrGLVertToFrag recipScale(kFloat_GrSLType);
75 GrGLVertToFrag st(kVec2f_GrSLType); 75 GrGLVertToFrag st(kVec2f_GrSLType);
76 bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_Distan ceFieldEffectFlag); 76 bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_Distan ceFieldEffectFlag);
77 args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); 77 args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
78 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor ds()->fName); 78 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor ds()->fName);
79 79
80 // compute numbers to be hardcoded to convert texture coordinates from i nt to float 80 // compute numbers to be hardcoded to convert texture coordinates from i nt to float
81 SkASSERT(dfTexEffect.numTextures() == 1); 81 SkASSERT(dfTexEffect.numTextures() == 1);
82 GrTexture* atlas = dfTexEffect.textureAccess(0).getTexture(); 82 GrTexture* atlas = dfTexEffect.textureAccess(0).getTexture();
83 SkASSERT(atlas); 83 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ;
84 SkScalar recipWidth = 1.0f / atlas->width(); 84 SkScalar recipWidth = 1.0f / atlas->width();
85 SkScalar recipHeight = 1.0f / atlas->height(); 85 SkScalar recipHeight = 1.0f / atlas->height();
86 86
87 GrGLVertToFrag uv(kVec2f_GrSLType); 87 GrGLVertToFrag uv(kVec2f_GrSLType);
88 args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); 88 args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
89 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), 89 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
90 SK_FLT_DECIMAL_DIG, recipWidth, 90 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
91 SK_FLT_DECIMAL_DIG, recipHeight, 91 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
92 dfTexEffect.inTextureCoords()->fName); 92 dfTexEffect.inTextureCoords()->fName);
93 93
94 // Use highp to work around aliasing issues 94 // Use highp to work around aliasing issues
95 fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision , 95 fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision ,
96 pb->ctxInfo().stand ard())); 96 pb->ctxInfo().stand ard()));
97 fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn()); 97 fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
98 98
99 fsBuilder->codeAppend("\tfloat texColor = "); 99 fsBuilder->codeAppend("\tfloat texColor = ");
100 fsBuilder->appendTextureLookup(args.fSamplers[0], 100 fsBuilder->appendTextureLookup(args.fSamplers[0],
101 "uv", 101 "uv",
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // set up varyings 535 // set up varyings
536 bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_Di stanceFieldEffectMask); 536 bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_Di stanceFieldEffectMask);
537 GrGLVertToFrag recipScale(kFloat_GrSLType); 537 GrGLVertToFrag recipScale(kFloat_GrSLType);
538 GrGLVertToFrag st(kVec2f_GrSLType); 538 GrGLVertToFrag st(kVec2f_GrSLType);
539 args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); 539 args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
540 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor ds()->fName); 540 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor ds()->fName);
541 541
542 // compute numbers to be hardcoded to convert texture coordinates from i nt to float 542 // compute numbers to be hardcoded to convert texture coordinates from i nt to float
543 SkASSERT(dfTexEffect.numTextures() == 1); 543 SkASSERT(dfTexEffect.numTextures() == 1);
544 GrTexture* atlas = dfTexEffect.textureAccess(0).getTexture(); 544 GrTexture* atlas = dfTexEffect.textureAccess(0).getTexture();
545 SkASSERT(atlas); 545 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ;
546 SkScalar recipWidth = 1.0f / atlas->width(); 546 SkScalar recipWidth = 1.0f / atlas->width();
547 SkScalar recipHeight = 1.0f / atlas->height(); 547 SkScalar recipHeight = 1.0f / atlas->height();
548 548
549 GrGLVertToFrag uv(kVec2f_GrSLType); 549 GrGLVertToFrag uv(kVec2f_GrSLType);
550 args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); 550 args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
551 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), 551 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
552 SK_FLT_DECIMAL_DIG, recipWidth, 552 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
553 SK_FLT_DECIMAL_DIG, recipHeight, 553 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
554 dfTexEffect.inTextureCoords()->fName); 554 dfTexEffect.inTextureCoords()->fName);
555 555
556 // add frag shader code 556 // add frag shader code
557 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 557 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
558 558
559 SkAssertResult(fsBuilder->enableFeature( 559 SkAssertResult(fsBuilder->enableFeature(
560 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); 560 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
561 561
562 // create LCD offset adjusted by inverse of transform 562 // create LCD offset adjusted by inverse of transform
563 // Use highp to work around aliasing issues 563 // Use highp to work around aliasing issues
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; 767 uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
768 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; 768 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0;
769 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; 769 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
770 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), 770 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom),
771 GrTest::TestMatrix(d->fRandom), 771 GrTest::TestMatrix(d->fRandom),
772 d->fTextures[texIdx], params, 772 d->fTextures[texIdx], params,
773 wa, 773 wa,
774 flags, 774 flags,
775 d->fRandom->nextBool()); 775 d->fRandom->nextBool());
776 } 776 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698