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

Unified Diff: src/gpu/gl/GrGLPath.cpp

Issue 694503003: Implement conics for NVPR (Closed) Base URL: https://skia.googlesource.com/skia.git@hairline-test-fix-unskip-nvpr
Patch Set: cleanup Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« include/core/SkPath.h ('K') | « src/gpu/gl/GrGLDefines.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLPath.cpp
diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp
index 6097f469db8f03048db93407af4458a185570772..e602b4fdbfca21c40168c5222f7388bc0e03218a 100644
--- a/src/gpu/gl/GrGLPath.cpp
+++ b/src/gpu/gl/GrGLPath.cpp
@@ -16,13 +16,14 @@ inline GrGLubyte verb_to_gl_path_cmd(SkPath::Verb verb) {
GR_GL_MOVE_TO,
GR_GL_LINE_TO,
GR_GL_QUADRATIC_CURVE_TO,
- 0xFF, // conic
+ GR_GL_CONIC_CURVE_TO,
GR_GL_CUBIC_CURVE_TO,
GR_GL_CLOSE_PATH,
};
GR_STATIC_ASSERT(0 == SkPath::kMove_Verb);
GR_STATIC_ASSERT(1 == SkPath::kLine_Verb);
GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb);
+ GR_STATIC_ASSERT(3 == SkPath::kConic_Verb);
GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb);
GR_STATIC_ASSERT(5 == SkPath::kClose_Verb);
@@ -30,7 +31,6 @@ inline GrGLubyte verb_to_gl_path_cmd(SkPath::Verb verb) {
return gTable[verb];
}
-#ifdef SK_DEBUG
inline int num_pts(SkPath::Verb verb) {
static const int gTable[] = {
1, // move
@@ -43,13 +43,13 @@ inline int num_pts(SkPath::Verb verb) {
GR_STATIC_ASSERT(0 == SkPath::kMove_Verb);
GR_STATIC_ASSERT(1 == SkPath::kLine_Verb);
GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb);
+ GR_STATIC_ASSERT(3 == SkPath::kConic_Verb);
GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb);
GR_STATIC_ASSERT(5 == SkPath::kClose_Verb);
SkASSERT(verb >= 0 && (size_t)verb < SK_ARRAY_COUNT(gTable));
return gTable[verb];
}
-#endif
inline GrGLenum join_to_gl_join(SkPaint::Join join) {
static GrGLenum gSkJoinsToGrGLJoins[] = {
@@ -87,28 +87,55 @@ void GrGLPath::InitPathObject(GrGpuGL* gpu,
const SkStrokeRec& stroke) {
if (!skPath.isEmpty()) {
SkSTArray<16, GrGLubyte, true> pathCommands;
- SkSTArray<16, SkPoint, true> pathPoints;
+ SkSTArray<16, GrGLfloat, true> pathCoords;
+ SK_COMPILE_ASSERT(sizeof(SkPoint) == 2 * sizeof(GrGLfloat), sk_point_not_two_floats);
int verbCnt = skPath.countVerbs();
int pointCnt = skPath.countPoints();
+ int conicWeightCnt = skPath.countConicWeights();
+ int coordCnt = 2 * pointCnt + conicWeightCnt;
+
pathCommands.resize_back(verbCnt);
- pathPoints.resize_back(pointCnt);
+ pathCoords.resize_back(coordCnt);
+
- // TODO: Direct access to path points since we could pass them on directly.
- skPath.getPoints(&pathPoints[0], pointCnt);
skPath.getVerbs(&pathCommands[0], verbCnt);
- SkDEBUGCODE(int numPts = 0);
- for (int i = 0; i < verbCnt; ++i) {
- SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
- pathCommands[i] = verb_to_gl_path_cmd(v);
- SkDEBUGCODE(numPts += num_pts(v));
+ // TODO: Direct access to path points since we could pass them on directly.
+ if (0 == conicWeightCnt) {
+ skPath.getPoints(reinterpret_cast<SkPoint*>(&pathCoords[0]), pointCnt);
+ SkDEBUGCODE(int numPts = 0);
+ for (int i = 0; i < verbCnt; ++i) {
+ SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
+ pathCommands[i] = verb_to_gl_path_cmd(v);
+ SkDEBUGCODE(numPts += num_pts(v));
+ }
+ SkASSERT(coordCnt == numPts * 2);
+ } else {
+ int pointIndex = 0;
+ int conicIndex = 0;
+ int coordIndex = 0;
+ for (int i = 0; i < verbCnt; ++i) {
+ SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
+ pathCommands[i] = verb_to_gl_path_cmd(v);
+ int pointsForVerb = num_pts(v);
+ while (pointsForVerb--) {
+ SkPoint p = skPath.getPoint(pointIndex++);
+ pathCoords[coordIndex++] = p.fX;
+ pathCoords[coordIndex++] = p.fY;
+ }
+ if (SkPath::kConic_Verb == v) {
+ pathCoords[coordIndex++] = skPath.getConicWeight(conicIndex++);
+ }
+ }
+ SkASSERT(pointCnt == pointIndex);
+ SkASSERT(conicWeightCnt == conicIndex);
+ SkASSERT(coordCnt == coordIndex);
}
- SkASSERT(pathPoints.count() == numPts);
GR_GL_CALL(gpu->glInterface(),
PathCommands(pathID, verbCnt, &pathCommands[0],
- 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
+ coordCnt, GR_GL_FLOAT, &pathCoords[0]));
} else {
GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, 0, NULL, 0, GR_GL_FLOAT, NULL));
}
« include/core/SkPath.h ('K') | « src/gpu/gl/GrGLDefines.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698