OLD | NEW |
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 "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
10 #include "GrTexture.h" | 11 #include "GrTexture.h" |
11 #include "gl/GrGLProcessor.h" | 12 #include "gl/GrGLProcessor.h" |
12 #include "gl/GrGLSL.h" | 13 #include "gl/GrGLSL.h" |
13 #include "gl/GrGLTexture.h" | 14 #include "gl/GrGLTexture.h" |
14 #include "gl/GrGLGeometryProcessor.h" | 15 #include "gl/GrGLGeometryProcessor.h" |
15 #include "gl/builders/GrGLProgramBuilder.h" | 16 #include "gl/builders/GrGLProgramBuilder.h" |
16 | 17 |
17 struct BitmapTextBatchTracker { | 18 struct BitmapTextBatchTracker { |
18 GrGPInput fInputColorType; | 19 GrGPInput fInputColorType; |
(...skipping 11 matching lines...) Expand all Loading... |
30 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack
er>(); | 31 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack
er>(); |
31 | 32 |
32 GrGLGPBuilder* pb = args.fPB; | 33 GrGLGPBuilder* pb = args.fPB; |
33 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 34 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
34 | 35 |
35 // emit attributes | 36 // emit attributes |
36 vsBuilder->emitAttributes(cte); | 37 vsBuilder->emitAttributes(cte); |
37 | 38 |
38 GrGLVertToFrag v(kVec2f_GrSLType); | 39 GrGLVertToFrag v(kVec2f_GrSLType); |
39 pb->addVarying("TextureCoords", &v); | 40 pb->addVarying("TextureCoords", &v); |
40 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), cte.inTextureCoords()->fNa
me); | 41 // this is only used with text, so our texture bounds always match the g
lyph atlas |
| 42 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", " |
| 43 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut(), |
| 44 cte.inTextureCoords()->fName); |
41 | 45 |
42 // Setup pass through color | 46 // Setup pass through color |
43 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, cte.inColor(), | 47 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, cte.inColor(), |
44 &fColorUniform); | 48 &fColorUniform); |
45 | 49 |
46 // Setup position | 50 // Setup position |
47 this->setupPosition(pb, gpArgs, cte.inPosition()->fName, cte.viewMatrix(
)); | 51 this->setupPosition(pb, gpArgs, cte.inPosition()->fName, cte.viewMatrix(
)); |
48 | 52 |
49 // emit transforms | 53 // emit transforms |
50 this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->f
Name, | 54 this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->f
Name, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 , fMaskFormat(format) { | 119 , fMaskFormat(format) { |
116 this->initClassID<GrBitmapTextGeoProc>(); | 120 this->initClassID<GrBitmapTextGeoProc>(); |
117 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 121 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
118 | 122 |
119 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; | 123 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; |
120 if (hasVertexColor) { | 124 if (hasVertexColor) { |
121 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 125 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
122 this->setHasVertexColor(); | 126 this->setHasVertexColor(); |
123 } | 127 } |
124 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 128 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
125 kVec2f_GrVertexAttribTyp
e)); | 129 kVec2s_GrVertexAttribTyp
e)); |
126 this->addTextureAccess(&fTextureAccess); | 130 this->addTextureAccess(&fTextureAccess); |
127 } | 131 } |
128 | 132 |
129 bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const { | 133 bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const { |
130 const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>(); | 134 const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>(); |
131 return SkToBool(this->inColor()) == SkToBool(gp.inColor()); | 135 return SkToBool(this->inColor()) == SkToBool(gp.inColor()); |
132 } | 136 } |
133 | 137 |
134 void GrBitmapTextGeoProc::onGetInvariantOutputColor(GrInitInvariantOutput* out)
const { | 138 void GrBitmapTextGeoProc::onGetInvariantOutputColor(GrInitInvariantOutput* out)
const { |
135 if (kARGB_GrMaskFormat == fMaskFormat) { | 139 if (kARGB_GrMaskFormat == fMaskFormat) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 break; | 221 break; |
218 case 2: | 222 case 2: |
219 format = kARGB_GrMaskFormat; | 223 format = kARGB_GrMaskFormat; |
220 break; | 224 break; |
221 } | 225 } |
222 | 226 |
223 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, | 227 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, |
224 format, random->nextBool(), | 228 format, random->nextBool(), |
225 GrProcessorUnitTest::TestMatrix(random)); | 229 GrProcessorUnitTest::TestMatrix(random)); |
226 } | 230 } |
OLD | NEW |