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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
830 quadCnt = generate_lines_and_quads(path, drawState->getViewMatrix(), devClip Bounds, | 830 quadCnt = generate_lines_and_quads(path, drawState->getViewMatrix(), devClip Bounds, |
831 &lines, &quads, &conics, &qSubdivs, &cWei ghts); | 831 &lines, &quads, &conics, &qSubdivs, &cWei ghts); |
832 lineCnt = lines.count() / 2; | 832 lineCnt = lines.count() / 2; |
833 conicCnt = conics.count() / 3; | 833 conicCnt = conics.count() / 3; |
834 | 834 |
835 // do lines first | 835 // do lines first |
836 if (lineCnt) { | 836 if (lineCnt) { |
837 GrDrawTarget::AutoReleaseGeometry arg; | 837 GrDrawTarget::AutoReleaseGeometry arg; |
838 SkRect devBounds; | 838 SkRect devBounds; |
839 | 839 |
840 // createLineGeom transforms the geometry to device space when the matri x does not have | |
841 // perspective. | |
842 GrDrawState::AutoViewMatrixRestore avmr; | |
843 SkMatrix invert = SkMatrix::I(); | |
844 if (!drawState->getViewMatrix().hasPerspective()) { | |
845 avmr.setIdentity(drawState); | |
846 if (!drawState->getViewMatrix().invert(&invert)) { | |
847 return false; | |
848 } | |
849 } | |
850 | |
851 GrDrawState::AutoRestoreEffects are(drawState); | |
840 uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType | | 852 uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType | |
841 GrDefaultGeoProcFactory::kCoverage_GPType; | 853 GrDefaultGeoProcFactory::kCoverage_GPType; |
842 GrDrawState::AutoRestoreEffects are(drawState); | |
843 SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Crea te(color, | 854 SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Crea te(color, |
844 gpFlags, | 855 gpFlags, |
845 false, | 856 false, |
846 newCoverage)); | 857 newCoverage, |
858 invert)); | |
847 | 859 |
848 if (!this->createLineGeom(target, | 860 if (!this->createLineGeom(target, |
849 drawState, | 861 drawState, |
850 newCoverage, | 862 newCoverage, |
851 gp->getVertexStride(), | 863 gp->getVertexStride(), |
852 &arg, | 864 &arg, |
853 &devBounds, | 865 &devBounds, |
854 path, | 866 path, |
855 lines, | 867 lines, |
856 lineCnt)) { | 868 lineCnt)) { |
857 return false; | 869 return false; |
858 } | 870 } |
859 | 871 |
860 // createLineGeom transforms the geometry to device space when the matri x does not have | |
861 // perspective. | |
862 GrDrawState::AutoViewMatrixRestore avmr; | |
863 if (!drawState->getViewMatrix().hasPerspective() && !avmr.setIdentity(dr awState)) { | |
864 return false; | |
865 } | |
866 | |
867 // Check devBounds | 872 // Check devBounds |
868 SkASSERT(check_bounds<LineVertex>(drawState, devBounds, arg.vertices(), | 873 SkASSERT(check_bounds<LineVertex>(drawState, devBounds, arg.vertices(), |
869 kLineSegNumVertices * lineCnt)); | 874 kLineSegNumVertices * lineCnt)); |
870 | 875 |
871 { | 876 { |
872 target->setIndexSourceToBuffer(fLinesIndexBuffer); | 877 target->setIndexSourceToBuffer(fLinesIndexBuffer); |
873 int lines = 0; | 878 int lines = 0; |
874 while (lines < lineCnt) { | 879 while (lines < lineCnt) { |
875 int n = SkTMin(lineCnt - lines, kLineSegsNumInIdxBuffer); | 880 int n = SkTMin(lineCnt - lines, kLineSegsNumInIdxBuffer); |
876 target->drawIndexed(drawState, | 881 target->drawIndexed(drawState, |
(...skipping 25 matching lines...) Expand all Loading... | |
902 conicCnt, | 907 conicCnt, |
903 qSubdivs, | 908 qSubdivs, |
904 cWeights, | 909 cWeights, |
905 sizeof(BezierVertex))) { | 910 sizeof(BezierVertex))) { |
906 return false; | 911 return false; |
907 } | 912 } |
908 | 913 |
909 // createGeom transforms the geometry to device space when the matrix do es not have | 914 // createGeom transforms the geometry to device space when the matrix do es not have |
910 // perspective. | 915 // perspective. |
911 GrDrawState::AutoViewMatrixRestore avmr; | 916 GrDrawState::AutoViewMatrixRestore avmr; |
912 if (!drawState->getViewMatrix().hasPerspective() && !avmr.setIdentity(dr awState)) { | 917 SkMatrix invert = SkMatrix::I(); |
bsalomon
2014/12/23 20:18:39
Why don't we just do this once outside the if (lin
| |
913 return false; | 918 if (!drawState->getViewMatrix().hasPerspective()) { |
919 avmr.setIdentity(drawState); | |
920 if (!drawState->getViewMatrix().invert(&invert)) { | |
921 return false; | |
922 } | |
914 } | 923 } |
915 | 924 |
916 | |
917 // Check devBounds | 925 // Check devBounds |
918 SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices() , | 926 SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices() , |
919 kQuadNumVertices * quadCnt + kQuadNu mVertices * conicCnt)); | 927 kQuadNumVertices * quadCnt + kQuadNu mVertices * conicCnt)); |
920 | 928 |
921 if (quadCnt > 0) { | 929 if (quadCnt > 0) { |
922 SkAutoTUnref<GrGeometryProcessor> hairQuadProcessor( | 930 SkAutoTUnref<GrGeometryProcessor> hairQuadProcessor( |
923 GrQuadEffect::Create(color, | 931 GrQuadEffect::Create(color, |
924 kHairlineAA_GrProcessorEdgeType, | 932 kHairlineAA_GrProcessorEdgeType, |
925 *target->caps(), | 933 *target->caps(), |
934 invert, | |
926 newCoverage)); | 935 newCoverage)); |
927 SkASSERT(hairQuadProcessor); | 936 SkASSERT(hairQuadProcessor); |
928 GrDrawState::AutoRestoreEffects are(drawState); | 937 GrDrawState::AutoRestoreEffects are(drawState); |
929 target->setIndexSourceToBuffer(fQuadsIndexBuffer); | 938 target->setIndexSourceToBuffer(fQuadsIndexBuffer); |
930 | 939 |
931 int quads = 0; | 940 int quads = 0; |
932 while (quads < quadCnt) { | 941 while (quads < quadCnt) { |
933 int n = SkTMin(quadCnt - quads, kQuadsNumInIdxBuffer); | 942 int n = SkTMin(quadCnt - quads, kQuadsNumInIdxBuffer); |
934 target->drawIndexed(drawState, | 943 target->drawIndexed(drawState, |
935 hairQuadProcessor, | 944 hairQuadProcessor, |
936 kTriangles_GrPrimitiveType, | 945 kTriangles_GrPrimitiveType, |
937 kQuadNumVertices*quads, // sta rtV | 946 kQuadNumVertices*quads, // sta rtV |
938 0, // sta rtI | 947 0, // sta rtI |
939 kQuadNumVertices*n, // vCo unt | 948 kQuadNumVertices*n, // vCo unt |
940 kIdxsPerQuad*n, // iCo unt | 949 kIdxsPerQuad*n, // iCo unt |
941 &devBounds); | 950 &devBounds); |
942 quads += n; | 951 quads += n; |
943 } | 952 } |
944 } | 953 } |
945 | 954 |
946 if (conicCnt > 0) { | 955 if (conicCnt > 0) { |
947 SkAutoTUnref<GrGeometryProcessor> hairConicProcessor( | 956 SkAutoTUnref<GrGeometryProcessor> hairConicProcessor( |
948 GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType , *target->caps(), | 957 GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType , *target->caps(), |
949 newCoverage)); | 958 invert, newCoverage)); |
950 SkASSERT(hairConicProcessor); | 959 SkASSERT(hairConicProcessor); |
951 GrDrawState::AutoRestoreEffects are(drawState); | 960 GrDrawState::AutoRestoreEffects are(drawState); |
952 target->setIndexSourceToBuffer(fQuadsIndexBuffer); | 961 target->setIndexSourceToBuffer(fQuadsIndexBuffer); |
953 | 962 |
954 int conics = 0; | 963 int conics = 0; |
955 while (conics < conicCnt) { | 964 while (conics < conicCnt) { |
956 int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer); | 965 int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer); |
957 target->drawIndexed(drawState, | 966 target->drawIndexed(drawState, |
958 hairConicProcessor, | 967 hairConicProcessor, |
959 kTriangles_GrPrimitiveType, | 968 kTriangles_GrPrimitiveType, |
960 kQuadNumVertices*(quadCnt + conics), // sta rtV | 969 kQuadNumVertices*(quadCnt + conics), // sta rtV |
961 0, // sta rtI | 970 0, // sta rtI |
962 kQuadNumVertices*n, // vCo unt | 971 kQuadNumVertices*n, // vCo unt |
963 kIdxsPerQuad*n, // iCo unt | 972 kIdxsPerQuad*n, // iCo unt |
964 &devBounds); | 973 &devBounds); |
965 conics += n; | 974 conics += n; |
966 } | 975 } |
967 } | 976 } |
968 } | 977 } |
969 | 978 |
970 target->resetIndexSource(); | 979 target->resetIndexSource(); |
971 | 980 |
972 return true; | 981 return true; |
973 } | 982 } |
OLD | NEW |