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

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

Issue 1908433002: Batch multiple single NVPR draw paths to instanced draws Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comments Created 4 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
« no previous file with comments | « src/gpu/batches/GrDrawPathBatch.h ('k') | src/gpu/gl/GrGLPath.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrDrawPathBatch.cpp
diff --git a/src/gpu/batches/GrDrawPathBatch.cpp b/src/gpu/batches/GrDrawPathBatch.cpp
index 1395d083286c7482a9c85bd5c0ef63adc81a0aca..fb9ca943dcb223d9bee72380dc0116ece2b53e37 100644
--- a/src/gpu/batches/GrDrawPathBatch.cpp
+++ b/src/gpu/batches/GrDrawPathBatch.cpp
@@ -13,18 +13,84 @@ static void pre_translate_transform_values(const float* xforms,
SkString GrDrawPathBatch::dumpInfo() const {
SkString string;
- string.printf("PATH: 0x%p", fPath.get());
+ string.printf("Color: 0x%08x Fill: %x Path count: %d Paths: ", this->color(), this->fillType(),
+ fTotalPathCount);
+ const GrDrawPathBatch* batch = this;
+ do {
+ string.appendf("0x%p", batch->fPath.get());
+ batch = batch->fNext.get();
+ } while (batch);
+ string.append("\n");
return string;
}
-void GrDrawPathBatch::onDraw(GrBatchFlushState* state) {
- GrProgramDesc desc;
+bool GrDrawPathBatch::ListBoundsIntersects(const GrDrawPathBatch* a, const GrDrawPathBatch* b) {
+ if (!SkRect::Intersects(a->fBounds, b->fBounds)) {
+ return false;
+ }
+ if (!a->fNext && !b->fNext) {
+ return true;
+ }
+ const GrDrawPathBatch* firstA = a;
+ do {
+ do {
+ if (SkRect::Intersects(a->fPathBounds, b->fPathBounds)) {
+ return true;
+ }
+ a = a->fNext.get();
+ } while (a);
+ a = firstA;
+ b = b->fNext.get();
+ } while (b);
+ return false;
+}
+
+bool GrDrawPathBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
+ GrDrawPathBatch* that = t->cast<GrDrawPathBatch>();
+ if (this->color() != that->color() ||
+ !this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
+ return false;
+ }
+ if (!GrPipeline::AreEqual(*this->pipeline(), *that->pipeline(), false)) {
+ return false;
+ }
+ if (that->fillType() != this->fillType() ||
+ this->stencilSettings() != that->stencilSettings()) {
+ return false;
+ }
+ if (ListBoundsIntersects(this, that)) {
+ return false;
+ }
+ if (!fPath.get()->canCombineDrawPathBatchWith(*that->fPath.get())) {
+ return false;
+ }
+ SkASSERT(!*fLastSlot);
+ fLastSlot->reset(SkRef(that));
+ fLastSlot = that->fLastSlot;
+ fTotalPathCount += that->fTotalPathCount;
+ this->joinBounds(that->fBounds);
+ return true;
+}
+void GrDrawPathBatch::onDraw(GrBatchFlushState* state) {
SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(),
this->overrides(),
this->viewMatrix()));
- state->gpu()->pathRendering()->drawPath(*this->pipeline(), *pathProc, this->stencilSettings(),
- fPath.get());
+ if (fTotalPathCount > 1) {
+ SkAutoSTMalloc<32, const GrPath*> paths(fTotalPathCount);
+ GrDrawPathBatch* batch = this;
+ int i = 0;
+ do {
+ paths[i++] = batch->fPath.get();
+ batch = batch->fNext.get();
+ } while (batch);
+ state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc,
+ this->stencilSettings(), paths, fTotalPathCount);
+ } else {
+ const GrPath* path = fPath.get();
+ state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc,
+ this->stencilSettings(), &path, 1);
+ }
}
SkString GrDrawPathRangeBatch::dumpInfo() const {
« no previous file with comments | « src/gpu/batches/GrDrawPathBatch.h ('k') | src/gpu/gl/GrGLPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698