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 "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 (*vert)[1].fCoverage = coverage; | 677 (*vert)[1].fCoverage = coverage; |
678 (*vert)[2].fPos = a - vec + ortho; | 678 (*vert)[2].fPos = a - vec + ortho; |
679 (*vert)[2].fCoverage = 0; | 679 (*vert)[2].fCoverage = 0; |
680 (*vert)[3].fPos = b + vec + ortho; | 680 (*vert)[3].fPos = b + vec + ortho; |
681 (*vert)[3].fCoverage = 0; | 681 (*vert)[3].fCoverage = 0; |
682 (*vert)[4].fPos = a - vec - ortho; | 682 (*vert)[4].fPos = a - vec - ortho; |
683 (*vert)[4].fCoverage = 0; | 683 (*vert)[4].fCoverage = 0; |
684 (*vert)[5].fPos = b + vec - ortho; | 684 (*vert)[5].fPos = b + vec - ortho; |
685 (*vert)[5].fCoverage = 0; | 685 (*vert)[5].fCoverage = 0; |
686 | 686 |
687 if (NULL != toSrc) { | 687 if (toSrc) { |
688 toSrc->mapPointsWithStride(&(*vert)->fPos, | 688 toSrc->mapPointsWithStride(&(*vert)->fPos, |
689 sizeof(LineVertex), | 689 sizeof(LineVertex), |
690 kVertsPerLineSeg); | 690 kVertsPerLineSeg); |
691 } | 691 } |
692 } else { | 692 } else { |
693 // just make it degenerate and likely offscreen | 693 // just make it degenerate and likely offscreen |
694 for (int i = 0; i < kVertsPerLineSeg; ++i) { | 694 for (int i = 0; i < kVertsPerLineSeg; ++i) { |
695 (*vert)[i].fPos.set(SK_ScalarMax, SK_ScalarMax); | 695 (*vert)[i].fPos.set(SK_ScalarMax, SK_ScalarMax); |
696 } | 696 } |
697 } | 697 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 // Seed the dev bounds with some pts known to be inside. Each quad and conic
grows the bounding | 801 // Seed the dev bounds with some pts known to be inside. Each quad and conic
grows the bounding |
802 // box to include its vertices. | 802 // box to include its vertices. |
803 SkPoint seedPts[2]; | 803 SkPoint seedPts[2]; |
804 if (quadCnt) { | 804 if (quadCnt) { |
805 seedPts[0] = quads[0]; | 805 seedPts[0] = quads[0]; |
806 seedPts[1] = quads[2]; | 806 seedPts[1] = quads[2]; |
807 } else if (conicCnt) { | 807 } else if (conicCnt) { |
808 seedPts[0] = conics[0]; | 808 seedPts[0] = conics[0]; |
809 seedPts[1] = conics[2]; | 809 seedPts[1] = conics[2]; |
810 } | 810 } |
811 if (NULL != toDevice) { | 811 if (toDevice) { |
812 toDevice->mapPoints(seedPts, 2); | 812 toDevice->mapPoints(seedPts, 2); |
813 } | 813 } |
814 devBounds->set(seedPts[0], seedPts[1]); | 814 devBounds->set(seedPts[0], seedPts[1]); |
815 | 815 |
816 int unsubdivQuadCnt = quads.count() / 3; | 816 int unsubdivQuadCnt = quads.count() / 3; |
817 for (int i = 0; i < unsubdivQuadCnt; ++i) { | 817 for (int i = 0; i < unsubdivQuadCnt; ++i) { |
818 SkASSERT(qSubdivs[i] >= 0); | 818 SkASSERT(qSubdivs[i] >= 0); |
819 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts, devBounds); | 819 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts, devBounds); |
820 } | 820 } |
821 | 821 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 992 |
993 static const int kEdgeAttrIndex = 1; | 993 static const int kEdgeAttrIndex = 1; |
994 | 994 |
995 // Check devBounds | 995 // Check devBounds |
996 SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices()
, | 996 SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices()
, |
997 kVertsPerQuad * quadCnt + kVertsPerQ
uad * conicCnt)); | 997 kVertsPerQuad * quadCnt + kVertsPerQ
uad * conicCnt)); |
998 | 998 |
999 if (quadCnt > 0) { | 999 if (quadCnt > 0) { |
1000 GrEffect* hairQuadEffect = GrQuadEffect::Create(kHairlineAA_GrEffect
EdgeType, | 1000 GrEffect* hairQuadEffect = GrQuadEffect::Create(kHairlineAA_GrEffect
EdgeType, |
1001 *target->caps()); | 1001 *target->caps()); |
1002 SkASSERT(NULL != hairQuadEffect); | 1002 SkASSERT(hairQuadEffect); |
1003 GrDrawState::AutoRestoreEffects are(drawState); | 1003 GrDrawState::AutoRestoreEffects are(drawState); |
1004 target->setIndexSourceToBuffer(fQuadsIndexBuffer); | 1004 target->setIndexSourceToBuffer(fQuadsIndexBuffer); |
1005 drawState->setGeometryProcessor(hairQuadEffect, kEdgeAttrIndex)->unr
ef(); | 1005 drawState->setGeometryProcessor(hairQuadEffect, kEdgeAttrIndex)->unr
ef(); |
1006 int quads = 0; | 1006 int quads = 0; |
1007 while (quads < quadCnt) { | 1007 while (quads < quadCnt) { |
1008 int n = SkTMin(quadCnt - quads, kNumQuadsInIdxBuffer); | 1008 int n = SkTMin(quadCnt - quads, kNumQuadsInIdxBuffer); |
1009 target->drawIndexed(kTriangles_GrPrimitiveType, | 1009 target->drawIndexed(kTriangles_GrPrimitiveType, |
1010 kVertsPerQuad*quads, // startV | 1010 kVertsPerQuad*quads, // startV |
1011 0, // startI | 1011 0, // startI |
1012 kVertsPerQuad*n, // vCount | 1012 kVertsPerQuad*n, // vCount |
1013 kIdxsPerQuad*n, // iCount | 1013 kIdxsPerQuad*n, // iCount |
1014 &devBounds); | 1014 &devBounds); |
1015 quads += n; | 1015 quads += n; |
1016 } | 1016 } |
1017 } | 1017 } |
1018 | 1018 |
1019 if (conicCnt > 0) { | 1019 if (conicCnt > 0) { |
1020 GrDrawState::AutoRestoreEffects are(drawState); | 1020 GrDrawState::AutoRestoreEffects are(drawState); |
1021 GrEffect* hairConicEffect = GrConicEffect::Create(kHairlineAA_GrEffe
ctEdgeType, | 1021 GrEffect* hairConicEffect = GrConicEffect::Create(kHairlineAA_GrEffe
ctEdgeType, |
1022 *target->caps()); | 1022 *target->caps()); |
1023 SkASSERT(NULL != hairConicEffect); | 1023 SkASSERT(hairConicEffect); |
1024 drawState->setGeometryProcessor(hairConicEffect, 1, 2)->unref(); | 1024 drawState->setGeometryProcessor(hairConicEffect, 1, 2)->unref(); |
1025 int conics = 0; | 1025 int conics = 0; |
1026 while (conics < conicCnt) { | 1026 while (conics < conicCnt) { |
1027 int n = SkTMin(conicCnt - conics, kNumQuadsInIdxBuffer); | 1027 int n = SkTMin(conicCnt - conics, kNumQuadsInIdxBuffer); |
1028 target->drawIndexed(kTriangles_GrPrimitiveType, | 1028 target->drawIndexed(kTriangles_GrPrimitiveType, |
1029 kVertsPerQuad*(quadCnt + conics), // startV | 1029 kVertsPerQuad*(quadCnt + conics), // startV |
1030 0, // startI | 1030 0, // startI |
1031 kVertsPerQuad*n, // vCount | 1031 kVertsPerQuad*n, // vCount |
1032 kIdxsPerQuad*n, // iCount | 1032 kIdxsPerQuad*n, // iCount |
1033 &devBounds); | 1033 &devBounds); |
1034 conics += n; | 1034 conics += n; |
1035 } | 1035 } |
1036 } | 1036 } |
1037 } | 1037 } |
1038 | 1038 |
1039 target->resetIndexSource(); | 1039 target->resetIndexSource(); |
1040 | 1040 |
1041 return true; | 1041 return true; |
1042 } | 1042 } |
OLD | NEW |