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)); |
} |