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 "GrFontAtlasSizes.h" |
10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
11 #include "GrTexture.h" | 11 #include "GrTexture.h" |
12 #include "gl/GrGLProcessor.h" | 12 #include "gl/GrGLProcessor.h" |
13 #include "gl/GrGLSL.h" | 13 #include "gl/GrGLSL.h" |
14 #include "gl/GrGLTexture.h" | 14 #include "gl/GrGLTexture.h" |
15 #include "gl/GrGLGeometryProcessor.h" | 15 #include "gl/GrGLGeometryProcessor.h" |
16 #include "gl/builders/GrGLProgramBuilder.h" | 16 #include "gl/builders/GrGLProgramBuilder.h" |
17 | 17 |
18 struct BitmapTextBatchTracker { | 18 struct BitmapTextBatchTracker { |
19 GrGPInput fInputColorType; | 19 GrGPInput fInputColorType; |
20 GrColor fColor; | 20 GrColor fColor; |
21 bool fUsesLocalCoords; | 21 bool fUsesLocalCoords; |
22 }; | 22 }; |
23 | 23 |
24 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { | 24 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { |
25 public: | 25 public: |
26 GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) | 26 GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) |
27 : fColor(GrColor_ILLEGAL) {} | 27 : fColor(GrColor_ILLEGAL) {} |
28 | 28 |
29 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ | 29 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
30 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); | 30 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); |
31 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack
er>(); | 31 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack
er>(); |
32 | 32 |
33 GrGLGPBuilder* pb = args.fPB; | 33 GrGLGPBuilder* pb = args.fPB; |
34 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 34 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
35 | 35 |
36 // emit attributes | 36 // emit attributes |
37 vsBuilder->emitAttributes(cte); | 37 vsBuilder->emitAttributes(cte); |
38 | 38 |
39 GrGLVertToFrag v(kVec2f_GrSLType); | 39 GrGLVertToFrag v(kVec2f_GrSLType); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage); | 71 fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage); |
72 } else { | 72 } else { |
73 fsBuilder->codeAppendf("%s = ", args.fOutputCoverage); | 73 fsBuilder->codeAppendf("%s = ", args.fOutputCoverage); |
74 fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_G
rSLType); | 74 fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_G
rSLType); |
75 fsBuilder->codeAppend(";"); | 75 fsBuilder->codeAppend(";"); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 virtual void setData(const GrGLProgramDataManager& pdman, | 79 virtual void setData(const GrGLProgramDataManager& pdman, |
80 const GrPrimitiveProcessor& gp, | 80 const GrPrimitiveProcessor& gp, |
81 const GrBatchTracker& bt) SK_OVERRIDE { | 81 const GrBatchTracker& bt) override { |
82 this->setUniformViewMatrix(pdman, gp.viewMatrix()); | 82 this->setUniformViewMatrix(pdman, gp.viewMatrix()); |
83 | 83 |
84 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); | 84 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); |
85 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 85 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
86 GrGLfloat c[4]; | 86 GrGLfloat c[4]; |
87 GrColorToRGBAFloat(local.fColor, c); | 87 GrColorToRGBAFloat(local.fColor, c); |
88 pdman.set4fv(fColorUniform, 1, c); | 88 pdman.set4fv(fColorUniform, 1, c); |
89 fColor = local.fColor; | 89 fColor = local.fColor; |
90 } | 90 } |
91 } | 91 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 break; | 227 break; |
228 case 2: | 228 case 2: |
229 format = kARGB_GrMaskFormat; | 229 format = kARGB_GrMaskFormat; |
230 break; | 230 break; |
231 } | 231 } |
232 | 232 |
233 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, | 233 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, |
234 format, random->nextBool(), | 234 format, random->nextBool(), |
235 GrProcessorUnitTest::TestMatrix(random)); | 235 GrProcessorUnitTest::TestMatrix(random)); |
236 } | 236 } |
OLD | NEW |