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

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

Issue 822733003: Fix conics for gpu GrAAHairLinePathRender (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Comment fix Created 5 years, 12 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
« 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 27 matching lines...) Expand all
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,b0,c0,c1,a1
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 ((a0,a1,b0), (b0,c1,c0), (a1,c1,b0))
49 // specified by these 9 indices:
49 static const uint16_t kQuadIdxBufPattern[] = { 50 static const uint16_t kQuadIdxBufPattern[] = {
50 0, 1, 2, 51 0, 1, 2,
51 2, 4, 3, 52 2, 4, 3,
52 1, 4, 2 53 1, 4, 2
53 }; 54 };
54 55
55 static const int kIdxsPerQuad = SK_ARRAY_COUNT(kQuadIdxBufPattern); 56 static const int kIdxsPerQuad = SK_ARRAY_COUNT(kQuadIdxBufPattern);
56 static const int kQuadNumVertices = 5; 57 static const int kQuadNumVertices = 5;
57 static const int kQuadsNumInIdxBuffer = 256; 58 static const int kQuadsNumInIdxBuffer = 256;
58 59
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 kQuadNumVertices*quads, // sta rtV 937 kQuadNumVertices*quads, // sta rtV
937 0, // sta rtI 938 0, // sta rtI
938 kQuadNumVertices*n, // vCo unt 939 kQuadNumVertices*n, // vCo unt
939 kIdxsPerQuad*n, // iCo unt 940 kIdxsPerQuad*n, // iCo unt
940 &devBounds); 941 &devBounds);
941 quads += n; 942 quads += n;
942 } 943 }
943 } 944 }
944 945
945 if (conicCnt > 0) { 946 if (conicCnt > 0) {
946 GrDrawState::AutoRestoreEffects are(drawState);
947 SkAutoTUnref<GrGeometryProcessor> hairConicProcessor( 947 SkAutoTUnref<GrGeometryProcessor> hairConicProcessor(
948 GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType , *target->caps(), 948 GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType , *target->caps(),
949 newCoverage)); 949 newCoverage));
950 SkASSERT(hairConicProcessor); 950 SkASSERT(hairConicProcessor);
951 GrDrawState::AutoRestoreEffects are(drawState);
952 target->setIndexSourceToBuffer(fQuadsIndexBuffer);
951 953
952 int conics = 0; 954 int conics = 0;
953 while (conics < conicCnt) { 955 while (conics < conicCnt) {
954 int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer); 956 int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer);
955 target->drawIndexed(drawState, 957 target->drawIndexed(drawState,
956 hairConicProcessor, 958 hairConicProcessor,
957 kTriangles_GrPrimitiveType, 959 kTriangles_GrPrimitiveType,
958 kQuadNumVertices*(quadCnt + conics), // sta rtV 960 kQuadNumVertices*(quadCnt + conics), // sta rtV
959 0, // sta rtI 961 0, // sta rtI
960 kQuadNumVertices*n, // vCo unt 962 kQuadNumVertices*n, // vCo unt
961 kIdxsPerQuad*n, // iCo unt 963 kIdxsPerQuad*n, // iCo unt
962 &devBounds); 964 &devBounds);
963 conics += n; 965 conics += n;
964 } 966 }
965 } 967 }
966 } 968 }
967 969
968 target->resetIndexSource(); 970 target->resetIndexSource();
969 971
970 return true; 972 return true;
971 } 973 }
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