| 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 701 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 702 | 702 |
| 703 // setup batch properties | 703 // setup batch properties |
| 704 fBatch.fColorIgnored = !init.readsColor(); | 704 fBatch.fColorIgnored = !init.readsColor(); |
| 705 fBatch.fColor = fGeoData[0].fColor; | 705 fBatch.fColor = fGeoData[0].fColor; |
| 706 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 706 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
| 707 fBatch.fCoverageIgnored = !init.readsCoverage(); | 707 fBatch.fCoverageIgnored = !init.readsCoverage(); |
| 708 fBatch.fCoverage = fGeoData[0].fCoverage; | 708 fBatch.fCoverage = fGeoData[0].fCoverage; |
| 709 } | 709 } |
| 710 | 710 |
| 711 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override; | 711 void generateGeometry(GrBatchTarget* batchTarget) override; |
| 712 | 712 |
| 713 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 713 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 714 | 714 |
| 715 private: | 715 private: |
| 716 typedef SkTArray<SkPoint, true> PtArray; | 716 typedef SkTArray<SkPoint, true> PtArray; |
| 717 typedef SkTArray<int, true> IntArray; | 717 typedef SkTArray<int, true> IntArray; |
| 718 typedef SkTArray<float, true> FloatArray; | 718 typedef SkTArray<float, true> FloatArray; |
| 719 | 719 |
| 720 AAHairlineBatch(const Geometry& geometry) { | 720 AAHairlineBatch(const Geometry& geometry) { |
| 721 this->initClassID<AAHairlineBatch>(); | 721 this->initClassID<AAHairlineBatch>(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 SkRect fDevBounds; | 780 SkRect fDevBounds; |
| 781 bool fUsesLocalCoords; | 781 bool fUsesLocalCoords; |
| 782 bool fColorIgnored; | 782 bool fColorIgnored; |
| 783 bool fCoverageIgnored; | 783 bool fCoverageIgnored; |
| 784 }; | 784 }; |
| 785 | 785 |
| 786 BatchTracker fBatch; | 786 BatchTracker fBatch; |
| 787 SkSTArray<1, Geometry, true> fGeoData; | 787 SkSTArray<1, Geometry, true> fGeoData; |
| 788 }; | 788 }; |
| 789 | 789 |
| 790 void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
ine* pipeline) { | 790 void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget) { |
| 791 // Setup the viewmatrix and localmatrix for the GrGeometryProcessor. | 791 // Setup the viewmatrix and localmatrix for the GrGeometryProcessor. |
| 792 SkMatrix invert; | 792 SkMatrix invert; |
| 793 if (!this->viewMatrix().invert(&invert)) { | 793 if (!this->viewMatrix().invert(&invert)) { |
| 794 return; | 794 return; |
| 795 } | 795 } |
| 796 | 796 |
| 797 // we will transform to identity space if the viewmatrix does not have persp
ective | 797 // we will transform to identity space if the viewmatrix does not have persp
ective |
| 798 bool hasPerspective = this->viewMatrix().hasPerspective(); | 798 bool hasPerspective = this->viewMatrix().hasPerspective(); |
| 799 const SkMatrix* geometryProcessorViewM = &SkMatrix::I(); | 799 const SkMatrix* geometryProcessorViewM = &SkMatrix::I(); |
| 800 const SkMatrix* geometryProcessorLocalM = &invert; | 800 const SkMatrix* geometryProcessorLocalM = &invert; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 &lines, &quads, &conics, &qSubdivs,
&cWeights); | 853 &lines, &quads, &conics, &qSubdivs,
&cWeights); |
| 854 } | 854 } |
| 855 | 855 |
| 856 int lineCount = lines.count() / 2; | 856 int lineCount = lines.count() / 2; |
| 857 int conicCount = conics.count() / 3; | 857 int conicCount = conics.count() / 3; |
| 858 | 858 |
| 859 // do lines first | 859 // do lines first |
| 860 if (lineCount) { | 860 if (lineCount) { |
| 861 SkAutoTUnref<const GrIndexBuffer> linesIndexBuffer( | 861 SkAutoTUnref<const GrIndexBuffer> linesIndexBuffer( |
| 862 ref_lines_index_buffer(batchTarget->resourceProvider())); | 862 ref_lines_index_buffer(batchTarget->resourceProvider())); |
| 863 batchTarget->initDraw(lineGP, pipeline); | 863 batchTarget->initDraw(lineGP, this->pipeline()); |
| 864 | 864 |
| 865 const GrVertexBuffer* vertexBuffer; | 865 const GrVertexBuffer* vertexBuffer; |
| 866 int firstVertex; | 866 int firstVertex; |
| 867 | 867 |
| 868 size_t vertexStride = lineGP->getVertexStride(); | 868 size_t vertexStride = lineGP->getVertexStride(); |
| 869 int vertexCount = kLineSegNumVertices * lineCount; | 869 int vertexCount = kLineSegNumVertices * lineCount; |
| 870 LineVertex* verts = reinterpret_cast<LineVertex*>( | 870 LineVertex* verts = reinterpret_cast<LineVertex*>( |
| 871 batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer,
&firstVertex)); | 871 batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer,
&firstVertex)); |
| 872 | 872 |
| 873 if (!verts|| !linesIndexBuffer) { | 873 if (!verts|| !linesIndexBuffer) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 SkASSERT(qSubdivs[i] >= 0); | 915 SkASSERT(qSubdivs[i] >= 0); |
| 916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts); | 916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts); |
| 917 } | 917 } |
| 918 | 918 |
| 919 // Start Conics | 919 // Start Conics |
| 920 for (int i = 0; i < conicCount; ++i) { | 920 for (int i = 0; i < conicCount; ++i) { |
| 921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts); | 921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts); |
| 922 } | 922 } |
| 923 | 923 |
| 924 if (quadCount > 0) { | 924 if (quadCount > 0) { |
| 925 batchTarget->initDraw(quadGP, pipeline); | 925 batchTarget->initDraw(quadGP, this->pipeline()); |
| 926 | 926 |
| 927 { | 927 { |
| 928 GrVertices verts; | 928 GrVertices verts; |
| 929 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, | 929 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, |
| 930 firstVertex, kQuadNumVertices, kIdxsPerQuad,
quadCount, | 930 firstVertex, kQuadNumVertices, kIdxsPerQuad,
quadCount, |
| 931 kQuadsNumInIdxBuffer); | 931 kQuadsNumInIdxBuffer); |
| 932 batchTarget->draw(verts); | 932 batchTarget->draw(verts); |
| 933 firstVertex += quadCount * kQuadNumVertices; | 933 firstVertex += quadCount * kQuadNumVertices; |
| 934 } | 934 } |
| 935 } | 935 } |
| 936 | 936 |
| 937 if (conicCount > 0) { | 937 if (conicCount > 0) { |
| 938 batchTarget->initDraw(conicGP, pipeline); | 938 batchTarget->initDraw(conicGP, this->pipeline()); |
| 939 | 939 |
| 940 { | 940 { |
| 941 GrVertices verts; | 941 GrVertices verts; |
| 942 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, | 942 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, |
| 943 firstVertex, kQuadNumVertices, kIdxsPerQuad,
conicCount, | 943 firstVertex, kQuadNumVertices, kIdxsPerQuad,
conicCount, |
| 944 kQuadsNumInIdxBuffer); | 944 kQuadsNumInIdxBuffer); |
| 945 batchTarget->draw(verts); | 945 batchTarget->draw(verts); |
| 946 } | 946 } |
| 947 } | 947 } |
| 948 } | 948 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 GrColor color = GrRandomColor(random); | 989 GrColor color = GrRandomColor(random); |
| 990 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 990 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
| 991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
| 992 SkPath path = GrTest::TestPath(random); | 992 SkPath path = GrTest::TestPath(random); |
| 993 SkIRect devClipBounds; | 993 SkIRect devClipBounds; |
| 994 devClipBounds.setEmpty(); | 994 devClipBounds.setEmpty(); |
| 995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
| 996 } | 996 } |
| 997 | 997 |
| 998 #endif | 998 #endif |
| OLD | NEW |