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

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 1386463004: Incrementally flush GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/GrDrawTarget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e7c1c8b5c14a93733bfca40cd8a7b99a82f7b4dd..a9a8a5c342efd2affe0f7d37961daa2e2b1341e1 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -36,7 +36,8 @@ GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
: fGpu(SkRef(gpu))
, fResourceProvider(resourceProvider)
, fFlushing(false)
- , fLastFlushToken(0) {
+ , fLastFlushToken(0)
+ , fLastFlushedBatch(0) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
fClipMaskManager.reset(new GrClipMaskManager(this));
@@ -111,7 +112,8 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
return true;
}
robertphillips 2015/10/02 13:02:57 Maybe flushNextN(int N) and just assume 'index' is
-void GrDrawTarget::flush() {
+void GrDrawTarget::flushN(int index, int N) {
robertphillips 2015/10/02 13:02:57 SkASSERT(index == fLastFlushedBatch); ?
+ SkASSERT(index + N <= fBatches.count());
if (fFlushing) {
return;
}
@@ -119,8 +121,10 @@ void GrDrawTarget::flush() {
GrBatchFlushState flushState(fGpu, fResourceProvider, fLastFlushToken);
+ int flushTo = index + N;
+
// Loop over all batches and generate geometry
- for (int i = 0; i < fBatches.count(); ++i) {
+ for (int i = index; i < flushTo; ++i) {
fBatches[i]->prepare(&flushState);
}
@@ -128,17 +132,22 @@ void GrDrawTarget::flush() {
flushState.preIssueDraws();
// Draw all the generated geometry.
- for (int i = 0; i < fBatches.count(); ++i) {
+ for (int i = index; i < flushTo; ++i) {
fBatches[i]->draw(&flushState);
}
fLastFlushToken = flushState.lastFlushedToken();
fFlushing = false;
+}
+
+void GrDrawTarget::flush() {
+ this->flushN(fLastFlushedBatch, fBatches.count() - fLastFlushedBatch);
this->reset();
}
void GrDrawTarget::reset() {
+ fLastFlushedBatch = 0;
fBatches.reset();
}
@@ -434,6 +443,9 @@ void GrDrawTarget::recordBatch(GrBatch* batch) {
GrBATCH_INFO("\t\tFirstBatch\n");
}
fBatches.push_back().reset(SkRef(batch));
+ if (fBatches.count() > kMaxLookback) {
+ this->flushN(fLastFlushedBatch++, 1);
+ }
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698