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

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

Issue 1111603004: removing equality / compute invariant loops from GrGeometryProcessors (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup1
Patch Set: tweaks 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
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 GrColor fColor; 111 GrColor fColor;
112 UniformHandle fColorUniform; 112 UniformHandle fColorUniform;
113 113
114 typedef GrGLGeometryProcessor INHERITED; 114 typedef GrGLGeometryProcessor INHERITED;
115 }; 115 };
116 116
117 /////////////////////////////////////////////////////////////////////////////// 117 ///////////////////////////////////////////////////////////////////////////////
118 118
119 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, 119 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture,
120 const GrTextureParams& params, GrMaskFo rmat format, 120 const GrTextureParams& params, GrMaskFo rmat format,
121 bool opaqueVertexColors, const SkMatrix & localMatrix) 121 const SkMatrix& localMatrix)
122 : INHERITED(color, SkMatrix::I(), localMatrix, opaqueVertexColors) 122 : INHERITED(color, SkMatrix::I(), localMatrix)
123 , fTextureAccess(texture, params) 123 , fTextureAccess(texture, params)
124 , fInColor(NULL) 124 , fInColor(NULL)
125 , fMaskFormat(format) { 125 , fMaskFormat(format) {
126 this->initClassID<GrBitmapTextGeoProc>(); 126 this->initClassID<GrBitmapTextGeoProc>();
127 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 127 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
128 128
129 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; 129 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat;
130 if (hasVertexColor) { 130 if (hasVertexColor) {
131 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); 131 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
132 this->setHasVertexColor();
133 } 132 }
134 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", 133 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
135 kVec2s_GrVertexAttribTyp e)); 134 kVec2s_GrVertexAttribTyp e));
136 this->addTextureAccess(&fTextureAccess); 135 this->addTextureAccess(&fTextureAccess);
137 } 136 }
138 137
139 bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const {
140 const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>();
141 return SkToBool(this->inColor()) == SkToBool(gp.inColor());
142 }
143
144 void GrBitmapTextGeoProc::onGetInvariantOutputColor(GrInitInvariantOutput* out) const {
145 if (kARGB_GrMaskFormat == fMaskFormat) {
146 out->setUnknownFourComponents();
147 }
148 }
149
150 void GrBitmapTextGeoProc::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou t) const {
151 if (kARGB_GrMaskFormat != fMaskFormat) {
152 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
153 out->setUnknownSingleComponent();
154 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
155 out->setUnknownOpaqueFourComponents();
156 out->setUsingLCDCoverage();
157 } else {
158 out->setUnknownFourComponents();
159 out->setUsingLCDCoverage();
160 }
161 } else {
162 out->setKnownSingleComponent(0xff);
163 }
164 }
165
166 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, 138 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt,
167 const GrGLSLCaps& caps, 139 const GrGLSLCaps& caps,
168 GrProcessorKeyBuilder* b) const { 140 GrProcessorKeyBuilder* b) const {
169 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b); 141 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b);
170 } 142 }
171 143
172 GrGLPrimitiveProcessor* 144 GrGLPrimitiveProcessor*
173 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, 145 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt,
174 const GrGLSLCaps& caps) const { 146 const GrGLSLCaps& caps) const {
175 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt)); 147 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt));
176 } 148 }
177 149
178 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const { 150 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const {
179 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>(); 151 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>();
180 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, 152 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it,
181 SkToBool(fInColor)); 153 SkToBool(fInColor));
182 local->fUsesLocalCoords = init.fUsesLocalCoords; 154 local->fUsesLocalCoords = init.fUsesLocalCoords;
183 } 155 }
184 156
185 bool GrBitmapTextGeoProc::onCanMakeEqual(const GrBatchTracker& m,
186 const GrGeometryProcessor& that,
187 const GrBatchTracker& t) const {
188 const BitmapTextBatchTracker& mine = m.cast<BitmapTextBatchTracker>();
189 const BitmapTextBatchTracker& theirs = t.cast<BitmapTextBatchTracker>();
190 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
191 that, theirs.fUsesLocalCoords) &&
192 CanCombineOutput(mine.fInputColorType, mine.fColor,
193 theirs.fInputColorType, theirs.fColor);
194 }
195
196 /////////////////////////////////////////////////////////////////////////////// 157 ///////////////////////////////////////////////////////////////////////////////
197 158
198 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); 159 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
199 160
200 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random, 161 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
201 GrContext*, 162 GrContext*,
202 const GrDrawTargetCaps&, 163 const GrDrawTargetCaps&,
203 GrTexture* textures[]) { 164 GrTexture* textures[]) {
204 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : 165 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
205 GrProcessorUnitTest::kAlphaTextureIdx; 166 GrProcessorUnitTest::kAlphaTextureIdx;
(...skipping 18 matching lines...) Expand all
224 break; 185 break;
225 case 1: 186 case 1:
226 format = kA565_GrMaskFormat; 187 format = kA565_GrMaskFormat;
227 break; 188 break;
228 case 2: 189 case 2:
229 format = kARGB_GrMaskFormat; 190 format = kARGB_GrMaskFormat;
230 break; 191 break;
231 } 192 }
232 193
233 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, 194 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
234 format, random->nextBool(), 195 format, GrTest::TestMatrix(random));
235 GrTest::TestMatrix(random));
236 } 196 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698