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

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

Issue 1127953003: Remove viewmatrix from GrGeometryProcessor base class (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup3
Patch Set: Created 5 years, 7 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", " 47 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", "
48 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut() , 48 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut() ,
49 cte.inTextureCoords()->fName); 49 cte.inTextureCoords()->fName);
50 } 50 }
51 51
52 // Setup pass through color 52 // Setup pass through color
53 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , cte.inColor(), 53 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , cte.inColor(),
54 &fColorUniform); 54 &fColorUniform);
55 55
56 // Setup position 56 // Setup position
57 this->setupPosition(pb, gpArgs, cte.inPosition()->fName, cte.viewMatrix( )); 57 this->setupPosition(pb, gpArgs, cte.inPosition()->fName);
58 58
59 // emit transforms 59 // emit transforms
60 this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->f Name, 60 this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->f Name,
61 cte.localMatrix(), args.fTransformsIn, args.fTransf ormsOut); 61 cte.localMatrix(), args.fTransformsIn, args.fTransf ormsOut);
62 62
63 GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); 63 GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
64 if (cte.maskFormat() == kARGB_GrMaskFormat) { 64 if (cte.maskFormat() == kARGB_GrMaskFormat) {
65 fsBuilder->codeAppendf("%s = ", args.fOutputColor); 65 fsBuilder->codeAppendf("%s = ", args.fOutputColor);
66 fsBuilder->appendTextureLookupAndModulate(args.fOutputColor, 66 fsBuilder->appendTextureLookupAndModulate(args.fOutputColor,
67 args.fSamplers[0], 67 args.fSamplers[0],
68 v.fsIn(), 68 v.fsIn(),
69 kVec2f_GrSLType); 69 kVec2f_GrSLType);
70 fsBuilder->codeAppend(";"); 70 fsBuilder->codeAppend(";");
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) override { 81 const GrBatchTracker& bt) override {
82 this->setUniformViewMatrix(pdman, gp.viewMatrix());
83
84 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); 82 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>();
85 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) { 83 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo r) {
86 GrGLfloat c[4]; 84 GrGLfloat c[4];
87 GrColorToRGBAFloat(local.fColor, c); 85 GrColorToRGBAFloat(local.fColor, c);
88 pdman.set4fv(fColorUniform, 1, c); 86 pdman.set4fv(fColorUniform, 1, c);
89 fColor = local.fColor; 87 fColor = local.fColor;
90 } 88 }
91 } 89 }
92 90
93 static inline void GenKey(const GrGeometryProcessor& proc, 91 static inline void GenKey(const GrGeometryProcessor& proc,
94 const GrBatchTracker& bt, 92 const GrBatchTracker& bt,
95 const GrGLSLCaps&, 93 const GrGLSLCaps&,
96 GrProcessorKeyBuilder* b) { 94 GrProcessorKeyBuilder* b) {
97 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); 95 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>();
98 // We have to put the optional vertex attribute as part of the key. See the comment 96 // We have to put the optional vertex attribute as part of the key. See the comment
99 // on addVertexAttrib. 97 // on addVertexAttrib.
100 // TODO When we have deferred geometry we can fix this 98 // TODO When we have deferred geometry we can fix this
101 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); 99 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
102 uint32_t key = 0; 100 uint32_t key = 0;
103 key |= SkToBool(gp.inColor()) ? 0x1 : 0x0; 101 key |= SkToBool(gp.inColor()) ? 0x1 : 0x0;
104 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0 x2 : 0x0; 102 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0 x2 : 0x0;
105 key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0; 103 key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0;
106 key |= ComputePosKey(gp.viewMatrix()) << 3;
107 b->add32(local.fInputColorType << 16 | key); 104 b->add32(local.fInputColorType << 16 | key);
108 } 105 }
109 106
110 private: 107 private:
111 GrColor fColor; 108 GrColor fColor;
112 UniformHandle fColorUniform; 109 UniformHandle fColorUniform;
113 110
114 typedef GrGLGeometryProcessor INHERITED; 111 typedef GrGLGeometryProcessor INHERITED;
115 }; 112 };
116 113
117 /////////////////////////////////////////////////////////////////////////////// 114 ///////////////////////////////////////////////////////////////////////////////
118 115
119 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, 116 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture,
120 const GrTextureParams& params, GrMaskFo rmat format, 117 const GrTextureParams& params, GrMaskFo rmat format,
121 const SkMatrix& localMatrix) 118 const SkMatrix& localMatrix)
122 : INHERITED(SkMatrix::I(), localMatrix) 119 : INHERITED(localMatrix)
123 , fColor(color) 120 , fColor(color)
124 , fTextureAccess(texture, params) 121 , fTextureAccess(texture, params)
125 , fInColor(NULL) 122 , fInColor(NULL)
126 , fMaskFormat(format) { 123 , fMaskFormat(format) {
127 this->initClassID<GrBitmapTextGeoProc>(); 124 this->initClassID<GrBitmapTextGeoProc>();
128 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 125 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
129 126
130 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; 127 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat;
131 if (hasVertexColor) { 128 if (hasVertexColor) {
132 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); 129 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 format = kA565_GrMaskFormat; 185 format = kA565_GrMaskFormat;
189 break; 186 break;
190 case 2: 187 case 2:
191 format = kARGB_GrMaskFormat; 188 format = kARGB_GrMaskFormat;
192 break; 189 break;
193 } 190 }
194 191
195 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, 192 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
196 format, GrTest::TestMatrix(random)); 193 format, GrTest::TestMatrix(random));
197 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698