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

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

Issue 1709133003: Revert of Use unorm shorts for texture coordinates when rendering text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 SkDEBUGCODE(GrTexture* atlas = cte.textureAccess(0).getTexture()); 34 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();
36 38
37 GrGLSLVertToFrag v(kVec2f_GrSLType); 39 GrGLSLVertToFrag v(kVec2f_GrSLType);
38 varyingHandler->addVarying("TextureCoords", &v); 40 varyingHandler->addVarying("TextureCoords", &v);
39 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), 41 vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(),
42 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
43 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
40 cte.inTextureCoords()->fName); 44 cte.inTextureCoords()->fName);
41 45
42 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 46 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
43 // Setup pass through color 47 // Setup pass through color
44 if (!cte.colorIgnored()) { 48 if (!cte.colorIgnored()) {
45 if (cte.hasVertexColor()) { 49 if (cte.hasVertexColor()) {
46 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor); 50 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor);
47 } else { 51 } else {
48 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu tColor, 52 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu tColor,
49 &fColorUniform); 53 &fColorUniform);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 , fMaskFormat(format) { 143 , fMaskFormat(format) {
140 this->initClassID<GrBitmapTextGeoProc>(); 144 this->initClassID<GrBitmapTextGeoProc>();
141 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 145 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
142 146
143 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat || 147 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat ||
144 kA565_GrMaskFormat == fMaskFormat; 148 kA565_GrMaskFormat == fMaskFormat;
145 if (hasVertexColor) { 149 if (hasVertexColor) {
146 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); 150 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
147 } 151 }
148 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", 152 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
149 kVec2us_GrVertexAttribTy pe)); 153 kVec2s_GrVertexAttribTyp e));
150 this->addTextureAccess(&fTextureAccess); 154 this->addTextureAccess(&fTextureAccess);
151 } 155 }
152 156
153 void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, 157 void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
154 GrProcessorKeyBuilder* b) const { 158 GrProcessorKeyBuilder* b) const {
155 GrGLBitmapTextGeoProc::GenKey(*this, caps, b); 159 GrGLBitmapTextGeoProc::GenKey(*this, caps, b);
156 } 160 }
157 161
158 GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrGLSLCa ps& caps) const { 162 GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrGLSLCa ps& caps) const {
159 return new GrGLBitmapTextGeoProc(); 163 return new GrGLBitmapTextGeoProc();
(...skipping 28 matching lines...) Expand all
188 break; 192 break;
189 case 2: 193 case 2:
190 format = kARGB_GrMaskFormat; 194 format = kARGB_GrMaskFormat;
191 break; 195 break;
192 } 196 }
193 197
194 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 198 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
195 format, GrTest::TestMatrix(d->fRandom), 199 format, GrTest::TestMatrix(d->fRandom),
196 d->fRandom->nextBool()); 200 d->fRandom->nextBool());
197 } 201 }
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