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

Side by Side Diff: src/gpu/GrOvalRenderer.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/GrGeometryProcessor.cpp ('k') | src/gpu/GrRectBatch.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 "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const GrGLSLCaps&) const ov erride { 167 const GrGLSLCaps&) const ov erride {
168 return SkNEW_ARGS(GLProcessor, (*this, bt)); 168 return SkNEW_ARGS(GLProcessor, (*this, bt));
169 } 169 }
170 170
171 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override { 171 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
172 BatchTracker* local = bt->cast<BatchTracker>(); 172 BatchTracker* local = bt->cast<BatchTracker>();
173 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false); 173 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false);
174 local->fUsesLocalCoords = init.fUsesLocalCoords; 174 local->fUsesLocalCoords = init.fUsesLocalCoords;
175 } 175 }
176 176
177 bool onCanMakeEqual(const GrBatchTracker& m,
178 const GrGeometryProcessor& that,
179 const GrBatchTracker& t) const override {
180 const BatchTracker& mine = m.cast<BatchTracker>();
181 const BatchTracker& theirs = t.cast<BatchTracker>();
182 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
183 that, theirs.fUsesLocalCoords) &&
184 CanCombineOutput(mine.fInputColorType, mine.fColor,
185 theirs.fInputColorType, theirs.fColor);
186 }
187
188 private: 177 private:
189 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) 178 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix)
190 : INHERITED(color, SkMatrix::I(), localMatrix) { 179 : INHERITED(color, SkMatrix::I(), localMatrix) {
191 this->initClassID<CircleEdgeEffect>(); 180 this->initClassID<CircleEdgeEffect>();
192 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType)); 181 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType));
193 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", 182 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge",
194 kVec4f_GrVertexAttrib Type)); 183 kVec4f_GrVertexAttrib Type));
195 fStroke = stroke; 184 fStroke = stroke;
196 } 185 }
197 186
198 bool onIsEqual(const GrGeometryProcessor& other) const override {
199 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>();
200 return cee.fStroke == fStroke;
201 }
202
203 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
204 out->setUnknownSingleComponent();
205 }
206
207 struct BatchTracker { 187 struct BatchTracker {
208 GrGPInput fInputColorType; 188 GrGPInput fInputColorType;
209 GrColor fColor; 189 GrColor fColor;
210 bool fUsesLocalCoords; 190 bool fUsesLocalCoords;
211 }; 191 };
212 192
213 const Attribute* fInPosition; 193 const Attribute* fInPosition;
214 const Attribute* fInCircleEdge; 194 const Attribute* fInCircleEdge;
215 bool fStroke; 195 bool fStroke;
216 196
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 const GrGLSLCaps&) const ov erride { 342 const GrGLSLCaps&) const ov erride {
363 return SkNEW_ARGS(GLProcessor, (*this, bt)); 343 return SkNEW_ARGS(GLProcessor, (*this, bt));
364 } 344 }
365 345
366 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override { 346 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
367 BatchTracker* local = bt->cast<BatchTracker>(); 347 BatchTracker* local = bt->cast<BatchTracker>();
368 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false); 348 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false);
369 local->fUsesLocalCoords = init.fUsesLocalCoords; 349 local->fUsesLocalCoords = init.fUsesLocalCoords;
370 } 350 }
371 351
372 bool onCanMakeEqual(const GrBatchTracker& m,
373 const GrGeometryProcessor& that,
374 const GrBatchTracker& t) const override {
375 const BatchTracker& mine = m.cast<BatchTracker>();
376 const BatchTracker& theirs = t.cast<BatchTracker>();
377 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
378 that, theirs.fUsesLocalCoords) &&
379 CanCombineOutput(mine.fInputColorType, mine.fColor,
380 theirs.fInputColorType, theirs.fColor);
381 }
382
383 private: 352 private:
384 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) 353 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix)
385 : INHERITED(color, SkMatrix::I(), localMatrix) { 354 : INHERITED(color, SkMatrix::I(), localMatrix) {
386 this->initClassID<EllipseEdgeEffect>(); 355 this->initClassID<EllipseEdgeEffect>();
387 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType)); 356 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType));
388 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", 357 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset",
389 kVec2f_GrVertexAtt ribType)); 358 kVec2f_GrVertexAtt ribType));
390 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", 359 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii",
391 kVec4f_GrVertexAttr ibType)); 360 kVec4f_GrVertexAttr ibType));
392 fStroke = stroke; 361 fStroke = stroke;
393 } 362 }
394 363
395 bool onIsEqual(const GrGeometryProcessor& other) const override {
396 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>();
397 return eee.fStroke == fStroke;
398 }
399
400 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
401 out->setUnknownSingleComponent();
402 }
403
404 struct BatchTracker { 364 struct BatchTracker {
405 GrGPInput fInputColorType; 365 GrGPInput fInputColorType;
406 GrColor fColor; 366 GrColor fColor;
407 bool fUsesLocalCoords; 367 bool fUsesLocalCoords;
408 }; 368 };
409 369
410 const Attribute* fInPosition; 370 const Attribute* fInPosition;
411 const Attribute* fInEllipseOffset; 371 const Attribute* fInEllipseOffset;
412 const Attribute* fInEllipseRadii; 372 const Attribute* fInEllipseRadii;
413 bool fStroke; 373 bool fStroke;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 const GrGLSLCaps&) const ov erride { 537 const GrGLSLCaps&) const ov erride {
578 return SkNEW_ARGS(GLProcessor, (*this, bt)); 538 return SkNEW_ARGS(GLProcessor, (*this, bt));
579 } 539 }
580 540
581 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override { 541 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
582 BatchTracker* local = bt->cast<BatchTracker>(); 542 BatchTracker* local = bt->cast<BatchTracker>();
583 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false); 543 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false);
584 local->fUsesLocalCoords = init.fUsesLocalCoords; 544 local->fUsesLocalCoords = init.fUsesLocalCoords;
585 } 545 }
586 546
587 bool onCanMakeEqual(const GrBatchTracker& m,
588 const GrGeometryProcessor& that,
589 const GrBatchTracker& t) const override {
590 const BatchTracker& mine = m.cast<BatchTracker>();
591 const BatchTracker& theirs = t.cast<BatchTracker>();
592 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
593 that, theirs.fUsesLocalCoords) &&
594 CanCombineOutput(mine.fInputColorType, mine.fColor,
595 theirs.fInputColorType, theirs.fColor);
596 }
597
598 private: 547 private:
599 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) 548 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode)
600 : INHERITED(color, viewMatrix) { 549 : INHERITED(color, viewMatrix) {
601 this->initClassID<DIEllipseEdgeEffect>(); 550 this->initClassID<DIEllipseEdgeEffect>();
602 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType)); 551 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType));
603 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0 ", 552 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0 ",
604 kVec2f_GrVertexA ttribType)); 553 kVec2f_GrVertexA ttribType));
605 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1 ", 554 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1 ",
606 kVec2f_GrVertexA ttribType)); 555 kVec2f_GrVertexA ttribType));
607 fMode = mode; 556 fMode = mode;
608 } 557 }
609 558
610 bool onIsEqual(const GrGeometryProcessor& other) const override {
611 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>();
612 return eee.fMode == fMode;
613 }
614
615 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
616 out->setUnknownSingleComponent();
617 }
618
619 struct BatchTracker { 559 struct BatchTracker {
620 GrGPInput fInputColorType; 560 GrGPInput fInputColorType;
621 GrColor fColor; 561 GrColor fColor;
622 bool fUsesLocalCoords; 562 bool fUsesLocalCoords;
623 }; 563 };
624 564
625 const Attribute* fInPosition; 565 const Attribute* fInPosition;
626 const Attribute* fInEllipseOffsets0; 566 const Attribute* fInEllipseOffsets0;
627 const Attribute* fInEllipseOffsets1; 567 const Attribute* fInEllipseOffsets1;
628 Mode fMode; 568 Mode fMode;
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 } 2058 }
2119 2059
2120 BATCH_TEST_DEFINE(RRectBatch) { 2060 BATCH_TEST_DEFINE(RRectBatch) {
2121 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2061 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2122 GrColor color = GrRandomColor(random); 2062 GrColor color = GrRandomColor(random);
2123 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2063 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2124 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2064 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2125 } 2065 }
2126 2066
2127 #endif 2067 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGeometryProcessor.cpp ('k') | src/gpu/GrRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698