Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: src/gpu/GrAAHairLinePathRenderer.cpp

Issue 22891023: Only assert that conic/quad effects get created if they are to be used. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 // perspective. 949 // perspective.
950 if (target->getDrawState().getViewMatrix().hasPerspective()) { 950 if (target->getDrawState().getViewMatrix().hasPerspective()) {
951 asr.set(target, GrDrawTarget::kPreserve_ASRInit); 951 asr.set(target, GrDrawTarget::kPreserve_ASRInit);
952 } else if (!asr.setIdentity(target, GrDrawTarget::kPreserve_ASRInit)) { 952 } else if (!asr.setIdentity(target, GrDrawTarget::kPreserve_ASRInit)) {
953 return false; 953 return false;
954 } 954 }
955 GrDrawState* drawState = target->drawState(); 955 GrDrawState* drawState = target->drawState();
956 956
957 static const int kEdgeAttrIndex = 1; 957 static const int kEdgeAttrIndex = 1;
958 958
959 GrEffectRef* hairQuadEffect = GrQuadEffect::Create(kHairAA_GrBezierEdgeT ype,
960 *target->caps());
961 GrEffectRef* hairConicEffect = GrConicEffect::Create(kHairAA_GrBezierEdg eType,
962 *target->caps());
963 SkASSERT(hairQuadEffect && hairConicEffect);
964
965 // Check devBounds 959 // Check devBounds
966 SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices() , 960 SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices() ,
967 kVertsPerQuad * quadCnt + kVertsPerQ uad * conicCnt)); 961 kVertsPerQuad * quadCnt + kVertsPerQ uad * conicCnt));
968 962
969 { 963 if (quadCnt > 0) {
964 GrEffectRef* hairQuadEffect = GrQuadEffect::Create(kHairAA_GrBezierE dgeType,
965 *target->caps());
966 SkASSERT(NULL != hairQuadEffect);
970 GrDrawState::AutoRestoreEffects are(drawState); 967 GrDrawState::AutoRestoreEffects are(drawState);
971 target->setIndexSourceToBuffer(fQuadsIndexBuffer); 968 target->setIndexSourceToBuffer(fQuadsIndexBuffer);
969 drawState->addCoverageEffect(hairQuadEffect, kEdgeAttrIndex)->unref( );
972 int quads = 0; 970 int quads = 0;
973 drawState->addCoverageEffect(hairQuadEffect, kEdgeAttrIndex)->unref( );
974 while (quads < quadCnt) { 971 while (quads < quadCnt) {
975 int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer); 972 int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer);
976 target->drawIndexed(kTriangles_GrPrimitiveType, 973 target->drawIndexed(kTriangles_GrPrimitiveType,
977 kVertsPerQuad*quads, // startV 974 kVertsPerQuad*quads, // startV
978 0, // startI 975 0, // startI
979 kVertsPerQuad*n, // vCount 976 kVertsPerQuad*n, // vCount
980 kIdxsPerQuad*n, // iCount 977 kIdxsPerQuad*n, // iCount
981 &devBounds); 978 &devBounds);
982 quads += n; 979 quads += n;
983 } 980 }
984 } 981 }
985 982
986 { 983 if (conicCnt > 0) {
987 GrDrawState::AutoRestoreEffects are(drawState); 984 GrDrawState::AutoRestoreEffects are(drawState);
985 GrEffectRef* hairConicEffect = GrConicEffect::Create(kHairAA_GrBezie rEdgeType,
986 *target->caps() );
987 SkASSERT(NULL != hairConicEffect);
988 drawState->addCoverageEffect(hairConicEffect, 1, 2)->unref();
988 int conics = 0; 989 int conics = 0;
989 drawState->addCoverageEffect(hairConicEffect, 1, 2)->unref();
990 while (conics < conicCnt) { 990 while (conics < conicCnt) {
991 int n = GrMin(conicCnt - conics, kNumQuadsInIdxBuffer); 991 int n = GrMin(conicCnt - conics, kNumQuadsInIdxBuffer);
992 target->drawIndexed(kTriangles_GrPrimitiveType, 992 target->drawIndexed(kTriangles_GrPrimitiveType,
993 kVertsPerQuad*(quadCnt + conics), // startV 993 kVertsPerQuad*(quadCnt + conics), // startV
994 0, // startI 994 0, // startI
995 kVertsPerQuad*n, // vCount 995 kVertsPerQuad*n, // vCount
996 kIdxsPerQuad*n, // iCount 996 kIdxsPerQuad*n, // iCount
997 &devBounds); 997 &devBounds);
998 conics += n; 998 conics += n;
999 } 999 }
1000 } 1000 }
1001 } 1001 }
1002 1002
1003 target->resetIndexSource(); 1003 target->resetIndexSource();
1004 1004
1005 return true; 1005 return true;
1006 } 1006 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698