| 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_D3D9_ES2_ContextType, //! ANGLE on Direct3D9 OpenGL ES 2 context. | 73 kANGLE_ContextType, //! ANGLE on DirectX OpenGL ES context. |
| 74 kANGLE_D3D11_ES2_ContextType,//! ANGLE on Direct3D11 OpenGL ES 2 context
. | 74 kANGLE_GL_ContextType, //! ANGLE on OpenGL OpenGL ES context. |
| 75 kANGLE_D3D11_ES3_ContextType,//! ANGLE on Direct3D11 OpenGL ES 3 context
. | 75 kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES contex
t. |
| 76 kANGLE_GL_ES2_ContextType, //! ANGLE on OpenGL OpenGL ES 2 context. | 76 kMESA_ContextType, //! MESA OpenGL context |
| 77 kANGLE_GL_ES3_ContextType, //! ANGLE on OpenGL OpenGL ES 3 context. | 77 kNullGL_ContextType, //! Non-rendering OpenGL mock context. |
| 78 kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES conte
xt. | 78 kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL co
ntext. |
| 79 kMESA_ContextType, //! MESA OpenGL context | 79 kVulkan_ContextType, //! Vulkan |
| 80 kNullGL_ContextType, //! Non-rendering OpenGL mock context. | |
| 81 kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL c
ontext. | |
| 82 kVulkan_ContextType, //! Vulkan | |
| 83 kLastContextType = kVulkan_ContextType | 80 kLastContextType = kVulkan_ContextType |
| 84 }; | 81 }; |
| 85 | 82 |
| 86 //! OpenGL or OpenGL ES context depending on the platform. To be removed. | 83 //! OpenGL or OpenGL ES context depending on the platform. To be removed. |
| 87 static const ContextType kNativeGL_ContextType; | 84 static const ContextType kNativeGL_ContextType; |
| 88 | 85 |
| 89 static const int kContextTypeCnt = kLastContextType + 1; | 86 static const int kContextTypeCnt = kLastContextType + 1; |
| 90 | 87 |
| 91 /** | 88 /** |
| 92 * Options for GL context creation. For historical and testing reasons the o
ptions will default | 89 * Options for GL context creation. For historical and testing reasons the o
ptions will default |
| (...skipping 30 matching lines...) Expand all Loading... |
| 123 | 120 |
| 124 static GrBackend ContextTypeBackend(ContextType type) { | 121 static GrBackend ContextTypeBackend(ContextType type) { |
| 125 switch (type) { | 122 switch (type) { |
| 126 case kVulkan_ContextType: | 123 case kVulkan_ContextType: |
| 127 return kVulkan_GrBackend; | 124 return kVulkan_GrBackend; |
| 128 default: | 125 default: |
| 129 return kOpenGL_GrBackend; | 126 return kOpenGL_GrBackend; |
| 130 } | 127 } |
| 131 } | 128 } |
| 132 | 129 |
| 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 |
| 133 explicit GrContextFactory(const GrContextOptions& opts); | 153 explicit GrContextFactory(const GrContextOptions& opts); |
| 134 GrContextFactory(); | 154 GrContextFactory(); |
| 135 | 155 |
| 136 ~GrContextFactory(); | 156 ~GrContextFactory(); |
| 137 | 157 |
| 138 void destroyContexts(); | 158 void destroyContexts(); |
| 139 void abandonContexts(); | 159 void abandonContexts(); |
| 140 void releaseResourcesAndAbandonContexts(); | 160 void releaseResourcesAndAbandonContexts(); |
| 141 | 161 |
| 142 /** | 162 /** |
| (...skipping 20 matching lines...) Expand all Loading... |
| 163 }; | 183 }; |
| 164 SkTArray<Context, true> fContexts; | 184 SkTArray<Context, true> fContexts; |
| 165 SkAutoTDelete<GLTestContext> fSentinelGLContext; | 185 SkAutoTDelete<GLTestContext> fSentinelGLContext; |
| 166 const GrContextOptions fGlobalOptions; | 186 const GrContextOptions fGlobalOptions; |
| 167 }; | 187 }; |
| 168 } // namespace sk_gpu_test | 188 } // namespace sk_gpu_test |
| 169 | 189 |
| 170 GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions); | 190 GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions); |
| 171 | 191 |
| 172 #endif | 192 #endif |
| OLD | NEW |