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