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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 //! 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. |
84 static const ContextType kNativeGL_ContextType; | 84 static const ContextType kNativeGL_ContextType; |
85 | 85 |
86 static const int kContextTypeCnt = kLastContextType + 1; | 86 static const int kContextTypeCnt = kLastContextType + 1; |
87 | 87 |
88 /** | 88 /** |
89 * 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 |
90 * to not using GL_NV_path_rendering extension even when the driver support
s it. | 90 * to not using GL_NV_path_rendering extension even when the driver support
s it. |
91 */ | 91 */ |
92 enum ContextOptions { | 92 enum class ContextOptions { |
93 kNone_ContextOptions = 0x0, | 93 kNone = 0x0, |
94 kEnableNVPR_ContextOptions = 0x1, | 94 kEnableNVPR = 0x1, |
95 kUseInstanced_ContextOptions = 0x2, | 95 kUseInstanced = 0x2, |
96 kRequireSRGBSupport_ContextOptions = 0x4, | 96 kRequireSRGBSupport = 0x4, |
97 }; | 97 }; |
98 | 98 |
99 static ContextType NativeContextTypeForBackend(GrBackend backend) { | 99 static ContextType NativeContextTypeForBackend(GrBackend backend) { |
100 switch (backend) { | 100 switch (backend) { |
101 case kOpenGL_GrBackend: | 101 case kOpenGL_GrBackend: |
102 return kNativeGL_ContextType; | 102 return kNativeGL_ContextType; |
103 case kVulkan_GrBackend: | 103 case kVulkan_GrBackend: |
104 return kVulkan_ContextType; | 104 return kVulkan_ContextType; |
105 default: | 105 default: |
106 SkFAIL("Unknown backend"); | 106 SkFAIL("Unknown backend"); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 ~GrContextFactory(); | 156 ~GrContextFactory(); |
157 | 157 |
158 void destroyContexts(); | 158 void destroyContexts(); |
159 void abandonContexts(); | 159 void abandonContexts(); |
160 void releaseResourcesAndAbandonContexts(); | 160 void releaseResourcesAndAbandonContexts(); |
161 | 161 |
162 /** | 162 /** |
163 * Get a context initialized with a type of GL context. It also makes the GL
context current. | 163 * Get a context initialized with a type of GL context. It also makes the GL
context current. |
164 */ | 164 */ |
165 ContextInfo getContextInfo(ContextType type, | 165 ContextInfo getContextInfo(ContextType type, |
166 ContextOptions options = kNone_ContextOptions); | 166 ContextOptions options = ContextOptions::kNone); |
167 /** | 167 /** |
168 * Get a GrContext initialized with a type of GL context. It also makes the
GL context current. | 168 * Get a GrContext initialized with a type of GL context. It also makes the
GL context current. |
169 */ | 169 */ |
170 GrContext* get(ContextType type, ContextOptions options = kNone_ContextOptio
ns) { | 170 GrContext* get(ContextType type, ContextOptions options = ContextOptions::kN
one) { |
171 return this->getContextInfo(type, options).grContext(); | 171 return this->getContextInfo(type, options).grContext(); |
172 } | 172 } |
173 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } | 173 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } |
174 | 174 |
175 private: | 175 private: |
176 struct Context { | 176 struct Context { |
177 ContextType fType; | 177 ContextType fType; |
178 ContextOptions fOptions; | 178 ContextOptions fOptions; |
179 GrBackend fBackend; | 179 GrBackend fBackend; |
180 TestContext* fTestContext; | 180 TestContext* fTestContext; |
181 GrContext* fGrContext; | 181 GrContext* fGrContext; |
182 bool fAbandoned; | 182 bool fAbandoned; |
183 }; | 183 }; |
184 SkTArray<Context, true> fContexts; | 184 SkTArray<Context, true> fContexts; |
185 SkAutoTDelete<GLTestContext> fSentinelGLContext; | 185 SkAutoTDelete<GLTestContext> fSentinelGLContext; |
186 const GrContextOptions fGlobalOptions; | 186 const GrContextOptions fGlobalOptions; |
187 }; | 187 }; |
188 } // namespace sk_gpu_test | 188 } // namespace sk_gpu_test |
| 189 |
| 190 GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions); |
| 191 |
189 #endif | 192 #endif |
OLD | NEW |