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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 } | 990 } |
991 GrDrawState* drawState = target->drawState(); | 991 GrDrawState* drawState = target->drawState(); |
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 GrEffectRef* hairQuadEffect = GrQuadEffect::Create(kHairAA_GrBezierE
dgeType, | 1000 GrEffectRef* hairQuadEffect = GrQuadEffect::Create(kHairlineAA_GrEff
ectEdgeType, |
1001 *target->caps()); | 1001 *target->caps()); |
1002 SkASSERT(NULL != hairQuadEffect); | 1002 SkASSERT(NULL != hairQuadEffect); |
1003 GrDrawState::AutoRestoreEffects are(drawState); | 1003 GrDrawState::AutoRestoreEffects are(drawState); |
1004 target->setIndexSourceToBuffer(fQuadsIndexBuffer); | 1004 target->setIndexSourceToBuffer(fQuadsIndexBuffer); |
1005 drawState->addCoverageEffect(hairQuadEffect, kEdgeAttrIndex)->unref(
); | 1005 drawState->addCoverageEffect(hairQuadEffect, kEdgeAttrIndex)->unref(
); |
1006 int quads = 0; | 1006 int quads = 0; |
1007 while (quads < quadCnt) { | 1007 while (quads < quadCnt) { |
1008 int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer); | 1008 int n = GrMin(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 GrEffectRef* hairConicEffect = GrConicEffect::Create(kHairAA_GrBezie
rEdgeType, | 1021 GrEffectRef* hairConicEffect = GrConicEffect::Create(kHairlineAA_GrE
ffectEdgeType, |
1022 *target->caps()
); | 1022 *target->caps()
); |
1023 SkASSERT(NULL != hairConicEffect); | 1023 SkASSERT(NULL != hairConicEffect); |
1024 drawState->addCoverageEffect(hairConicEffect, 1, 2)->unref(); | 1024 drawState->addCoverageEffect(hairConicEffect, 1, 2)->unref(); |
1025 int conics = 0; | 1025 int conics = 0; |
1026 while (conics < conicCnt) { | 1026 while (conics < conicCnt) { |
1027 int n = GrMin(conicCnt - conics, kNumQuadsInIdxBuffer); | 1027 int n = GrMin(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 |