[email protected] | 5ae0b28 | 2011-03-28 19:24:49 | [diff] [blame] | 1 | // Copyright (c) 2011 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] | 5ae0b28 | 2011-03-28 19:24:49 | [diff] [blame] | 5 | #ifndef UI_GFX_GL_GL_IMPLEMENTATION_H_ |
6 | #define UI_GFX_GL_GL_IMPLEMENTATION_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 8 | |
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 9 | #include <string> |
10 | |||||
11 | #include "base/native_library.h" | ||||
12 | #include "build/build_config.h" | ||||
[email protected] | fe377e1 | 2011-08-18 17:37:36 | [diff] [blame] | 13 | #include "ui/gfx/gl/gl_export.h" |
[email protected] | 418c3cb | 2011-07-28 18:07:44 | [diff] [blame] | 14 | #include "ui/gfx/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, | ||||
25 | kGLImplementationEGLGLES2, | ||||
26 | kGLImplementationMockGL | ||||
27 | }; | ||||
28 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 29 | #if defined(OS_WIN) |
30 | typedef void* (WINAPI *GLGetProcAddressProc)(const char* name); | ||||
31 | #else | ||||
32 | typedef void* (*GLGetProcAddressProc)(const char* name); | ||||
33 | #endif | ||||
34 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 35 | // Initialize a particular GL implementation. |
[email protected] | fe377e1 | 2011-08-18 17:37:36 | [diff] [blame] | 36 | GL_EXPORT bool InitializeGLBindings(GLImplementation implementation); |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 37 | |
[email protected] | 6494823b | 2011-10-27 18:30:44 | [diff] [blame^] | 38 | // Initialize extension function bindings for a GL implementation. |
39 | GL_EXPORT bool InitializeGLExtensionBindings(GLImplementation implementation, | ||||
40 | GLContext* context); | ||||
41 | |||||
[email protected] | e9f6aee5 | 2010-11-04 20:32:06 | [diff] [blame] | 42 | // Initialize Debug logging wrappers for GL bindings. |
[email protected] | 218a5a2 | 2010-11-04 19:27:49 | [diff] [blame] | 43 | void InitializeDebugGLBindings(); |
44 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 45 | // Set the current GL implementation. |
46 | void SetGLImplementation(GLImplementation implementation); | ||||
47 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 48 | // Get the current GL implementation. |
[email protected] | fe377e1 | 2011-08-18 17:37:36 | [diff] [blame] | 49 | GL_EXPORT GLImplementation GetGLImplementation(); |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 50 | |
[email protected] | 380aba8 | 2011-09-21 18:15:39 | [diff] [blame] | 51 | // Does the underlying GL support all features from Desktop GL 2.0 that were |
52 | // removed from the ES 2.0 spec without requiring specific extension strings. | ||||
53 | GL_EXPORT bool HasDesktopGLFeatures(); | ||||
54 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 55 | // Get the GL implementation with a given name. |
56 | GLImplementation GetNamedGLImplementation(const std::wstring& name); | ||||
57 | |||||
[email protected] | 363b20d | 2011-01-14 22:54:16 | [diff] [blame] | 58 | // Get the name of a GL implementation. |
59 | const char* GetGLImplementationName(GLImplementation implementation); | ||||
60 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 61 | // Initialize the preferred GL binding from the given list. The preferred GL |
62 | // bindings depend on command line switches passed by the user and which GL | ||||
[email protected] | 7dac074 | 2011-02-04 22:32:59 | [diff] [blame] | 63 | // implementation is the default on a given platform. |
64 | bool InitializeRequestedGLBindings( | ||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 65 | const GLImplementation* allowed_implementations_begin, |
[email protected] | 7dac074 | 2011-02-04 22:32:59 | [diff] [blame] | 66 | const GLImplementation* allowed_implementations_end, |
67 | GLImplementation default_implementation); | ||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 68 | |
69 | // Add a native library to those searched for GL entry points. | ||||
70 | void AddGLNativeLibrary(base::NativeLibrary library); | ||||
71 | |||||
72 | // Set an additional function that will be called to find GL entry points. | ||||
73 | void SetGLGetProcAddressProc(GLGetProcAddressProc proc); | ||||
74 | |||||
[email protected] | 6494823b | 2011-10-27 18:30:44 | [diff] [blame^] | 75 | // Find a core (non-extension) entry point in the current GL implementation. On |
76 | // EGL based implementations core entry points will not be queried through | ||||
77 | // GLGetProcAddressProc. | ||||
78 | void* GetGLCoreProcAddress(const char* name); | ||||
79 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 80 | // Find an entry point in the current GL implementation. |
81 | void* GetGLProcAddress(const char* name); | ||||
82 | |||||
83 | } // namespace gfx | ||||
84 | |||||
[email protected] | 5ae0b28 | 2011-03-28 19:24:49 | [diff] [blame] | 85 | #endif // UI_GFX_GL_GL_IMPLEMENTATION_H_ |