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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 665 } |
666 if (!first) { | 666 if (!first) { |
667 return tolDevBounds.contains(actualBounds); | 667 return tolDevBounds.contains(actualBounds); |
668 } | 668 } |
669 | 669 |
670 return true; | 670 return true; |
671 } | 671 } |
672 | 672 |
673 class AAHairlineBatch : public GrVertexBatch { | 673 class AAHairlineBatch : public GrVertexBatch { |
674 public: | 674 public: |
| 675 DEFINE_BATCH_CLASS_ID |
| 676 |
675 struct Geometry { | 677 struct Geometry { |
676 GrColor fColor; | 678 GrColor fColor; |
677 uint8_t fCoverage; | 679 uint8_t fCoverage; |
678 SkMatrix fViewMatrix; | 680 SkMatrix fViewMatrix; |
679 SkPath fPath; | 681 SkPath fPath; |
680 SkIRect fDevClipBounds; | 682 SkIRect fDevClipBounds; |
681 }; | 683 }; |
682 | 684 |
683 static GrDrawBatch* Create(const Geometry& geometry) { return new AAHairline
Batch(geometry); } | 685 static GrDrawBatch* Create(const Geometry& geometry) { return new AAHairline
Batch(geometry); } |
684 | 686 |
(...skipping 24 matching lines...) Expand all Loading... |
709 } | 711 } |
710 | 712 |
711 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 713 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
712 | 714 |
713 void onPrepareDraws(Target*) override; | 715 void onPrepareDraws(Target*) override; |
714 | 716 |
715 typedef SkTArray<SkPoint, true> PtArray; | 717 typedef SkTArray<SkPoint, true> PtArray; |
716 typedef SkTArray<int, true> IntArray; | 718 typedef SkTArray<int, true> IntArray; |
717 typedef SkTArray<float, true> FloatArray; | 719 typedef SkTArray<float, true> FloatArray; |
718 | 720 |
719 AAHairlineBatch(const Geometry& geometry) { | 721 AAHairlineBatch(const Geometry& geometry) : INHERITED(ClassID()) { |
720 this->initClassID<AAHairlineBatch>(); | |
721 fGeoData.push_back(geometry); | 722 fGeoData.push_back(geometry); |
722 | 723 |
723 // compute bounds | 724 // compute bounds |
724 fBounds = geometry.fPath.getBounds(); | 725 fBounds = geometry.fPath.getBounds(); |
725 geometry.fViewMatrix.mapRect(&fBounds); | 726 geometry.fViewMatrix.mapRect(&fBounds); |
726 | 727 |
727 // This is b.c. hairlines are notionally infinitely thin so without expa
nsion | 728 // This is b.c. hairlines are notionally infinitely thin so without expa
nsion |
728 // two overlapping lines could be reordered even though they hit the sam
e pixels. | 729 // two overlapping lines could be reordered even though they hit the sam
e pixels. |
729 fBounds.outset(0.5f, 0.5f); | 730 fBounds.outset(0.5f, 0.5f); |
730 } | 731 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 GrColor fColor; | 779 GrColor fColor; |
779 uint8_t fCoverage; | 780 uint8_t fCoverage; |
780 SkRect fDevBounds; | 781 SkRect fDevBounds; |
781 bool fUsesLocalCoords; | 782 bool fUsesLocalCoords; |
782 bool fColorIgnored; | 783 bool fColorIgnored; |
783 bool fCoverageIgnored; | 784 bool fCoverageIgnored; |
784 }; | 785 }; |
785 | 786 |
786 BatchTracker fBatch; | 787 BatchTracker fBatch; |
787 SkSTArray<1, Geometry, true> fGeoData; | 788 SkSTArray<1, Geometry, true> fGeoData; |
| 789 |
| 790 typedef GrVertexBatch INHERITED; |
788 }; | 791 }; |
789 | 792 |
790 void AAHairlineBatch::onPrepareDraws(Target* target) { | 793 void AAHairlineBatch::onPrepareDraws(Target* target) { |
791 // Setup the viewmatrix and localmatrix for the GrGeometryProcessor. | 794 // Setup the viewmatrix and localmatrix for the GrGeometryProcessor. |
792 SkMatrix invert; | 795 SkMatrix invert; |
793 if (!this->viewMatrix().invert(&invert)) { | 796 if (!this->viewMatrix().invert(&invert)) { |
794 return; | 797 return; |
795 } | 798 } |
796 | 799 |
797 // we will transform to identity space if the viewmatrix does not have persp
ective | 800 // we will transform to identity space if the viewmatrix does not have persp
ective |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 GrColor color = GrRandomColor(random); | 992 GrColor color = GrRandomColor(random); |
990 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 993 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 994 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
992 SkPath path = GrTest::TestPath(random); | 995 SkPath path = GrTest::TestPath(random); |
993 SkIRect devClipBounds; | 996 SkIRect devClipBounds; |
994 devClipBounds.setEmpty(); | 997 devClipBounds.setEmpty(); |
995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 998 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
996 } | 999 } |
997 | 1000 |
998 #endif | 1001 #endif |
OLD | NEW |