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

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

Issue 1713693002: Use unorm shorts for texture coordinates when rendering text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix tabbing Created 4 years, 10 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/GrTest.cpp ('k') | src/gpu/effects/GrDistanceFieldGeoProc.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 "GrBitmapTextGeoProc.h" 8 #include "GrBitmapTextGeoProc.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
(...skipping 13 matching lines...) Expand all
24 24
25 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 25 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
26 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; 26 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
27 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 27 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
28 28
29 // emit attributes 29 // emit attributes
30 varyingHandler->emitAttributes(cte); 30 varyingHandler->emitAttributes(cte);
31 31
32 // compute numbers to be hardcoded to convert texture coordinates from i nt to float 32 // compute numbers to be hardcoded to convert texture coordinates from i nt to float
33 SkASSERT(cte.numTextures() == 1); 33 SkASSERT(cte.numTextures() == 1);
34 GrTexture* atlas = cte.textureAccess(0).getTexture(); 34 SkDEBUGCODE(GrTexture* atlas = cte.textureAccess(0).getTexture());
35 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ; 35 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ;
36 SkScalar recipWidth = 1.0f / atlas->width();
37 SkScalar recipHeight = 1.0f / atlas->height();
38 36
39 GrGLSLVertToFrag v(kVec2f_GrSLType); 37 GrGLSLVertToFrag v(kVec2f_GrSLType);
40 varyingHandler->addVarying("TextureCoords", &v); 38 varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
41 vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), 39 vertBuilder->codeAppendf("%s = %s;", v.vsOut(),
42 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
43 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
44 cte.inTextureCoords()->fName); 40 cte.inTextureCoords()->fName);
45 41
46 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; 42 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
47 // Setup pass through color 43 // Setup pass through color
48 if (!cte.colorIgnored()) { 44 if (!cte.colorIgnored()) {
49 if (cte.hasVertexColor()) { 45 if (cte.hasVertexColor()) {
50 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor); 46 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor);
51 } else { 47 } else {
52 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu tColor, 48 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu tColor,
53 &fColorUniform); 49 &fColorUniform);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 , fMaskFormat(format) { 139 , fMaskFormat(format) {
144 this->initClassID<GrBitmapTextGeoProc>(); 140 this->initClassID<GrBitmapTextGeoProc>();
145 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 141 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
146 142
147 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat || 143 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat ||
148 kA565_GrMaskFormat == fMaskFormat; 144 kA565_GrMaskFormat == fMaskFormat;
149 if (hasVertexColor) { 145 if (hasVertexColor) {
150 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); 146 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
151 } 147 }
152 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", 148 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
153 kVec2s_GrVertexAttribTyp e)); 149 kVec2us_GrVertexAttribTy pe,
150 kHigh_GrSLPrecision));
154 this->addTextureAccess(&fTextureAccess); 151 this->addTextureAccess(&fTextureAccess);
155 } 152 }
156 153
157 void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, 154 void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
158 GrProcessorKeyBuilder* b) const { 155 GrProcessorKeyBuilder* b) const {
159 GrGLBitmapTextGeoProc::GenKey(*this, caps, b); 156 GrGLBitmapTextGeoProc::GenKey(*this, caps, b);
160 } 157 }
161 158
162 GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrGLSLCa ps& caps) const { 159 GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrGLSLCa ps& caps) const {
163 return new GrGLBitmapTextGeoProc(); 160 return new GrGLBitmapTextGeoProc();
(...skipping 28 matching lines...) Expand all
192 break; 189 break;
193 case 2: 190 case 2:
194 format = kARGB_GrMaskFormat; 191 format = kARGB_GrMaskFormat;
195 break; 192 break;
196 } 193 }
197 194
198 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 195 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
199 format, GrTest::TestMatrix(d->fRandom), 196 format, GrTest::TestMatrix(d->fRandom),
200 d->fRandom->nextBool()); 197 d->fRandom->nextBool());
201 } 198 }
OLDNEW
« no previous file with comments | « src/gpu/GrTest.cpp ('k') | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698