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

Unified Diff: src/gpu/GrTessellatingPathRenderer.cpp

Issue 1087323002: Implement caching in the tessellating path renderer, including strokes. Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: NULL -> nullptr Created 5 years, 4 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/GrPathRenderer.h ('k') | tests/TessellatingPathRendererTests.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTessellatingPathRenderer.cpp
diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp
index 282efe251666a46ac42b04424e58c76d46c3b447..5defe2942deed7601465ca563ca4d5a52ad4ec68 100644
--- a/src/gpu/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/GrTessellatingPathRenderer.cpp
@@ -1394,9 +1394,12 @@ public:
static GrBatch* Create(const GrColor& color,
const SkPath& path,
+ const GrStrokeInfo* stroke,
const SkMatrix& viewMatrix,
- SkRect clipBounds) {
- return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipBounds));
+ SkRect clipBounds,
+ const SkPath* origSrcPath,
+ const GrStrokeInfo* origStrokeInfo) {
+ return SkNEW_ARGS(TessellatingPathBatch, (color, path, stroke, viewMatrix, clipBounds, origSrcPath, origStrokeInfo));
}
const char* name() const override { return "TessellatingPathBatch"; }
@@ -1485,15 +1488,13 @@ public:
LOG("actual count: %d\n", actualCount);
SkASSERT(actualCount <= count);
- if (!fPath.isVolatile()) {
- TessInfo info;
- info.fTolerance = isLinear ? 0 : tol;
- info.fCount = actualCount;
- SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
- key->setCustomData(data.get());
- resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get());
- SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key)));
- }
+ TessInfo info;
+ info.fTolerance = isLinear ? 0 : tol;
+ info.fCount = actualCount;
+ SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
+ key->setCustomData(data.get());
+ resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get());
+ SkPathPriv::AddGenIDChangeListener(fPathForKey, SkNEW(PathInvalidator(*key)));
return actualCount;
}
@@ -1503,13 +1504,15 @@ public:
GrUniqueKey key;
int clipBoundsSize32 =
fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) : 0;
- GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32);
- builder[0] = fPath.getGenerationID();
- builder[1] = fPath.getFillType();
+ int strokeDataSize32 = fOrigStroke.computeUniqueKeyFragmentData32Cnt();
+ GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32 + strokeDataSize32);
+ builder[0] = fPathForKey.getGenerationID();
+ builder[1] = fPathForKey.getFillType();
// For inverse fills, the tessellation is dependent on clip bounds.
if (fPath.isInverseFillType()) {
memcpy(&builder[2], &fClipBounds, sizeof(fClipBounds));
}
+ fOrigStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]);
builder.finish();
GrResourceProvider* rp = batchTarget->resourceProvider();
SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrVertexBuffer>(key));
@@ -1561,12 +1564,18 @@ public:
private:
TessellatingPathBatch(const GrColor& color,
const SkPath& path,
+ const GrStrokeInfo* stroke,
const SkMatrix& viewMatrix,
- const SkRect& clipBounds)
+ const SkRect& clipBounds,
+ const SkPath* origSrcPath,
+ const GrStrokeInfo* origStrokeInfo)
: fColor(color)
, fPath(path)
+ , fStroke(*stroke)
, fViewMatrix(viewMatrix)
- , fClipBounds(clipBounds) {
+ , fClipBounds(clipBounds)
+ , fPathForKey(origSrcPath ? *origSrcPath : fPath)
+ , fOrigStroke(origStrokeInfo ? *origStrokeInfo : *stroke) {
this->initClassID<TessellatingPathBatch>();
fBounds = path.getBounds();
@@ -1575,9 +1584,12 @@ private:
GrColor fColor;
SkPath fPath;
+ GrStrokeInfo fStroke;
SkMatrix fViewMatrix;
SkRect fClipBounds; // in source space
GrPipelineInfo fPipelineInfo;
+ SkPath fPathForKey;
+ GrStrokeInfo fOrigStroke;
};
bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
@@ -1596,7 +1608,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
}
vmi.mapRect(&clipBounds);
SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(args.fColor, *args.fPath,
- *args.fViewMatrix, clipBounds));
+ args.fStroke, *args.fViewMatrix, clipBounds, args.fOrigSrcPath, args.fOrigStrokeInfo));
args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
return true;
@@ -1610,6 +1622,7 @@ BATCH_TEST_DEFINE(TesselatingPathBatch) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
SkPath path = GrTest::TestPath(random);
+ GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
SkRect clipBounds = GrTest::TestRect(random);
SkMatrix vmi;
bool result = viewMatrix.invert(&vmi);
@@ -1617,7 +1630,7 @@ BATCH_TEST_DEFINE(TesselatingPathBatch) {
SkFAIL("Cannot invert matrix\n");
}
vmi.mapRect(&clipBounds);
- return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds);
+ return TessellatingPathBatch::Create(color, path, &stroke, viewMatrix, clipBounds, nullptr, nullptr);
}
#endif
« no previous file with comments | « src/gpu/GrPathRenderer.h ('k') | tests/TessellatingPathRendererTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698