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

Unified Diff: src/gpu/gl/GrGLPathRange.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, 7 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
« no previous file with comments | « src/gpu/gl/GrGLPathRange.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLPathRange.cpp
diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
index d7ccf1bcc74664673bb079bd2a1c34202bdf8452..b577d896192d41cf1c07c0374f10d51f897412f3 100644
--- a/src/gpu/gl/GrGLPathRange.cpp
+++ b/src/gpu/gl/GrGLPathRange.cpp
@@ -11,10 +11,12 @@
#include "GrGLPathRendering.h"
#include "GrGLGpu.h"
-GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const SkStrokeRec& stroke)
- : INHERITED(gpu, pathGenerator, stroke),
+GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const GrStrokeInfo& stroke)
+ : INHERITED(gpu, pathGenerator),
+ fStroke(stroke),
fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())),
fGpuMemorySize(0) {
+ this->init();
this->registerWithCache();
}
@@ -22,14 +24,27 @@ GrGLPathRange::GrGLPathRange(GrGLGpu* gpu,
GrGLuint basePathID,
int numPaths,
size_t gpuMemorySize,
- const SkStrokeRec& stroke)
- : INHERITED(gpu, numPaths, stroke),
+ const GrStrokeInfo& stroke)
+ : INHERITED(gpu, numPaths),
+ fStroke(stroke),
fBasePathID(basePathID),
fGpuMemorySize(gpuMemorySize) {
+ this->init();
this->registerWithCache();
}
-void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const {
+void GrGLPathRange::init() {
+ if (fStroke.isDashed()) {
+ fShouldStroke = false;
+ fShouldFill = true;
+ } else {
+ fShouldStroke = fStroke.needToApply();
+ fShouldFill = fStroke.isFillStyle() ||
+ fStroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style;
+ }
+}
+
+void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const {
GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu());
if (NULL == gpu) {
return;
@@ -41,7 +56,31 @@ void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const {
GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)));
SkASSERT(GR_GL_FALSE == isPath);
- GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke());
+ const SkPath* skPath = &origSkPath;
+ SkTLazy<SkPath> tmpPath;
+ const GrStrokeInfo* stroke = &fStroke;
+ GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
+
+ // Dashing must be applied to the path. However, if dashing is present,
+ // we must convert all the paths to fills. The GrStrokeInfo::applyDash leaves
+ // simple paths as strokes but converts other paths to fills.
+ // Thus we must stroke the strokes here, so that all paths in the
+ // path range are using the same style.
+ if (fStroke.isDashed()) {
+ if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
+ return;
+ }
+ skPath = tmpPath.get();
+ stroke = &tmpStroke;
+ if (tmpStroke.needToApply()) {
+ if (!tmpStroke.applyToPath(tmpPath.get(), *tmpPath.get())) {
+ return;
+ }
+ tmpStroke.setFillStyle();
+ }
+ }
+
+ GrGLPath::InitPathObject(gpu, fBasePathID + index, *skPath, *stroke);
// TODO: Use a better approximation for the individual path sizes.
fGpuMemorySize += 100;
« no previous file with comments | « src/gpu/gl/GrGLPathRange.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698