GrGLuint pathID,
const SkPath& skPath,
const SkStrokeRec& stroke) {
- GrGLPathRendering* pr = gpu->pathRendering();
- SkSTArray<16, GrGLubyte, true> pathCommands;
- SkSTArray<16, SkPoint, true> pathPoints;
-
- int verbCnt = skPath.countVerbs();
- int pointCnt = skPath.countPoints();
- pathCommands.resize_back(verbCnt);
- pathPoints.resize_back(pointCnt);
-
- // 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));
+ if (!skPath.isEmpty()) {
+ SkSTArray<16, GrGLubyte, true> pathCommands;
+ SkSTArray<16, SkPoint, true> pathPoints;
+
+ int verbCnt = skPath.countVerbs();
+ int pointCnt = skPath.countPoints();
+ pathCommands.resize_back(verbCnt);
+ pathPoints.resize_back(pointCnt);
+
+ // 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));
+ }
+ SkASSERT(pathPoints.count() == numPts);
+
+ GR_GL_CALL(gpu->glInterface(),
+ PathCommands(pathID, verbCnt, &pathCommands[0],
+ 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
+ } else {
+ GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, 0, NULL, 0, GR_GL_FLOAT, NULL));
}
- SkASSERT(pathPoints.count() == numPts);
- pr->pathCommands(pathID, verbCnt, &pathCommands[0], 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]);
if (stroke.needToApply()) {
SkASSERT(!stroke.isHairlineStyle());
- pr->pathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stroke.getWidth()));
- pr->pathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(stroke.getMiter()));
+ GR_GL_CALL(gpu->glInterface(),
+ PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stroke.getWidth())));
+ GR_GL_CALL(gpu->glInterface(),
+ PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(stroke.getMiter())));
GrGLenum join = join_to_gl_join(stroke.getJoin());
- pr->pathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join);
+ GR_GL_CALL(gpu->glInterface(),
+ PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
GrGLenum cap = cap_to_gl_cap(stroke.getCap());
- pr->pathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap);
- pr->pathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap);
+ GR_GL_CALL(gpu->glInterface(),
+ PathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap));
+ GR_GL_CALL(gpu->glInterface(),
+ PathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap));
}
}
GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
: INHERITED(gpu, kIsWrapped, path, stroke),
- fPathID(gpu->pathRendering()->genPaths(1)) {
- SkASSERT(!path.isEmpty());
+ fPathID(gpu->glPathRendering()->genPaths(1)) {
InitPathObject(gpu, fPathID, fSkPath, stroke);
// FIXME: try to account for stroking, without rasterizing the stroke.
fBounds.outset(stroke.getWidth(), stroke.getWidth());
}
+ this->registerWithCache();
}
GrGLPath::~GrGLPath() {
void GrGLPath::onRelease() {
if (0 != fPathID && !this->isWrapped()) {
- static_cast<GrGpuGL*>(this->getGpu())->pathRendering()->deletePaths(fPathID, 1);
+ static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fPathID, 1);
fPathID = 0;
}