OLD | NEW |
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/GLTestContext.h" | 14 #include "gl/GLTestContext.h" |
15 #include "SkTArray.h" | 15 #include "SkTArray.h" |
16 | 16 |
17 struct GrVkBackendContext; | 17 struct GrVkBackendContext; |
18 | 18 |
19 namespace sk_gpu_test { | 19 namespace sk_gpu_test { |
20 | 20 |
21 struct ContextInfo { | 21 class ContextInfo { |
| 22 public: |
| 23 GrContext* grContext() const { return fGrContext; } |
| 24 GLTestContext* glContext() const { return fGLContext; } |
| 25 |
| 26 private: |
22 ContextInfo() | 27 ContextInfo() |
23 : fGrContext(nullptr), fGLContext(nullptr) { } | 28 : fGrContext(nullptr), fGLContext(nullptr) { } |
24 ContextInfo(GrContext* grContext, GLTestContext* glContext) | 29 ContextInfo(GrContext* grContext, GLTestContext* glContext) |
25 : fGrContext(grContext), fGLContext(glContext) { } | 30 : fGrContext(grContext), fGLContext(glContext) { } |
26 GrContext* fGrContext; | 31 GrContext* fGrContext; |
27 GLTestContext* fGLContext; //! Valid until the factory destroys it via aband
onContexts() or | 32 GLTestContext* fGLContext; //! Valid until the factory destroys it via aband
onContexts() or |
28 //! destroyContexts(). Null if context is not bas
ed on OpenGL. | 33 //! destroyContexts(). Null if context is not bas
ed on OpenGL. |
| 34 |
| 35 friend class GrContextFactory; |
29 }; | 36 }; |
30 | 37 |
31 /** | 38 /** |
32 * This is a simple class that is useful in test apps that use different | 39 * This is a simple class that is useful in test apps that use different |
33 * GrContexts backed by different types of GL contexts. It manages creating the | 40 * GrContexts backed by different types of GL contexts. It manages creating the |
34 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the | 41 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the |
35 * factory is destroyed (though the caller can always grab a ref on the returned | 42 * factory is destroyed (though the caller can always grab a ref on the returned |
36 * Gr and GL contexts to make them outlive the factory). | 43 * Gr and GL contexts to make them outlive the factory). |
37 */ | 44 */ |
38 class GrContextFactory : SkNoncopyable { | 45 class GrContextFactory : SkNoncopyable { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 GLTestContext* fGLContext; // null if non-GL | 145 GLTestContext* fGLContext; // null if non-GL |
139 GrContext* fGrContext; | 146 GrContext* fGrContext; |
140 bool fAbandoned; | 147 bool fAbandoned; |
141 }; | 148 }; |
142 SkTArray<Context, true> fContexts; | 149 SkTArray<Context, true> fContexts; |
143 SkAutoTDelete<GLTestContext> fSentinelGLContext; | 150 SkAutoTDelete<GLTestContext> fSentinelGLContext; |
144 const GrContextOptions fGlobalOptions; | 151 const GrContextOptions fGlobalOptions; |
145 }; | 152 }; |
146 } // namespace sk_gpu_test | 153 } // namespace sk_gpu_test |
147 #endif | 154 #endif |
OLD | NEW |