aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-10-23 09:06:59 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-23 09:06:59 -0700
commit648c696438410fe0f0f5db9bb7935006fecf9cad (patch)
treedf620ddfe66ab5d647920e6524b05a4f28b0863a /src
parentb7f1251775390cdcf58197fd904d7676b9508128 (diff)
Add immediate mode option for gpu configs in dm
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrContext.cpp8
-rw-r--r--src/gpu/GrDrawTarget.cpp11
-rw-r--r--src/gpu/GrDrawTarget.h8
-rw-r--r--src/gpu/GrDrawingManager.cpp3
-rw-r--r--src/gpu/GrDrawingManager.h15
-rw-r--r--src/gpu/GrTest.cpp2
6 files changed, 32 insertions, 15 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2ca3461a69..fee92fe692 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -74,11 +74,11 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
if (!fGpu) {
return false;
}
- this->initCommon();
+ this->initCommon(options);
return true;
}
-void GrContext::initCommon() {
+void GrContext::initCommon(const GrContextOptions& options) {
fCaps = SkRef(fGpu->caps());
fResourceCache = new GrResourceCache(fCaps);
fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
@@ -88,7 +88,9 @@ void GrContext::initCommon() {
fDidTestPMConversions = false;
- fDrawingManager.reset(new GrDrawingManager(this));
+ GrDrawTarget::Options dtOptions;
+ dtOptions.fImmediateMode = options.fImmediateMode;
+ fDrawingManager.reset(new GrDrawingManager(this, dtOptions));
// GrBatchFontCache will eventually replace GrFontCache
fBatchFontCache = new GrBatchFontCache(this);
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index f42ee111ce..1dc26bc8c6 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -32,13 +32,15 @@
////////////////////////////////////////////////////////////////////////////////
-GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
+GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
+ const Options& options)
: fGpu(SkRef(gpu))
, fResourceProvider(resourceProvider)
, fFlushState(fGpu, fResourceProvider, 0)
, fFlushing(false)
, fFirstUnpreparedBatch(0)
- , fFlags(0) {
+ , fFlags(0)
+ , fOptions(options) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
fClipMaskManager.reset(new GrClipMaskManager(this));
@@ -472,6 +474,8 @@ template <class Left, class Right> static bool intersect(const Left& a, const Ri
void GrDrawTarget::recordBatch(GrBatch* batch) {
// A closed drawTarget should never receive new/more batches
SkASSERT(!this->isClosed());
+ // Should never have batches queued up when in immediate mode.
+ SkASSERT(!fOptions.fImmediateMode || !fBatches.count());
// Check if there is a Batch Draw we can batch with by linearly searching back until we either
// 1) check every draw
@@ -524,6 +528,9 @@ void GrDrawTarget::recordBatch(GrBatch* batch) {
SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1);
fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState);
}
+ if (fOptions.fImmediateMode) {
+ this->flush();
+ }
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index ec94da1f0e..a487785a8b 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -43,9 +43,13 @@ class GrPathRangeDraw;
class GrDrawTarget final : public SkRefCnt {
public:
+ struct Options {
+ bool fImmediateMode;
+ };
+
// The context may not be fully constructed and should not be used during GrDrawTarget
// construction.
- GrDrawTarget(GrGpu* gpu, GrResourceProvider*);
+ GrDrawTarget(GrGpu* gpu, GrResourceProvider*, const Options& options);
~GrDrawTarget() override;
@@ -221,7 +225,6 @@ public:
const CMMAccess cmmAccess() { return CMMAccess(this); }
-
private:
friend class GrDrawingManager; // for resetFlag & TopoSortTraits
@@ -311,6 +314,7 @@ private:
SkDEBUGCODE(int fDebugID;)
uint32_t fFlags;
+ Options fOptions;
// 'this' drawTarget relies on the output of the drawTargets in 'fDependencies'
SkTDArray<GrDrawTarget*> fDependencies;
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 682b15511a..0dbd476c79 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -105,7 +105,8 @@ GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
}
#endif
- GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourceProvider());
+ GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourceProvider(),
+ fOptions);
*fDrawTargets.append() = dt;
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index d799493c8f..be21d68ea8 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -8,6 +8,7 @@
#ifndef GrDrawingManager_DEFINED
#define GrDrawingManager_DEFINED
+#include "GrDrawTarget.h"
#include "SkTDArray.h"
class GrContext;
@@ -40,9 +41,10 @@ public:
GrContext* getContext() { return fContext; }
private:
- GrDrawingManager(GrContext* context)
+ GrDrawingManager(GrContext* context, GrDrawTarget::Options options)
: fContext(context)
, fAbandoned(false)
+ , fOptions(options)
, fNVPRTextContext(nullptr) {
sk_bzero(fTextContexts, sizeof(fTextContexts));
}
@@ -57,13 +59,14 @@ private:
static const int kNumPixelGeometries = 5; // The different pixel geometries
static const int kNumDFTOptions = 2; // DFT or no DFT
- GrContext* fContext;
+ GrContext* fContext;
- bool fAbandoned;
- SkTDArray<GrDrawTarget*> fDrawTargets;
+ bool fAbandoned;
+ SkTDArray<GrDrawTarget*> fDrawTargets;
+ GrDrawTarget::Options fOptions;
- GrTextContext* fNVPRTextContext;
- GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
+ GrTextContext* fNVPRTextContext;
+ GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
};
#endif
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index aafb0b975a..4adc3f7b7b 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -288,7 +288,7 @@ void GrContext::initMockContext() {
SkASSERT(nullptr == fGpu);
fGpu = new MockGpu(this, options);
SkASSERT(fGpu);
- this->initCommon();
+ this->initCommon(options);
// We delete these because we want to test the cache starting with zero resources. Also, none of
// these objects are required for any of tests that use this context. TODO: make stop allocating