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

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 1386463004: Incrementally flush GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 2 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..6cfb985ff21d1ebf6f04e207203d586ea6296b8e 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -35,8 +35,9 @@
GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
: fGpu(SkRef(gpu))
, fResourceProvider(resourceProvider)
+ , fFlushState(fGpu, fResourceProvider, 0)
, fFlushing(false)
- , fLastFlushToken(0) {
+ , fLastPreparedBatch(0) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
fClipMaskManager.reset(new GrClipMaskManager(this));
@@ -111,34 +112,40 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
return true;
}
+void GrDrawTarget::prepareN(int N) {
bsalomon 2015/10/02 14:40:17 I'm wondering how helpful this helper function is,
+ SkASSERT(fLastPreparedBatch + N <= fBatches.count());
+
+ int flushTo = fLastPreparedBatch + N;
+
+ // Loop over all batches and generate geometry
+ for (int i = fLastPreparedBatch; i < flushTo; ++i) {
+ fBatches[i]->prepare(&fFlushState);
+ }
+}
+
void GrDrawTarget::flush() {
if (fFlushing) {
return;
}
fFlushing = true;
- GrBatchFlushState flushState(fGpu, fResourceProvider, fLastFlushToken);
-
- // Loop over all batches and generate geometry
- for (int i = 0; i < fBatches.count(); ++i) {
- fBatches[i]->prepare(&flushState);
- }
+ this->prepareN(fBatches.count() - fLastPreparedBatch);
// Upload all data to the GPU
- flushState.preIssueDraws();
+ fFlushState.preIssueDraws();
// Draw all the generated geometry.
for (int i = 0; i < fBatches.count(); ++i) {
- fBatches[i]->draw(&flushState);
+ fBatches[i]->draw(&fFlushState);
}
- fLastFlushToken = flushState.lastFlushedToken();
+ this->reset();
fFlushing = false;
- this->reset();
}
void GrDrawTarget::reset() {
+ fLastPreparedBatch = 0;
fBatches.reset();
}
@@ -434,6 +441,11 @@ void GrDrawTarget::recordBatch(GrBatch* batch) {
GrBATCH_INFO("\t\tFirstBatch\n");
}
fBatches.push_back().reset(SkRef(batch));
+ if (fBatches.count() > kMaxLookback) {
+ SkASSERT(fBatches.count() - kMaxLookback - fLastPreparedBatch == 1);
+ this->prepareN(1);
+ fLastPreparedBatch++;
+ }
}
///////////////////////////////////////////////////////////////////////////////
« 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