OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrAAHairLinePathRenderer.h" | 8 #include "GrAAHairLinePathRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 SkIRect fDevClipBounds; | 702 SkIRect fDevClipBounds; |
703 }; | 703 }; |
704 | 704 |
705 // TODO Batch itself should not hold on to index buffers. Instead, these sh
ould live in the | 705 // TODO Batch itself should not hold on to index buffers. Instead, these sh
ould live in the |
706 // cache. | 706 // cache. |
707 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* linesI
ndexBuffer, | 707 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* linesI
ndexBuffer, |
708 const GrIndexBuffer* quadsIndexBuffer) { | 708 const GrIndexBuffer* quadsIndexBuffer) { |
709 return SkNEW_ARGS(AAHairlineBatch, (geometry, linesIndexBuffer, quadsInd
exBuffer)); | 709 return SkNEW_ARGS(AAHairlineBatch, (geometry, linesIndexBuffer, quadsInd
exBuffer)); |
710 } | 710 } |
711 | 711 |
712 const char* name() const SK_OVERRIDE { return "AAHairlineBatch"; } | 712 const char* name() const override { return "AAHairlineBatch"; } |
713 | 713 |
714 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 714 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
715 // When this is called on a batch, there is only one geometry bundle | 715 // When this is called on a batch, there is only one geometry bundle |
716 out->setKnownFourComponents(fGeoData[0].fColor); | 716 out->setKnownFourComponents(fGeoData[0].fColor); |
717 } | 717 } |
718 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 718 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
719 out->setUnknownSingleComponent(); | 719 out->setUnknownSingleComponent(); |
720 } | 720 } |
721 | 721 |
722 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 722 void initBatchTracker(const GrPipelineInfo& init) override { |
723 // Handle any color overrides | 723 // Handle any color overrides |
724 if (init.fColorIgnored) { | 724 if (init.fColorIgnored) { |
725 fGeoData[0].fColor = GrColor_ILLEGAL; | 725 fGeoData[0].fColor = GrColor_ILLEGAL; |
726 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 726 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
727 fGeoData[0].fColor = init.fOverrideColor; | 727 fGeoData[0].fColor = init.fOverrideColor; |
728 } | 728 } |
729 | 729 |
730 // setup batch properties | 730 // setup batch properties |
731 fBatch.fColorIgnored = init.fColorIgnored; | 731 fBatch.fColorIgnored = init.fColorIgnored; |
732 fBatch.fColor = fGeoData[0].fColor; | 732 fBatch.fColor = fGeoData[0].fColor; |
733 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 733 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
734 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 734 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
735 fBatch.fCoverage = fGeoData[0].fCoverage; | 735 fBatch.fCoverage = fGeoData[0].fCoverage; |
736 SkDEBUGCODE(fBatch.fDevBounds = fGeoData[0].fDevBounds;) | 736 SkDEBUGCODE(fBatch.fDevBounds = fGeoData[0].fDevBounds;) |
737 } | 737 } |
738 | 738 |
739 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE; | 739 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override; |
740 | 740 |
741 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 741 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
742 | 742 |
743 private: | 743 private: |
744 typedef SkTArray<SkPoint, true> PtArray; | 744 typedef SkTArray<SkPoint, true> PtArray; |
745 typedef SkTArray<int, true> IntArray; | 745 typedef SkTArray<int, true> IntArray; |
746 typedef SkTArray<float, true> FloatArray; | 746 typedef SkTArray<float, true> FloatArray; |
747 | 747 |
748 AAHairlineBatch(const Geometry& geometry, const GrIndexBuffer* linesIndexBuf
fer, | 748 AAHairlineBatch(const Geometry& geometry, const GrIndexBuffer* linesIndexBuf
fer, |
749 const GrIndexBuffer* quadsIndexBuffer) | 749 const GrIndexBuffer* quadsIndexBuffer) |
750 : fLinesIndexBuffer(linesIndexBuffer) | 750 : fLinesIndexBuffer(linesIndexBuffer) |
751 , fQuadsIndexBuffer(quadsIndexBuffer) { | 751 , fQuadsIndexBuffer(quadsIndexBuffer) { |
752 SkASSERT(linesIndexBuffer && quadsIndexBuffer); | 752 SkASSERT(linesIndexBuffer && quadsIndexBuffer); |
753 this->initClassID<AAHairlineBatch>(); | 753 this->initClassID<AAHairlineBatch>(); |
754 fGeoData.push_back(geometry); | 754 fGeoData.push_back(geometry); |
755 } | 755 } |
756 | 756 |
757 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 757 bool onCombineIfPossible(GrBatch* t) override { |
758 AAHairlineBatch* that = t->cast<AAHairlineBatch>(); | 758 AAHairlineBatch* that = t->cast<AAHairlineBatch>(); |
759 | 759 |
760 if (this->viewMatrix().hasPerspective() != that->viewMatrix().hasPerspec
tive()) { | 760 if (this->viewMatrix().hasPerspective() != that->viewMatrix().hasPerspec
tive()) { |
761 return false; | 761 return false; |
762 } | 762 } |
763 | 763 |
764 // We go to identity if we don't have perspective | 764 // We go to identity if we don't have perspective |
765 if (this->viewMatrix().hasPerspective() && | 765 if (this->viewMatrix().hasPerspective() && |
766 !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 766 !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
767 return false; | 767 return false; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 geometry.fPath = path; | 1059 geometry.fPath = path; |
1060 SkDEBUGCODE(geometry.fDevBounds = devRect;) | 1060 SkDEBUGCODE(geometry.fDevBounds = devRect;) |
1061 geometry.fDevClipBounds = devClipBounds; | 1061 geometry.fDevClipBounds = devClipBounds; |
1062 | 1062 |
1063 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuf
fer, | 1063 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuf
fer, |
1064 fQuadsIndexBuffer)); | 1064 fQuadsIndexBuffer)); |
1065 target->drawBatch(pipelineBuilder, batch, &devRect); | 1065 target->drawBatch(pipelineBuilder, batch, &devRect); |
1066 | 1066 |
1067 return true; | 1067 return true; |
1068 } | 1068 } |
OLD | NEW |