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

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

Issue 1332923003: Remove batchtracker (Closed) Base URL: https://skia.googlesource.com/skia.git@latecreatepathprocessor
Patch Set: tweaks Created 5 years, 3 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 "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
11 #include "gl/GrGLFragmentProcessor.h" 11 #include "gl/GrGLFragmentProcessor.h"
12 #include "gl/GrGLTexture.h" 12 #include "gl/GrGLTexture.h"
13 #include "gl/GrGLGeometryProcessor.h" 13 #include "gl/GrGLGeometryProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "gl/builders/GrGLProgramBuilder.h"
15 15
16 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { 16 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
17 public: 17 public:
18 GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) 18 GrGLBitmapTextGeoProc()
bsalomon 2015/09/10 18:55:31 one line?
joshualitt 2015/09/10 20:08:05 Acknowledged.
19 : fColor(GrColor_ILLEGAL) {} 19 : fColor(GrColor_ILLEGAL) {}
20 20
21 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ 21 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
22 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); 22 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
23 23
24 GrGLGPBuilder* pb = args.fPB; 24 GrGLGPBuilder* pb = args.fPB;
25 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); 25 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
26 26
27 // emit attributes 27 // emit attributes
28 vsBuilder->emitAttributes(cte); 28 vsBuilder->emitAttributes(cte);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 fsBuilder->codeAppend(";"); 67 fsBuilder->codeAppend(";");
68 fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage); 68 fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
69 } else { 69 } else {
70 fsBuilder->codeAppendf("%s = ", args.fOutputCoverage); 70 fsBuilder->codeAppendf("%s = ", args.fOutputCoverage);
71 fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_G rSLType); 71 fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_G rSLType);
72 fsBuilder->codeAppend(";"); 72 fsBuilder->codeAppend(";");
73 } 73 }
74 } 74 }
75 75
76 virtual void setData(const GrGLProgramDataManager& pdman, 76 virtual void setData(const GrGLProgramDataManager& pdman,
77 const GrPrimitiveProcessor& gp, 77 const GrPrimitiveProcessor& gp) override {
78 const GrBatchTracker& bt) override {
79 const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>(); 78 const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
80 if (btgp.color() != fColor && !btgp.hasVertexColor()) { 79 if (btgp.color() != fColor && !btgp.hasVertexColor()) {
81 GrGLfloat c[4]; 80 GrGLfloat c[4];
82 GrColorToRGBAFloat(btgp.color(), c); 81 GrColorToRGBAFloat(btgp.color(), c);
83 pdman.set4fv(fColorUniform, 1, c); 82 pdman.set4fv(fColorUniform, 1, c);
84 fColor = btgp.color(); 83 fColor = btgp.color();
85 } 84 }
86 } 85 }
87 86
88 void setTransformData(const GrPrimitiveProcessor& primProc, 87 void setTransformData(const GrPrimitiveProcessor& primProc,
89 const GrGLProgramDataManager& pdman, 88 const GrGLProgramDataManager& pdman,
90 int index, 89 int index,
91 const SkTArray<const GrCoordTransform*, true>& transfo rms) override { 90 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
92 this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index , transforms); 91 this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index , transforms);
93 } 92 }
94 93
95 static inline void GenKey(const GrGeometryProcessor& proc, 94 static inline void GenKey(const GrGeometryProcessor& proc,
96 const GrBatchTracker& bt,
97 const GrGLSLCaps&, 95 const GrGLSLCaps&,
98 GrProcessorKeyBuilder* b) { 96 GrProcessorKeyBuilder* b) {
99 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); 97 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
100 uint32_t key = 0; 98 uint32_t key = 0;
101 key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0; 99 key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
102 key |= gp.colorIgnored() ? 0x2 : 0x0; 100 key |= gp.colorIgnored() ? 0x2 : 0x0;
103 key |= gp.maskFormat() << 3; 101 key |= gp.maskFormat() << 3;
104 b->add32(key); 102 b->add32(key);
105 103
106 // Currently we hardcode numbers to convert atlas coordinates to normali zed floating point 104 // Currently we hardcode numbers to convert atlas coordinates to normali zed floating point
(...skipping 29 matching lines...) Expand all
136 // we don't do text positioning in batch, so we can't quite do that yet. 134 // we don't do text positioning in batch, so we can't quite do that yet.
137 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; 135 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat;
138 if (hasVertexColor) { 136 if (hasVertexColor) {
139 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); 137 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
140 } 138 }
141 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", 139 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
142 kVec2s_GrVertexAttribTyp e)); 140 kVec2s_GrVertexAttribTyp e));
143 this->addTextureAccess(&fTextureAccess); 141 this->addTextureAccess(&fTextureAccess);
144 } 142 }
145 143
146 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, 144 void GrBitmapTextGeoProc::getGLProcessorKey(const GrGLSLCaps& caps,
bsalomon 2015/09/10 18:55:31 one line?
joshualitt 2015/09/10 20:08:05 Acknowledged.
147 const GrGLSLCaps& caps,
148 GrProcessorKeyBuilder* b) const { 145 GrProcessorKeyBuilder* b) const {
149 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b); 146 GrGLBitmapTextGeoProc::GenKey(*this, caps, b);
150 } 147 }
151 148
152 GrGLPrimitiveProcessor* 149 GrGLPrimitiveProcessor*
153 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, 150 GrBitmapTextGeoProc::createGLInstance(const GrGLSLCaps& caps) const {
bsalomon 2015/09/10 18:55:31 one line?
joshualitt 2015/09/10 20:08:05 Acknowledged.
154 const GrGLSLCaps& caps) const { 151 return new GrGLBitmapTextGeoProc();
155 return new GrGLBitmapTextGeoProc(*this, bt);
156 } 152 }
157 153
158 /////////////////////////////////////////////////////////////////////////////// 154 ///////////////////////////////////////////////////////////////////////////////
159 155
160 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); 156 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
161 157
162 const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) { 158 const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
163 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : 159 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
164 GrProcessorUnitTest::kAlphaTextureIdx; 160 GrProcessorUnitTest::kAlphaTextureIdx;
165 static const SkShader::TileMode kTileModes[] = { 161 static const SkShader::TileMode kTileModes[] = {
(...skipping 18 matching lines...) Expand all
184 break; 180 break;
185 case 2: 181 case 2:
186 format = kARGB_GrMaskFormat; 182 format = kARGB_GrMaskFormat;
187 break; 183 break;
188 } 184 }
189 185
190 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 186 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
191 format, GrTest::TestMatrix(d->fRandom), 187 format, GrTest::TestMatrix(d->fRandom),
192 d->fRandom->nextBool()); 188 d->fRandom->nextBool());
193 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698