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

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

Issue 1116123003: Improve caching of dashed paths in GrStencilAndCoverPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr-01
Patch Set: . Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLPath.cpp
diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp
index 6417e684f9f61b985f1061ed7c8d47adcc7efdb4..496961723d0f93a5bbe8c6fdcb84d46f32264ce7 100644
--- a/src/gpu/gl/GrGLPath.cpp
+++ b/src/gpu/gl/GrGLPath.cpp
@@ -91,7 +91,8 @@ inline void points_to_coords(const SkPoint points[], size_t first_point, size_t
void GrGLPath::InitPathObject(GrGLGpu* gpu,
GrGLuint pathID,
const SkPath& skPath,
- const SkStrokeRec& stroke) {
+ const GrStrokeInfo& stroke) {
+ SkASSERT(!stroke.isDashed());
if (!skPath.isEmpty()) {
int verbCnt = skPath.countVerbs();
int pointCnt = skPath.countPoints();
@@ -168,29 +169,49 @@ void GrGLPath::InitPathObject(GrGLGpu* gpu,
GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, 0, NULL, 0, GR_GL_FLOAT, NULL));
}
- if (stroke.needToApply()) {
- SkASSERT(!stroke.isHairlineStyle());
+ const SkStrokeRec& strokeRec = stroke.getStrokeRec();
+ if (strokeRec.needToApply()) {
+ SkASSERT(!strokeRec.isHairlineStyle());
GR_GL_CALL(gpu->glInterface(),
- PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stroke.getWidth())));
+ PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(strokeRec.getWidth())));
GR_GL_CALL(gpu->glInterface(),
- PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(stroke.getMiter())));
- GrGLenum join = join_to_gl_join(stroke.getJoin());
+ PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strokeRec.getMiter())));
+ GrGLenum join = join_to_gl_join(strokeRec.getJoin());
GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
- GrGLenum cap = cap_to_gl_cap(stroke.getCap());
+ GrGLenum cap = cap_to_gl_cap(strokeRec.getCap());
GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAPS, cap));
}
}
-GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& path, const SkStrokeRec& stroke)
- : INHERITED(gpu, path, stroke),
+GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStrokeInfo& origStroke)
+ : INHERITED(gpu, origSkPath, origStroke),
fPathID(gpu->glPathRendering()->genPaths(1)) {
- InitPathObject(gpu, fPathID, fSkPath, stroke);
+ // Convert a dashing to either a stroke or a fill.
+ const SkPath* skPath = &origSkPath;
+ SkTLazy<SkPath> tmpPath;
+ const GrStrokeInfo* stroke = &origStroke;
+ GrStrokeInfo tmpStroke(origStroke, false);
- if (stroke.needToApply()) {
+ if (stroke->isDashed()) {
+ if (stroke->applyDash(tmpPath.init(), &tmpStroke, *skPath)) {
+ skPath = tmpPath.get();
+ stroke = &tmpStroke;
+ }
+ }
+
+ InitPathObject(gpu, fPathID, *skPath, *stroke);
+
+ const SkStrokeRec& strokeRec = stroke->getStrokeRec();
+ fShouldStroke = strokeRec.needToApply();
+ fShouldFill = stroke->isFillStyle() ||
+ strokeRec.getStyle() == SkStrokeRec::kStrokeAndFill_Style;
+
+ if (fShouldStroke) {
// FIXME: try to account for stroking, without rasterizing the stroke.
- fBounds.outset(stroke.getWidth(), stroke.getWidth());
+ fBounds.outset(strokeRec.getWidth(), strokeRec.getWidth());
}
+
this->registerWithCache();
}
« src/gpu/GrStrokeInfo.h ('K') | « src/gpu/gl/GrGLPath.h ('k') | src/gpu/gl/GrGLPathRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698