aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-10-02 09:06:39 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-02 09:06:39 -0700
commita7e878064509ef96b54d5507dab0b50def66dc13 (patch)
tree76be24b95d95d4a0304bd20938f9e3521c464710 /src/gpu
parentdb9f66472e6e6a916bfc07052029a93c9332b5e5 (diff)
Incrementally flush GrDrawTarget
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrDrawTarget.cpp21
-rw-r--r--src/gpu/GrDrawTarget.h5
2 files changed, 16 insertions, 10 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e7c1c8b5c1..de22d0d3c0 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) {
+ , fFirstUnpreparedBatch(0) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
fClipMaskManager.reset(new GrClipMaskManager(this));
@@ -117,28 +118,26 @@ void GrDrawTarget::flush() {
}
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);
+ for (; fFirstUnpreparedBatch < fBatches.count(); ++fFirstUnpreparedBatch) {
+ fBatches[fFirstUnpreparedBatch]->prepare(&fFlushState);
}
// 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() {
+ fFirstUnpreparedBatch = 0;
fBatches.reset();
}
@@ -434,6 +433,10 @@ void GrDrawTarget::recordBatch(GrBatch* batch) {
GrBATCH_INFO("\t\tFirstBatch\n");
}
fBatches.push_back().reset(SkRef(batch));
+ if (fBatches.count() > kMaxLookback) {
+ SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1);
+ fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState);
+ }
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 3c28b1e254..8c85e0ad2a 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -8,6 +8,7 @@
#ifndef GrDrawTarget_DEFINED
#define GrDrawTarget_DEFINED
+#include "GrBatchFlushState.h"
#include "GrClip.h"
#include "GrClipMaskManager.h"
#include "GrContext.h"
@@ -33,6 +34,7 @@
#include "SkXfermode.h"
class GrBatch;
+class GrBatchFlushState;
class GrClip;
class GrCaps;
class GrPath;
@@ -228,8 +230,9 @@ private:
GrContext* fContext;
GrGpu* fGpu;
GrResourceProvider* fResourceProvider;
+ GrBatchFlushState fFlushState;
bool fFlushing;
- GrBatchToken fLastFlushToken;
+ int fFirstUnpreparedBatch;
typedef SkRefCnt INHERITED;
};