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

Unified Diff: tools/gpu/TestContext.h

Issue 1964243003: Add base class for GLTestContext and add new subclass VkTestContext. (Closed) Base URL: https://chromium.googlesource.com/skia.git@ContextInfo
Patch Set: move #include "GrVkBackendContext.h" inside #ifdef SK_VULKAN Created 4 years, 7 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 | « tools/gpu/GrContextFactory.cpp ('k') | tools/gpu/TestContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gpu/TestContext.h
diff --git a/tools/gpu/TestContext.h b/tools/gpu/TestContext.h
new file mode 100644
index 0000000000000000000000000000000000000000..5143b8a6fae352c3c8bea503908288ab41061ece
--- /dev/null
+++ b/tools/gpu/TestContext.h
@@ -0,0 +1,95 @@
+
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef TestContext_DEFINED
+#define TestContext_DEFINED
+
+#include "GrTypes.h"
+#include "../private/SkGpuFenceSync.h"
+#include "../private/SkTemplates.h"
+
+namespace sk_gpu_test {
+/**
+ * An offscreen 3D context. This class is intended for Skia's internal testing needs and not
+ * for general use.
+ */
+class TestContext : public SkNoncopyable {
+public:
+ virtual ~TestContext();
+
+ virtual bool isValid() const = 0;
+
+ bool fenceSyncSupport() const { return fFenceSync != nullptr; }
+
+ bool getMaxGpuFrameLag(int *maxFrameLag) const {
+ if (!fFenceSync) {
+ return false;
+ }
+ *maxFrameLag = kMaxFrameLag;
+ return true;
+ }
+
+ void makeCurrent() const;
+
+ virtual GrBackend backend() = 0;
+ virtual GrBackendContext backendContext() = 0;
+
+ /** Swaps front and back buffer (if the context has such buffers) */
+ void swapBuffers();
+
+ /**
+ * The only purpose of this function it to provide a means of scheduling
+ * work on the GPU (since all of the subclasses create primary buffers for
+ * testing that are small and not meant to be rendered to the screen).
+ *
+ * If the platform supports fence syncs (OpenGL 3.2+ or EGL_KHR_fence_sync),
+ * this will not swap any buffers, but rather emulate triple buffer synchronization
+ * using fences.
+ *
+ * Otherwise it will call the platform SwapBuffers method. This may or may
+ * not perform some sort of synchronization, depending on whether the
+ * drawing surface provided by the platform is double buffered.
+ */
+ void waitOnSyncOrSwap();
+
+ /**
+ * This notifies the context that we are deliberately testing abandoning
+ * the context. It is useful for debugging contexts that would otherwise
+ * test that GPU resources are properly deleted. It also allows a debugging
+ * context to test that further API calls are not made by Skia GPU code.
+ */
+ virtual void testAbandon();
+
+ /**
+ * returns the fencesync object owned by this GLTestContext
+ */
+ SkGpuFenceSync *fenceSync() { return fFenceSync; }
+
+protected:
+ SkGpuFenceSync* fFenceSync;
+
+ TestContext();
+
+ /** This should destroy the 3D context. */
+ virtual void teardown();
+
+ virtual void onPlatformMakeCurrent() const = 0;
+ virtual void onPlatformSwapBuffers() const = 0;
+
+private:
+ enum {
+ kMaxFrameLag = 3
+ };
+
+ SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
+ int fCurrentFenceIdx;
+
+ typedef SkNoncopyable INHERITED;
+};
+} // namespace sk_gpu_test
+#endif
« no previous file with comments | « tools/gpu/GrContextFactory.cpp ('k') | tools/gpu/TestContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698