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

Side by Side Diff: tools/gpu/GrContextFactory.h

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: rebase, readd null interface to main lib Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrContextFactory_DEFINED 8 #ifndef GrContextFactory_DEFINED
9 #define GrContextFactory_DEFINED 9 #define GrContextFactory_DEFINED
10 10
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrContextOptions.h" 12 #include "GrContextOptions.h"
13 13
14 #include "gl/SkGLContext.h" 14 #include "gl/GLContext.h"
15 #include "SkTArray.h" 15 #include "SkTArray.h"
16 16
17 namespace sk_gpu_test {
17 /** 18 /**
18 * This is a simple class that is useful in test apps that use different 19 * This is a simple class that is useful in test apps that use different
19 * GrContexts backed by different types of GL contexts. It manages creating the 20 * GrContexts backed by different types of GL contexts. It manages creating the
20 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the 21 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the
21 * factory is destroyed (though the caller can always grab a ref on the returned 22 * factory is destroyed (though the caller can always grab a ref on the returned
22 * Gr and GL contexts to make them outlive the factory). 23 * Gr and GL contexts to make them outlive the factory).
23 */ 24 */
24 class GrContextFactory : SkNoncopyable { 25 class GrContextFactory : SkNoncopyable {
25 public: 26 public:
26 enum GLContextType { 27 enum GLContextType {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 GrContextFactory(); 103 GrContextFactory();
103 104
104 ~GrContextFactory(); 105 ~GrContextFactory();
105 106
106 void destroyContexts(); 107 void destroyContexts();
107 void abandonContexts(); 108 void abandonContexts();
108 109
109 struct ContextInfo { 110 struct ContextInfo {
110 ContextInfo() 111 ContextInfo()
111 : fGrContext(nullptr), fGLContext(nullptr) { } 112 : fGrContext(nullptr), fGLContext(nullptr) { }
112 ContextInfo(GrContext* grContext, SkGLContext* glContext) 113 ContextInfo(GrContext* grContext, GLContext* glContext)
113 : fGrContext(grContext), fGLContext(glContext) { } 114 : fGrContext(grContext), fGLContext(glContext) { }
114 GrContext* fGrContext; 115 GrContext* fGrContext;
115 SkGLContext* fGLContext; //! Valid until the factory destroys it via aba ndonContexts() or 116 GLContext* fGLContext; //! Valid until the factory destroys it via aband onContexts() or
116 //! destroyContexts(). 117 //! destroyContexts().
117 }; 118 };
118 119
119 /** 120 /**
120 * Get a context initialized with a type of GL context. It also makes the GL context current. 121 * Get a context initialized with a type of GL context. It also makes the GL context current.
121 */ 122 */
122 ContextInfo getContextInfo(GLContextType type, 123 ContextInfo getContextInfo(GLContextType type,
123 GLContextOptions options = kNone_GLContextOptions ); 124 GLContextOptions options = kNone_GLContextOptions );
124 /** 125 /**
125 * Get a GrContext initialized with a type of GL context. It also makes the GL context current. 126 * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
126 */ 127 */
127 GrContext* get(GLContextType type, 128 GrContext* get(GLContextType type,
128 GLContextOptions options = kNone_GLContextOptions) { 129 GLContextOptions options = kNone_GLContextOptions) {
129 return this->getContextInfo(type, options).fGrContext; 130 return this->getContextInfo(type, options).fGrContext;
130 } 131 }
131 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } 132 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
132 133
133 private: 134 private:
134 struct Context { 135 struct Context {
135 GLContextType fType; 136 GLContextType fType;
136 GLContextOptions fOptions; 137 GLContextOptions fOptions;
137 SkGLContext* fGLContext; 138 GLContext* fGLContext;
138 GrContext* fGrContext; 139 GrContext* fGrContext;
139 }; 140 };
140 SkTArray<Context, true> fContexts; 141 SkTArray<Context, true> fContexts;
141 const GrContextOptions fGlobalOptions; 142 const GrContextOptions fGlobalOptions;
142 }; 143 };
143 144 } // namespace sk_gpu_test
144 #endif 145 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698