[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 5 | #ifndef UI_GL_GL_IMPLEMENTATION_H_ |
6 | #define UI_GL_GL_IMPLEMENTATION_H_ | ||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 7 | |
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 8 | #include <string> |
[email protected] | 0f5e888 | 2011-11-08 22:29:38 | [diff] [blame] | 9 | #include <vector> |
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 10 | |
11 | #include "base/native_library.h" | ||||
12 | #include "build/build_config.h" | ||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 13 | #include "ui/gl/gl_export.h" |
14 | #include "ui/gl/gl_switches.h" | ||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 15 | |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 16 | namespace gfx { |
17 | |||||
[email protected] | 6494823b | 2011-10-27 18:30:44 | [diff] [blame] | 18 | class GLContext; |
19 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 20 | // The GL implementation currently in use. |
21 | enum GLImplementation { | ||||
22 | kGLImplementationNone, | ||||
23 | kGLImplementationDesktopGL, | ||||
24 | kGLImplementationOSMesaGL, | ||||
[email protected] | 020d047e | 2011-12-07 19:15:42 | [diff] [blame] | 25 | kGLImplementationAppleGL, |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 26 | kGLImplementationEGLGLES2, |
27 | kGLImplementationMockGL | ||||
28 | }; | ||||
29 | |||||
[email protected] | 4589503 | 2013-05-30 17:06:43 | [diff] [blame] | 30 | struct GLWindowSystemBindingInfo { |
31 | std::string vendor; | ||||
32 | std::string version; | ||||
33 | std::string extensions; | ||||
34 | }; | ||||
35 | |||||
[email protected] | 0f5e888 | 2011-11-08 22:29:38 | [diff] [blame] | 36 | void GetAllowedGLImplementations(std::vector<GLImplementation>* impls); |
37 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 38 | #if defined(OS_WIN) |
39 | typedef void* (WINAPI *GLGetProcAddressProc)(const char* name); | ||||
40 | #else | ||||
41 | typedef void* (*GLGetProcAddressProc)(const char* name); | ||||
42 | #endif | ||||
43 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 44 | // Initialize a particular GL implementation. |
[email protected] | fe377e1 | 2011-08-18 17:37:36 | [diff] [blame] | 45 | GL_EXPORT bool InitializeGLBindings(GLImplementation implementation); |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 46 | |
[email protected] | 6494823b | 2011-10-27 18:30:44 | [diff] [blame] | 47 | // Initialize extension function bindings for a GL implementation. |
48 | GL_EXPORT bool InitializeGLExtensionBindings(GLImplementation implementation, | ||||
49 | GLContext* context); | ||||
50 | |||||
[email protected] | e9f6aee5 | 2010-11-04 20:32:06 | [diff] [blame] | 51 | // Initialize Debug logging wrappers for GL bindings. |
[email protected] | 218a5a2 | 2010-11-04 19:27:49 | [diff] [blame] | 52 | void InitializeDebugGLBindings(); |
53 | |||||
[email protected] | d5ad62a | 2013-05-23 10:56:21 | [diff] [blame] | 54 | GL_EXPORT void ClearGLBindings(); |
[email protected] | 0f5e888 | 2011-11-08 22:29:38 | [diff] [blame] | 55 | |
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 56 | // Set the current GL implementation. |
[email protected] | 8af4d5e | 2013-03-15 23:55:33 | [diff] [blame] | 57 | GL_EXPORT void SetGLImplementation(GLImplementation implementation); |
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 58 | |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 59 | // Get the current GL implementation. |
[email protected] | fe377e1 | 2011-08-18 17:37:36 | [diff] [blame] | 60 | GL_EXPORT GLImplementation GetGLImplementation(); |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 61 | |
[email protected] | 380aba8 | 2011-09-21 18:15:39 | [diff] [blame] | 62 | // Does the underlying GL support all features from Desktop GL 2.0 that were |
63 | // removed from the ES 2.0 spec without requiring specific extension strings. | ||||
64 | GL_EXPORT bool HasDesktopGLFeatures(); | ||||
65 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 66 | // Get the GL implementation with a given name. |
[email protected] | 0f5e888 | 2011-11-08 22:29:38 | [diff] [blame] | 67 | GLImplementation GetNamedGLImplementation(const std::string& name); |
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 68 | |
[email protected] | 363b20d | 2011-01-14 22:54:16 | [diff] [blame] | 69 | // Get the name of a GL implementation. |
70 | const char* GetGLImplementationName(GLImplementation implementation); | ||||
71 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 72 | // Add a native library to those searched for GL entry points. |
73 | void AddGLNativeLibrary(base::NativeLibrary library); | ||||
74 | |||||
[email protected] | 0f5e888 | 2011-11-08 22:29:38 | [diff] [blame] | 75 | // Unloads all native libraries. |
76 | void UnloadGLNativeLibraries(); | ||||
77 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 78 | // Set an additional function that will be called to find GL entry points. |
79 | void SetGLGetProcAddressProc(GLGetProcAddressProc proc); | ||||
80 | |||||
[email protected] | 6494823b | 2011-10-27 18:30:44 | [diff] [blame] | 81 | // Find a core (non-extension) entry point in the current GL implementation. On |
82 | // EGL based implementations core entry points will not be queried through | ||||
83 | // GLGetProcAddressProc. | ||||
84 | void* GetGLCoreProcAddress(const char* name); | ||||
85 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 86 | // Find an entry point in the current GL implementation. |
87 | void* GetGLProcAddress(const char* name); | ||||
88 | |||||
[email protected] | 4589503 | 2013-05-30 17:06:43 | [diff] [blame] | 89 | // Return information about the GL window system binding implementation (e.g., |
90 | // EGL, GLX, WGL). Returns true if the information was retrieved successfully. | ||||
91 | GL_EXPORT bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info); | ||||
92 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 93 | } // namespace gfx |
94 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 95 | #endif // UI_GL_GL_IMPLEMENTATION_H_ |