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

Unified Diff: src/gpu/batches/GrTessellatingPathRenderer.cpp

Issue 1990793003: Don't allow uncacheable paths in tessellated path renderer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Change order of tests in onCanDrawPath Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrTessellatingPathRenderer.cpp
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index e697f78d7218e2a6d36f8c06f3b0fce3ce1c69be..f8f5db3af0da4908d3794220ee79157892977098 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -105,11 +105,14 @@ GrTessellatingPathRenderer::GrTessellatingPathRenderer() {
bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
// This path renderer can draw all fill styles, all stroke styles except hairlines, but does
// not do antialiasing. It can do convex and concave paths, but we'll leave the convex ones to
- // simpler algorithms. Similary, we skip the non-hairlines that can be treated as hairline.
- // An arbitrary path effect could produce a hairline result so we pass on those.
- return !IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullptr) &&
+ // simpler algorithms. Similarly, we skip the non-hairlines that can be treated as hairline.
+ // An arbitrary path effect could produce a hairline result so we pass on those. We also skip
+ // volatile paths since they are not cacheable.
+ return !args.fAntiAlias && !args.fPath->isVolatile() &&
!args.fStyle->strokeRec().isHairlineStyle() &&
- !args.fStyle->hasNonDashPathEffect() && !args.fAntiAlias && !args.fPath->isConvex();
+ !args.fStyle->hasNonDashPathEffect() &&
+ !IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullptr) &&
+ !args.fPath->isConvex();
}
class TessellatingPathBatch : public GrVertexBatch {
@@ -160,25 +163,25 @@ private:
int clipBoundsCnt =
fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) : 0;
int styleDataCnt = GrStyle::KeySize(fStyle, GrStyle::Apply::kPathEffectAndStrokeRec);
- if (styleDataCnt >= 0) {
- GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsCnt + styleDataCnt);
- builder[0] = fPath.getGenerationID();
- builder[1] = fPath.getFillType();
- // For inverse fills, the tessellation is dependent on clip bounds.
- if (fPath.isInverseFillType()) {
- memcpy(&builder[2], &fClipBounds, sizeof(fClipBounds));
- }
- if (styleDataCnt) {
- GrStyle::WriteKey(&builder[2 + clipBoundsCnt], fStyle,
- GrStyle::Apply::kPathEffectAndStrokeRec, styleScale);
- }
- builder.finish();
- SkAutoTUnref<GrBuffer> cachedVertexBuffer(rp->findAndRefTByUniqueKey<GrBuffer>(key));
- int actualCount;
- if (cache_match(cachedVertexBuffer.get(), tol, &actualCount)) {
- this->drawVertices(target, gp, cachedVertexBuffer.get(), 0, actualCount);
- return;
- }
+ // We should have excluded anything we wouldn't know how to cache.
+ SkASSERT(styleDataCnt >= 0);
+ GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsCnt + styleDataCnt);
+ builder[0] = fPath.getGenerationID();
+ builder[1] = fPath.getFillType();
+ // For inverse fills, the tessellation is dependent on clip bounds.
+ if (fPath.isInverseFillType()) {
+ memcpy(&builder[2], &fClipBounds, sizeof(fClipBounds));
+ }
+ if (styleDataCnt) {
+ GrStyle::WriteKey(&builder[2 + clipBoundsCnt], fStyle,
+ GrStyle::Apply::kPathEffectAndStrokeRec, styleScale);
+ }
+ builder.finish();
+ SkAutoTUnref<GrBuffer> cachedVertexBuffer(rp->findAndRefTByUniqueKey<GrBuffer>(key));
+ int actualCount;
+ if (cache_match(cachedVertexBuffer.get(), tol, &actualCount)) {
+ this->drawVertices(target, gp, cachedVertexBuffer.get(), 0, actualCount);
+ return;
}
SkPath path;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698