OLD | NEW |
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const GrGLCaps&) const over
ride { | 166 const GrGLCaps&) const over
ride { |
167 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 167 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
168 } | 168 } |
169 | 169 |
170 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 170 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
171 BatchTracker* local = bt->cast<BatchTracker>(); | 171 BatchTracker* local = bt->cast<BatchTracker>(); |
172 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 172 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
173 local->fUsesLocalCoords = init.fUsesLocalCoords; | 173 local->fUsesLocalCoords = init.fUsesLocalCoords; |
174 } | 174 } |
175 | 175 |
| 176 bool onCanMakeEqual(const GrBatchTracker& m, |
| 177 const GrGeometryProcessor& that, |
| 178 const GrBatchTracker& t) const override { |
| 179 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 180 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 181 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 182 that, theirs.fUsesLocalCoords) && |
| 183 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 184 theirs.fInputColorType, theirs.fColor); |
| 185 } |
| 186 |
176 private: | 187 private: |
177 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) | 188 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) |
178 : INHERITED(color, SkMatrix::I(), localMatrix) { | 189 : INHERITED(color, SkMatrix::I(), localMatrix) { |
179 this->initClassID<CircleEdgeEffect>(); | 190 this->initClassID<CircleEdgeEffect>(); |
180 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 191 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
181 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", | 192 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", |
182 kVec4f_GrVertexAttrib
Type)); | 193 kVec4f_GrVertexAttrib
Type)); |
183 fStroke = stroke; | 194 fStroke = stroke; |
184 } | 195 } |
185 | 196 |
| 197 bool onIsEqual(const GrGeometryProcessor& other) const override { |
| 198 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); |
| 199 return cee.fStroke == fStroke; |
| 200 } |
| 201 |
| 202 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ |
| 203 out->setUnknownSingleComponent(); |
| 204 } |
| 205 |
186 struct BatchTracker { | 206 struct BatchTracker { |
187 GrGPInput fInputColorType; | 207 GrGPInput fInputColorType; |
188 GrColor fColor; | 208 GrColor fColor; |
189 bool fUsesLocalCoords; | 209 bool fUsesLocalCoords; |
190 }; | 210 }; |
191 | 211 |
192 const Attribute* fInPosition; | 212 const Attribute* fInPosition; |
193 const Attribute* fInCircleEdge; | 213 const Attribute* fInCircleEdge; |
194 bool fStroke; | 214 bool fStroke; |
195 | 215 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 const GrGLCaps&) const over
ride { | 361 const GrGLCaps&) const over
ride { |
342 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 362 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
343 } | 363 } |
344 | 364 |
345 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 365 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
346 BatchTracker* local = bt->cast<BatchTracker>(); | 366 BatchTracker* local = bt->cast<BatchTracker>(); |
347 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 367 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
348 local->fUsesLocalCoords = init.fUsesLocalCoords; | 368 local->fUsesLocalCoords = init.fUsesLocalCoords; |
349 } | 369 } |
350 | 370 |
| 371 bool onCanMakeEqual(const GrBatchTracker& m, |
| 372 const GrGeometryProcessor& that, |
| 373 const GrBatchTracker& t) const override { |
| 374 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 375 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 376 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 377 that, theirs.fUsesLocalCoords) && |
| 378 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 379 theirs.fInputColorType, theirs.fColor); |
| 380 } |
| 381 |
351 private: | 382 private: |
352 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) | 383 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) |
353 : INHERITED(color, SkMatrix::I(), localMatrix) { | 384 : INHERITED(color, SkMatrix::I(), localMatrix) { |
354 this->initClassID<EllipseEdgeEffect>(); | 385 this->initClassID<EllipseEdgeEffect>(); |
355 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 386 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
356 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", | 387 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", |
357 kVec2f_GrVertexAtt
ribType)); | 388 kVec2f_GrVertexAtt
ribType)); |
358 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", | 389 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", |
359 kVec4f_GrVertexAttr
ibType)); | 390 kVec4f_GrVertexAttr
ibType)); |
360 fStroke = stroke; | 391 fStroke = stroke; |
361 } | 392 } |
362 | 393 |
| 394 bool onIsEqual(const GrGeometryProcessor& other) const override { |
| 395 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); |
| 396 return eee.fStroke == fStroke; |
| 397 } |
| 398 |
| 399 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ |
| 400 out->setUnknownSingleComponent(); |
| 401 } |
| 402 |
363 struct BatchTracker { | 403 struct BatchTracker { |
364 GrGPInput fInputColorType; | 404 GrGPInput fInputColorType; |
365 GrColor fColor; | 405 GrColor fColor; |
366 bool fUsesLocalCoords; | 406 bool fUsesLocalCoords; |
367 }; | 407 }; |
368 | 408 |
369 const Attribute* fInPosition; | 409 const Attribute* fInPosition; |
370 const Attribute* fInEllipseOffset; | 410 const Attribute* fInEllipseOffset; |
371 const Attribute* fInEllipseRadii; | 411 const Attribute* fInEllipseRadii; |
372 bool fStroke; | 412 bool fStroke; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 const GrGLCaps&) const over
ride { | 576 const GrGLCaps&) const over
ride { |
537 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 577 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
538 } | 578 } |
539 | 579 |
540 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 580 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
541 BatchTracker* local = bt->cast<BatchTracker>(); | 581 BatchTracker* local = bt->cast<BatchTracker>(); |
542 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 582 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
543 local->fUsesLocalCoords = init.fUsesLocalCoords; | 583 local->fUsesLocalCoords = init.fUsesLocalCoords; |
544 } | 584 } |
545 | 585 |
| 586 bool onCanMakeEqual(const GrBatchTracker& m, |
| 587 const GrGeometryProcessor& that, |
| 588 const GrBatchTracker& t) const override { |
| 589 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 590 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 591 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 592 that, theirs.fUsesLocalCoords) && |
| 593 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 594 theirs.fInputColorType, theirs.fColor); |
| 595 } |
| 596 |
546 private: | 597 private: |
547 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) | 598 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) |
548 : INHERITED(color, viewMatrix) { | 599 : INHERITED(color, viewMatrix) { |
549 this->initClassID<DIEllipseEdgeEffect>(); | 600 this->initClassID<DIEllipseEdgeEffect>(); |
550 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 601 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
551 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", | 602 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", |
552 kVec2f_GrVertexA
ttribType)); | 603 kVec2f_GrVertexA
ttribType)); |
553 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", | 604 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", |
554 kVec2f_GrVertexA
ttribType)); | 605 kVec2f_GrVertexA
ttribType)); |
555 fMode = mode; | 606 fMode = mode; |
556 } | 607 } |
557 | 608 |
| 609 bool onIsEqual(const GrGeometryProcessor& other) const override { |
| 610 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); |
| 611 return eee.fMode == fMode; |
| 612 } |
| 613 |
| 614 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ |
| 615 out->setUnknownSingleComponent(); |
| 616 } |
| 617 |
558 struct BatchTracker { | 618 struct BatchTracker { |
559 GrGPInput fInputColorType; | 619 GrGPInput fInputColorType; |
560 GrColor fColor; | 620 GrColor fColor; |
561 bool fUsesLocalCoords; | 621 bool fUsesLocalCoords; |
562 }; | 622 }; |
563 | 623 |
564 const Attribute* fInPosition; | 624 const Attribute* fInPosition; |
565 const Attribute* fInEllipseOffsets0; | 625 const Attribute* fInEllipseOffsets0; |
566 const Attribute* fInEllipseOffsets1; | 626 const Attribute* fInEllipseOffsets1; |
567 Mode fMode; | 627 Mode fMode; |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 geometry.fInnerXRadius = innerXRadius; | 2222 geometry.fInnerXRadius = innerXRadius; |
2163 geometry.fInnerYRadius = innerYRadius; | 2223 geometry.fInnerYRadius = innerYRadius; |
2164 geometry.fStroke = isStrokeOnly; | 2224 geometry.fStroke = isStrokeOnly; |
2165 geometry.fDevBounds = bounds; | 2225 geometry.fDevBounds = bounds; |
2166 | 2226 |
2167 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2227 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
2168 target->drawBatch(pipelineBuilder, batch, &bounds); | 2228 target->drawBatch(pipelineBuilder, batch, &bounds); |
2169 } | 2229 } |
2170 return true; | 2230 return true; |
2171 } | 2231 } |
OLD | NEW |