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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 | 767 |
768 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 768 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
769 this->joinBounds(that->bounds()); | 769 this->joinBounds(that->bounds()); |
770 return true; | 770 return true; |
771 } | 771 } |
772 | 772 |
773 GrColor color() const { return fBatch.fColor; } | 773 GrColor color() const { return fBatch.fColor; } |
774 uint8_t coverage() const { return fBatch.fCoverage; } | 774 uint8_t coverage() const { return fBatch.fCoverage; } |
775 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 775 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
776 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 776 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 777 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
777 | 778 |
778 struct BatchTracker { | 779 struct BatchTracker { |
779 GrColor fColor; | 780 GrColor fColor; |
780 uint8_t fCoverage; | 781 uint8_t fCoverage; |
781 SkRect fDevBounds; | 782 SkRect fDevBounds; |
782 bool fUsesLocalCoords; | 783 bool fUsesLocalCoords; |
783 bool fColorIgnored; | 784 bool fColorIgnored; |
784 bool fCoverageIgnored; | 785 bool fCoverageIgnored; |
785 }; | 786 }; |
786 | 787 |
(...skipping 21 matching lines...) Expand all Loading... |
808 toSrc = &invert; | 809 toSrc = &invert; |
809 } | 810 } |
810 | 811 |
811 // Setup geometry processors for worst case | 812 // Setup geometry processors for worst case |
812 uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType | | 813 uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType | |
813 GrDefaultGeoProcFactory::kCoverage_GPType; | 814 GrDefaultGeoProcFactory::kCoverage_GPType; |
814 | 815 |
815 SkAutoTUnref<const GrGeometryProcessor> lineGP( | 816 SkAutoTUnref<const GrGeometryProcessor> lineGP( |
816 GrDefaultGeoProcFactory::Create(gpFlags, | 817 GrDefaultGeoProcFactory::Create(gpFlags, |
817 this->color(), | 818 this->color(), |
| 819 this->usesLocalCoords(), |
| 820 this->coverageIgnored(), |
818 *geometryProcessorViewM, | 821 *geometryProcessorViewM, |
819 *geometryProcessorLocalM, | 822 *geometryProcessorLocalM, |
820 this->coverage())); | 823 this->coverage())); |
821 | 824 |
822 SkAutoTUnref<const GrGeometryProcessor> quadGP( | 825 SkAutoTUnref<const GrGeometryProcessor> quadGP( |
823 GrQuadEffect::Create(this->color(), | 826 GrQuadEffect::Create(this->color(), |
824 *geometryProcessorViewM, | 827 *geometryProcessorViewM, |
825 kHairlineAA_GrProcessorEdgeType, | 828 kHairlineAA_GrProcessorEdgeType, |
826 batchTarget->caps(), | 829 batchTarget->caps(), |
827 *geometryProcessorLocalM, | 830 *geometryProcessorLocalM, |
| 831 this->usesLocalCoords(), |
828 this->coverage())); | 832 this->coverage())); |
829 | 833 |
830 SkAutoTUnref<const GrGeometryProcessor> conicGP( | 834 SkAutoTUnref<const GrGeometryProcessor> conicGP( |
831 GrConicEffect::Create(this->color(), | 835 GrConicEffect::Create(this->color(), |
832 *geometryProcessorViewM, | 836 *geometryProcessorViewM, |
833 kHairlineAA_GrProcessorEdgeType, | 837 kHairlineAA_GrProcessorEdgeType, |
834 batchTarget->caps(), | 838 batchTarget->caps(), |
835 *geometryProcessorLocalM, | 839 *geometryProcessorLocalM, |
| 840 this->usesLocalCoords(), |
836 this->coverage())); | 841 this->coverage())); |
837 | 842 |
838 // This is hand inlined for maximum performance. | 843 // This is hand inlined for maximum performance. |
839 PREALLOC_PTARRAY(128) lines; | 844 PREALLOC_PTARRAY(128) lines; |
840 PREALLOC_PTARRAY(128) quads; | 845 PREALLOC_PTARRAY(128) quads; |
841 PREALLOC_PTARRAY(128) conics; | 846 PREALLOC_PTARRAY(128) conics; |
842 IntArray qSubdivs; | 847 IntArray qSubdivs; |
843 FloatArray cWeights; | 848 FloatArray cWeights; |
844 int quadCount = 0; | 849 int quadCount = 0; |
845 | 850 |
846 int instanceCount = fGeoData.count(); | 851 int instanceCount = fGeoData.count(); |
847 for (int i = 0; i < instanceCount; i++) { | 852 for (int i = 0; i < instanceCount; i++) { |
848 const Geometry& args = fGeoData[i]; | 853 const Geometry& args = fGeoData[i]; |
849 quadCount += gather_lines_and_quads(args.fPath, args.fViewMatrix, args.f
DevClipBounds, | 854 quadCount += gather_lines_and_quads(args.fPath, args.fViewMatrix, args.f
DevClipBounds, |
850 &lines, &quads, &conics, &qSubdivs,
&cWeights); | 855 &lines, &quads, &conics, &qSubdivs,
&cWeights); |
851 } | 856 } |
852 | 857 |
853 int lineCount = lines.count() / 2; | 858 int lineCount = lines.count() / 2; |
854 int conicCount = conics.count() / 3; | 859 int conicCount = conics.count() / 3; |
855 | 860 |
856 // do lines first | 861 // do lines first |
857 if (lineCount) { | 862 if (lineCount) { |
858 SkAutoTUnref<const GrIndexBuffer> linesIndexBuffer( | 863 SkAutoTUnref<const GrIndexBuffer> linesIndexBuffer( |
859 ref_lines_index_buffer(batchTarget->resourceProvider())); | 864 ref_lines_index_buffer(batchTarget->resourceProvider())); |
860 batchTarget->initDraw(lineGP, pipeline); | 865 batchTarget->initDraw(lineGP, pipeline); |
861 | 866 |
862 // TODO remove this when batch is everywhere | |
863 GrPipelineInfo init; | |
864 init.fColorIgnored = fBatch.fColorIgnored; | |
865 init.fOverrideColor = GrColor_ILLEGAL; | |
866 init.fCoverageIgnored = fBatch.fCoverageIgnored; | |
867 init.fUsesLocalCoords = this->usesLocalCoords(); | |
868 lineGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | |
869 | |
870 const GrVertexBuffer* vertexBuffer; | 867 const GrVertexBuffer* vertexBuffer; |
871 int firstVertex; | 868 int firstVertex; |
872 | 869 |
873 size_t vertexStride = lineGP->getVertexStride(); | 870 size_t vertexStride = lineGP->getVertexStride(); |
874 int vertexCount = kLineSegNumVertices * lineCount; | 871 int vertexCount = kLineSegNumVertices * lineCount; |
875 LineVertex* verts = reinterpret_cast<LineVertex*>( | 872 LineVertex* verts = reinterpret_cast<LineVertex*>( |
876 batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer,
&firstVertex)); | 873 batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer,
&firstVertex)); |
877 | 874 |
878 if (!verts|| !linesIndexBuffer) { | 875 if (!verts|| !linesIndexBuffer) { |
879 SkDebugf("Could not allocate vertices\n"); | 876 SkDebugf("Could not allocate vertices\n"); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 } | 919 } |
923 | 920 |
924 // Start Conics | 921 // Start Conics |
925 for (int i = 0; i < conicCount; ++i) { | 922 for (int i = 0; i < conicCount; ++i) { |
926 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts); | 923 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts); |
927 } | 924 } |
928 | 925 |
929 if (quadCount > 0) { | 926 if (quadCount > 0) { |
930 batchTarget->initDraw(quadGP, pipeline); | 927 batchTarget->initDraw(quadGP, pipeline); |
931 | 928 |
932 // TODO remove this when batch is everywhere | |
933 GrPipelineInfo init; | |
934 init.fColorIgnored = fBatch.fColorIgnored; | |
935 init.fOverrideColor = GrColor_ILLEGAL; | |
936 init.fCoverageIgnored = fBatch.fCoverageIgnored; | |
937 init.fUsesLocalCoords = this->usesLocalCoords(); | |
938 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | |
939 | |
940 { | 929 { |
941 GrVertices verts; | 930 GrVertices verts; |
942 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, | 931 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, |
943 firstVertex, kQuadNumVertices, kIdxsPerQuad,
quadCount, | 932 firstVertex, kQuadNumVertices, kIdxsPerQuad,
quadCount, |
944 kQuadsNumInIdxBuffer); | 933 kQuadsNumInIdxBuffer); |
945 batchTarget->draw(verts); | 934 batchTarget->draw(verts); |
946 firstVertex += quadCount * kQuadNumVertices; | 935 firstVertex += quadCount * kQuadNumVertices; |
947 } | 936 } |
948 } | 937 } |
949 | 938 |
950 if (conicCount > 0) { | 939 if (conicCount > 0) { |
951 batchTarget->initDraw(conicGP, pipeline); | 940 batchTarget->initDraw(conicGP, pipeline); |
952 | 941 |
953 // TODO remove this when batch is everywhere | |
954 GrPipelineInfo init; | |
955 init.fColorIgnored = fBatch.fColorIgnored; | |
956 init.fOverrideColor = GrColor_ILLEGAL; | |
957 init.fCoverageIgnored = fBatch.fCoverageIgnored; | |
958 init.fUsesLocalCoords = this->usesLocalCoords(); | |
959 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | |
960 | |
961 { | 942 { |
962 GrVertices verts; | 943 GrVertices verts; |
963 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, | 944 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, |
964 firstVertex, kQuadNumVertices, kIdxsPerQuad,
conicCount, | 945 firstVertex, kQuadNumVertices, kIdxsPerQuad,
conicCount, |
965 kQuadsNumInIdxBuffer); | 946 kQuadsNumInIdxBuffer); |
966 batchTarget->draw(verts); | 947 batchTarget->draw(verts); |
967 } | 948 } |
968 } | 949 } |
969 } | 950 } |
970 } | 951 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 GrColor color = GrRandomColor(random); | 997 GrColor color = GrRandomColor(random); |
1017 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 998 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
1018 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 999 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
1019 SkPath path = GrTest::TestPath(random); | 1000 SkPath path = GrTest::TestPath(random); |
1020 SkIRect devClipBounds; | 1001 SkIRect devClipBounds; |
1021 devClipBounds.setEmpty(); | 1002 devClipBounds.setEmpty(); |
1022 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 1003 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
1023 } | 1004 } |
1024 | 1005 |
1025 #endif | 1006 #endif |
OLD | NEW |