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

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

Issue 1110993002: Revert of removing equality / compute invariant loops from GrGeometryProcessors (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup1
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
« 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 const SkMatrix& localMatrix) 121 bool opaqueVertexColors, const SkMatrix & localMatrix)
122 : INHERITED(color, SkMatrix::I(), localMatrix) 122 : INHERITED(color, SkMatrix::I(), localMatrix, opaqueVertexColors)
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();
132 } 133 }
133 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", 134 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
134 kVec2s_GrVertexAttribTyp e)); 135 kVec2s_GrVertexAttribTyp e));
135 this->addTextureAccess(&fTextureAccess); 136 this->addTextureAccess(&fTextureAccess);
136 } 137 }
137 138
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
138 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, 166 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt,
139 const GrGLCaps& caps, 167 const GrGLCaps& caps,
140 GrProcessorKeyBuilder* b) const { 168 GrProcessorKeyBuilder* b) const {
141 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b); 169 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b);
142 } 170 }
143 171
144 GrGLPrimitiveProcessor* 172 GrGLPrimitiveProcessor*
145 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, 173 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt,
146 const GrGLCaps& caps) const { 174 const GrGLCaps& caps) const {
147 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt)); 175 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt));
148 } 176 }
149 177
150 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const { 178 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const {
151 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>(); 179 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>();
152 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, 180 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it,
153 SkToBool(fInColor)); 181 SkToBool(fInColor));
154 local->fUsesLocalCoords = init.fUsesLocalCoords; 182 local->fUsesLocalCoords = init.fUsesLocalCoords;
155 } 183 }
156 184
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
157 /////////////////////////////////////////////////////////////////////////////// 196 ///////////////////////////////////////////////////////////////////////////////
158 197
159 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); 198 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
160 199
161 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random, 200 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
162 GrContext*, 201 GrContext*,
163 const GrDrawTargetCaps&, 202 const GrDrawTargetCaps&,
164 GrTexture* textures[]) { 203 GrTexture* textures[]) {
165 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : 204 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
166 GrProcessorUnitTest::kAlphaTextureIdx; 205 GrProcessorUnitTest::kAlphaTextureIdx;
(...skipping 18 matching lines...) Expand all
185 break; 224 break;
186 case 1: 225 case 1:
187 format = kA565_GrMaskFormat; 226 format = kA565_GrMaskFormat;
188 break; 227 break;
189 case 2: 228 case 2:
190 format = kARGB_GrMaskFormat; 229 format = kARGB_GrMaskFormat;
191 break; 230 break;
192 } 231 }
193 232
194 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, 233 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
195 format, GrProcessorUnitTest::TestMatrix(r andom)); 234 format, random->nextBool(),
235 GrProcessorUnitTest::TestMatrix(random));
196 } 236 }
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