aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDDLContext.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-08 11:30:12 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-08 19:52:31 +0000
commita3457b8452a24c04a77a5ab32fc6464e005c76a1 (patch)
treed70c916a1802b622f526f8711f69729815423c10 /src/gpu/GrDDLContext.cpp
parent1eb5ca41d9db5ca72f44f957fdd483d3f260f051 (diff)
Split GrDDL- & GrDirect- Contexts into their own files
Following up on an prior CLs TODO Change-Id: I99397d4ffa5cc67b39726900f48b399e38fdbdd9 Reviewed-on: https://skia-review.googlesource.com/113201 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
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;
+}