aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDDLContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrDDLContext.cpp')
-rw-r--r--src/gpu/GrDDLContext.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/gpu/GrDDLContext.cpp b/src/gpu/GrDDLContext.cpp
new file mode 100644
index 0000000000..eba0379aa8
--- /dev/null
+++ b/src/gpu/GrDDLContext.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrContext.h"
+
+#include "GrContextPriv.h"
+
+/**
+ * The DDL Context is the one in effect during DDL Recording. It isn't backed by a GrGPU and
+ * cannot allocate any GPU resources.
+ */
+class SK_API GrDDLContext : public GrContext {
+public:
+ GrDDLContext(sk_sp<GrContextThreadSafeProxy> proxy)
+ : INHERITED(proxy->fBackend, proxy->fContextUniqueID) {
+ fCaps = proxy->fCaps;
+ fThreadSafeProxy = std::move(proxy);
+ }
+
+ ~GrDDLContext() override {
+ // The GrDDLContext doesn't actually own the fRestrictedAtlasManager so don't delete it
+ }
+
+ void abandonContext() override {
+ SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
+ INHERITED::abandonContext();
+ }
+
+ void releaseResourcesAndAbandonContext() override {
+ SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
+ INHERITED::releaseResourcesAndAbandonContext();
+ }
+
+ void freeGpuResources() override {
+ SkASSERT(0); // freeing resources in a DDL Recorder doesn't make a whole lot of sense
+ INHERITED::freeGpuResources();
+ }
+
+protected:
+ bool init(const GrContextOptions& options) override {
+ SkASSERT(fCaps); // should've been set in ctor
+ SkASSERT(fThreadSafeProxy); // should've been set in the ctor
+
+ if (!INHERITED::initCommon(options)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ GrAtlasManager* onGetAtlasManager() override {
+ SkASSERT(0); // the DDL Recorders should never invoke this
+ return nullptr;
+ }
+
+private:
+ typedef GrContext INHERITED;
+};
+
+sk_sp<GrContext> GrContextPriv::MakeDDL(sk_sp<GrContextThreadSafeProxy> proxy) {
+ sk_sp<GrContext> context(new GrDDLContext(proxy));
+
+ // Note: we aren't creating a Gpu here. This causes the resource provider & cache to
+ // also not be created
+ if (!context->init(proxy->fOptions)) {
+ return nullptr;
+ }
+ return context;
+}