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

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

Issue 1271163003: Revert of Break LCD and Bitmap text dependency on hardcoded atlas values (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrFontAtlasSizes.h ('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 "GrFontAtlasSizes.h" 9 #include "GrFontAtlasSizes.h"
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
(...skipping 10 matching lines...) Expand all
21 21
22 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ 22 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
23 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); 23 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
24 24
25 GrGLGPBuilder* pb = args.fPB; 25 GrGLGPBuilder* pb = args.fPB;
26 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); 26 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
27 27
28 // emit attributes 28 // emit attributes
29 vsBuilder->emitAttributes(cte); 29 vsBuilder->emitAttributes(cte);
30 30
31 // compute numbers to be hardcoded to convert texture coordinates from i nt to float
32 SkASSERT(cte.numTextures() == 1);
33 GrTexture* atlas = cte.textureAccess(0).getTexture();
34 SkASSERT(atlas);
35 SkScalar recipWidth = 1.0f / atlas->width();
36 SkScalar recipHeight = 1.0f / atlas->height();
37
38 GrGLVertToFrag v(kVec2f_GrSLType); 31 GrGLVertToFrag v(kVec2f_GrSLType);
39 pb->addVarying("TextureCoords", &v); 32 pb->addVarying("TextureCoords", &v);
40 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), 33 // this is only used with text, so our texture bounds always match the g lyph atlas
41 SK_FLT_DECIMAL_DIG, recipWidth, 34 if (cte.maskFormat() == kA8_GrMaskFormat) {
42 SK_FLT_DECIMAL_DIG, recipHeight, 35 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_A8_RECIP_WIDTH ", "
43 cte.inTextureCoords()->fName); 36 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut() ,
37 cte.inTextureCoords()->fName);
38 } else {
39 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", "
40 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut() ,
41 cte.inTextureCoords()->fName);
42 }
44 43
45 // Setup pass through color 44 // Setup pass through color
46 if (!cte.colorIgnored()) { 45 if (!cte.colorIgnored()) {
47 if (cte.hasVertexColor()) { 46 if (cte.hasVertexColor()) {
48 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); 47 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
49 } else { 48 } else {
50 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); 49 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
51 } 50 }
52 } 51 }
53 52
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 static inline void GenKey(const GrGeometryProcessor& proc, 95 static inline void GenKey(const GrGeometryProcessor& proc,
97 const GrBatchTracker& bt, 96 const GrBatchTracker& bt,
98 const GrGLSLCaps&, 97 const GrGLSLCaps&,
99 GrProcessorKeyBuilder* b) { 98 GrProcessorKeyBuilder* b) {
100 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); 99 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
101 uint32_t key = 0; 100 uint32_t key = 0;
102 key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0; 101 key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
103 key |= gp.colorIgnored() ? 0x2 : 0x0; 102 key |= gp.colorIgnored() ? 0x2 : 0x0;
104 key |= gp.maskFormat() << 3; 103 key |= gp.maskFormat() << 3;
105 b->add32(key); 104 b->add32(key);
106
107 // Currently we hardcode numbers to convert atlas coordinates to normali zed floating point
108 SkASSERT(gp.numTextures() == 1);
109 GrTexture* atlas = gp.textureAccess(0).getTexture();
110 SkASSERT(atlas);
111 b->add32(atlas->width());
112 b->add32(atlas->height());
113 } 105 }
114 106
115 private: 107 private:
116 GrColor fColor; 108 GrColor fColor;
117 UniformHandle fColorUniform; 109 UniformHandle fColorUniform;
118 110
119 typedef GrGLGeometryProcessor INHERITED; 111 typedef GrGLGeometryProcessor INHERITED;
120 }; 112 };
121 113
122 /////////////////////////////////////////////////////////////////////////////// 114 ///////////////////////////////////////////////////////////////////////////////
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 break; 177 break;
186 case 2: 178 case 2:
187 format = kARGB_GrMaskFormat; 179 format = kARGB_GrMaskFormat;
188 break; 180 break;
189 } 181 }
190 182
191 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 183 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
192 format, GrTest::TestMatrix(d->fRandom), 184 format, GrTest::TestMatrix(d->fRandom),
193 d->fRandom->nextBool()); 185 d->fRandom->nextBool());
194 } 186 }
OLDNEW
« no previous file with comments | « src/gpu/GrFontAtlasSizes.h ('k') | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698