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

Unified Diff: tools/gpu/GrContextFactory.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 | « include/gpu/vk/GrVkDefines.h ('k') | tools/gpu/GrContextFactory.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gpu/GrContextFactory.h
diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
index f5783fc1ae9ba23704a63ade1241eb08cd396039..dc896a7bc8be32083cb399fa464807b2191b4594 100644
--- a/tools/gpu/GrContextFactory.h
+++ b/tools/gpu/GrContextFactory.h
@@ -12,6 +12,7 @@
#include "GrContextOptions.h"
#include "gl/GLTestContext.h"
+#include "vk/VkTestContext.h"
#include "SkTArray.h"
struct GrVkBackendContext;
@@ -20,17 +21,35 @@ namespace sk_gpu_test {
class ContextInfo {
public:
+ ContextInfo() = default;
+ ContextInfo& operator=(const ContextInfo&) = default;
+
+ GrBackend backend() const { return fBackend; };
+
GrContext* grContext() const { return fGrContext; }
- GLTestContext* glContext() const { return fGLContext; }
+
+ GLTestContext* glContext() const {
+ SkASSERT(kOpenGL_GrBackend == fBackend);
+ return static_cast<GLTestContext*>(fTestContext);
+ }
+
+#ifdef SK_VULKAN
+ VkTestContext* vkContext() const {
+ SkASSERT(kVulkan_GrBackend == fBackend);
+ return static_cast<VkTestContext*>(fTestContext);
+ }
+#endif
private:
- ContextInfo()
- : fGrContext(nullptr), fGLContext(nullptr) { }
- ContextInfo(GrContext* grContext, GLTestContext* glContext)
- : fGrContext(grContext), fGLContext(glContext) { }
- GrContext* fGrContext;
- GLTestContext* fGLContext; //! Valid until the factory destroys it via abandonContexts() or
- //! destroyContexts(). Null if context is not based on OpenGL.
+ ContextInfo(GrBackend backend, TestContext* testContext, GrContext* grContext)
+ : fBackend(backend)
+ , fTestContext(testContext)
+ , fGrContext(grContext) {}
+
+ GrBackend fBackend = kOpenGL_GrBackend;
+ // Valid until the factory destroys it via abandonContexts() or destroyContexts().
+ TestContext* fTestContext = nullptr;
+ GrContext* fGrContext = nullptr;
friend class GrContextFactory;
};
@@ -134,7 +153,7 @@ public:
* Get a GrContext initialized with a type of GL context. It also makes the GL context current.
*/
GrContext* get(ContextType type, ContextOptions options = kNone_ContextOptions) {
- return this->getContextInfo(type, options).fGrContext;
+ return this->getContextInfo(type, options).grContext();
}
const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
@@ -142,7 +161,8 @@ private:
struct Context {
ContextType fType;
ContextOptions fOptions;
- GLTestContext* fGLContext; // null if non-GL
+ GrBackend fBackend;
+ TestContext* fTestContext;
GrContext* fGrContext;
bool fAbandoned;
};
« no previous file with comments | « include/gpu/vk/GrVkDefines.h ('k') | tools/gpu/GrContextFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698