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 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 * GrContexts backed by different types of GL contexts. It manages creating the | 61 * GrContexts backed by different types of GL contexts. It manages creating the |
62 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the | 62 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the |
63 * factory is destroyed (though the caller can always grab a ref on the returned | 63 * factory is destroyed (though the caller can always grab a ref on the returned |
64 * Gr and GL contexts to make them outlive the factory). | 64 * Gr and GL contexts to make them outlive the factory). |
65 */ | 65 */ |
66 class GrContextFactory : SkNoncopyable { | 66 class GrContextFactory : SkNoncopyable { |
67 public: | 67 public: |
68 // The availability of context types is subject to platform and build config
uration | 68 // The availability of context types is subject to platform and build config
uration |
69 // restrictions. | 69 // restrictions. |
70 enum ContextType { | 70 enum ContextType { |
71 kGL_ContextType, //! OpenGL context. | 71 kGL_ContextType, //! OpenGL context. |
72 kGLES_ContextType, //! OpenGL ES context. | 72 kGLES_ContextType, //! OpenGL ES context. |
73 kANGLE_ContextType, //! ANGLE on DirectX OpenGL ES context. | 73 kANGLE_D3D9_ES2_ContextType, //! ANGLE on Direct3D9 OpenGL ES 2 context. |
74 kANGLE_GL_ContextType, //! ANGLE on OpenGL OpenGL ES context. | 74 kANGLE_D3D11_ES2_ContextType,//! ANGLE on Direct3D11 OpenGL ES 2 context
. |
75 kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES contex
t. | 75 kANGLE_D3D11_ES3_ContextType,//! ANGLE on Direct3D11 OpenGL ES 3 context
. |
76 kMESA_ContextType, //! MESA OpenGL context | 76 kANGLE_GL_ES2_ContextType, //! ANGLE on OpenGL OpenGL ES 2 context. |
77 kNullGL_ContextType, //! Non-rendering OpenGL mock context. | 77 kANGLE_GL_ES3_ContextType, //! ANGLE on OpenGL OpenGL ES 3 context. |
78 kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL co
ntext. | 78 kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES conte
xt. |
79 kVulkan_ContextType, //! Vulkan | 79 kMESA_ContextType, //! MESA OpenGL context |
| 80 kNullGL_ContextType, //! Non-rendering OpenGL mock context. |
| 81 kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL c
ontext. |
| 82 kVulkan_ContextType, //! Vulkan |
80 kLastContextType = kVulkan_ContextType | 83 kLastContextType = kVulkan_ContextType |
81 }; | 84 }; |
82 | 85 |
83 //! OpenGL or OpenGL ES context depending on the platform. To be removed. | 86 //! OpenGL or OpenGL ES context depending on the platform. To be removed. |
84 static const ContextType kNativeGL_ContextType; | 87 static const ContextType kNativeGL_ContextType; |
85 | 88 |
86 static const int kContextTypeCnt = kLastContextType + 1; | 89 static const int kContextTypeCnt = kLastContextType + 1; |
87 | 90 |
88 /** | 91 /** |
89 * Options for GL context creation. For historical and testing reasons the o
ptions will default | 92 * Options for GL context creation. For historical and testing reasons the o
ptions will default |
(...skipping 30 matching lines...) Expand all Loading... |
120 | 123 |
121 static GrBackend ContextTypeBackend(ContextType type) { | 124 static GrBackend ContextTypeBackend(ContextType type) { |
122 switch (type) { | 125 switch (type) { |
123 case kVulkan_ContextType: | 126 case kVulkan_ContextType: |
124 return kVulkan_GrBackend; | 127 return kVulkan_GrBackend; |
125 default: | 128 default: |
126 return kOpenGL_GrBackend; | 129 return kOpenGL_GrBackend; |
127 } | 130 } |
128 } | 131 } |
129 | 132 |
130 static const char* ContextTypeName(ContextType type) { | |
131 switch (type) { | |
132 case kGL_ContextType: | |
133 return "gl"; | |
134 case kGLES_ContextType: | |
135 return "gles"; | |
136 case kANGLE_ContextType: | |
137 return "angle"; | |
138 case kANGLE_GL_ContextType: | |
139 return "angle-gl"; | |
140 case kCommandBuffer_ContextType: | |
141 return "commandbuffer"; | |
142 case kMESA_ContextType: | |
143 return "mesa"; | |
144 case kNullGL_ContextType: | |
145 return "nullgl"; | |
146 case kDebugGL_ContextType: | |
147 return "debuggl"; | |
148 case kVulkan_ContextType: | |
149 return "vulkan"; | |
150 } | |
151 } | |
152 | |
153 explicit GrContextFactory(const GrContextOptions& opts); | 133 explicit GrContextFactory(const GrContextOptions& opts); |
154 GrContextFactory(); | 134 GrContextFactory(); |
155 | 135 |
156 ~GrContextFactory(); | 136 ~GrContextFactory(); |
157 | 137 |
158 void destroyContexts(); | 138 void destroyContexts(); |
159 void abandonContexts(); | 139 void abandonContexts(); |
160 void releaseResourcesAndAbandonContexts(); | 140 void releaseResourcesAndAbandonContexts(); |
161 | 141 |
162 /** | 142 /** |
(...skipping 20 matching lines...) Expand all Loading... |
183 }; | 163 }; |
184 SkTArray<Context, true> fContexts; | 164 SkTArray<Context, true> fContexts; |
185 SkAutoTDelete<GLTestContext> fSentinelGLContext; | 165 SkAutoTDelete<GLTestContext> fSentinelGLContext; |
186 const GrContextOptions fGlobalOptions; | 166 const GrContextOptions fGlobalOptions; |
187 }; | 167 }; |
188 } // namespace sk_gpu_test | 168 } // namespace sk_gpu_test |
189 | 169 |
190 GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions); | 170 GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions); |
191 | 171 |
192 #endif | 172 #endif |
OLD | NEW |