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 19 matching lines...) Expand all Loading... | |
30 // |\ -_______ /| | 30 // |\ -_______ /| |
31 // | \ \ / | | 31 // | \ \ / | |
32 // | *--------* | | 32 // | *--------* | |
33 // | / ______/ \ | | 33 // | / ______/ \ | |
34 // */_-__________\* | 34 // */_-__________\* |
35 // For: 6 vertices and 18 indices (for 6 triangles) | 35 // For: 6 vertices and 18 indices (for 6 triangles) |
36 | 36 |
37 // Each quadratic is rendered as a five sided polygon. This poly bounds | 37 // Each quadratic is rendered as a five sided polygon. This poly bounds |
38 // the quadratic's bounding triangle but has been expanded so that the | 38 // the quadratic's bounding triangle but has been expanded so that the |
39 // 1-pixel wide area around the curve is inside the poly. | 39 // 1-pixel wide area around the curve is inside the poly. |
40 // If a,b,c are the original control points then the poly a0,b0,c0,c1,a1 | 40 // If a,b,c are the original control points then the poly a0,a1,b0,c0,c1 |
bsalomon
2014/12/22 16:40:46
really? a1 connects to b0? otherwise, lgtm
egdaniel
2014/12/22 16:52:17
yeah we draw the two "skinny" triangles on the sid
bsalomon
2014/12/22 17:04:46
ok, i think the comment is describing the bounding
| |
41 // that is rendered would look like this: | 41 // that is rendered would look like this: |
42 // b0 | 42 // b0 |
43 // b | 43 // b |
44 // | 44 // |
45 // a0 c0 | 45 // a0 c0 |
46 // a c | 46 // a c |
47 // a1 c1 | 47 // a1 c1 |
48 // Each is drawn as three triangles specified by these 9 indices: | 48 // Each is drawn as three triangles specified by these 9 indices: |
49 static const uint16_t kQuadIdxBufPattern[] = { | 49 static const uint16_t kQuadIdxBufPattern[] = { |
50 0, 1, 2, | 50 0, 1, 2, |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 kQuadNumVertices*quads, // sta rtV | 936 kQuadNumVertices*quads, // sta rtV |
937 0, // sta rtI | 937 0, // sta rtI |
938 kQuadNumVertices*n, // vCo unt | 938 kQuadNumVertices*n, // vCo unt |
939 kIdxsPerQuad*n, // iCo unt | 939 kIdxsPerQuad*n, // iCo unt |
940 &devBounds); | 940 &devBounds); |
941 quads += n; | 941 quads += n; |
942 } | 942 } |
943 } | 943 } |
944 | 944 |
945 if (conicCnt > 0) { | 945 if (conicCnt > 0) { |
946 GrDrawState::AutoRestoreEffects are(drawState); | |
947 SkAutoTUnref<GrGeometryProcessor> hairConicProcessor( | 946 SkAutoTUnref<GrGeometryProcessor> hairConicProcessor( |
948 GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType , *target->caps(), | 947 GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType , *target->caps(), |
949 newCoverage)); | 948 newCoverage)); |
950 SkASSERT(hairConicProcessor); | 949 SkASSERT(hairConicProcessor); |
950 GrDrawState::AutoRestoreEffects are(drawState); | |
951 target->setIndexSourceToBuffer(fQuadsIndexBuffer); | |
951 | 952 |
952 int conics = 0; | 953 int conics = 0; |
953 while (conics < conicCnt) { | 954 while (conics < conicCnt) { |
954 int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer); | 955 int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer); |
955 target->drawIndexed(drawState, | 956 target->drawIndexed(drawState, |
956 hairConicProcessor, | 957 hairConicProcessor, |
957 kTriangles_GrPrimitiveType, | 958 kTriangles_GrPrimitiveType, |
958 kQuadNumVertices*(quadCnt + conics), // sta rtV | 959 kQuadNumVertices*(quadCnt + conics), // sta rtV |
959 0, // sta rtI | 960 0, // sta rtI |
960 kQuadNumVertices*n, // vCo unt | 961 kQuadNumVertices*n, // vCo unt |
961 kIdxsPerQuad*n, // iCo unt | 962 kIdxsPerQuad*n, // iCo unt |
962 &devBounds); | 963 &devBounds); |
963 conics += n; | 964 conics += n; |
964 } | 965 } |
965 } | 966 } |
966 } | 967 } |
967 | 968 |
968 target->resetIndexSource(); | 969 target->resetIndexSource(); |
969 | 970 |
970 return true; | 971 return true; |
971 } | 972 } |
OLD | NEW |