[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef APP_GFX_GL_GL_IMPLEMENTATION_H_ | ||||
6 | #define APP_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" | ||||
13 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 14 | namespace gfx { |
15 | |||||
16 | // The GL implementation currently in use. | ||||
17 | enum GLImplementation { | ||||
18 | kGLImplementationNone, | ||||
19 | kGLImplementationDesktopGL, | ||||
20 | kGLImplementationOSMesaGL, | ||||
21 | kGLImplementationEGLGLES2, | ||||
22 | kGLImplementationMockGL | ||||
23 | }; | ||||
24 | |||||
[email protected] | aefbf90 | 2010-10-27 19:42:56 | [diff] [blame] | 25 | // The GL implementation names that can be passed to --use-gl. |
26 | extern const char kGLImplementationDesktopName[]; | ||||
27 | extern const char kGLImplementationOSMesaName[]; | ||||
28 | extern const char kGLImplementationEGLName[]; | ||||
29 | extern const char kGLImplementationMockName[]; | ||||
30 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 31 | #if defined(OS_WIN) |
32 | typedef void* (WINAPI *GLGetProcAddressProc)(const char* name); | ||||
33 | #else | ||||
34 | typedef void* (*GLGetProcAddressProc)(const char* name); | ||||
35 | #endif | ||||
36 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 37 | // Initialize a particular GL implementation. |
38 | bool InitializeGLBindings(GLImplementation implementation); | ||||
39 | |||||
[email protected] | e9f6aee5 | 2010-11-04 20:32:06 | [diff] [blame] | 40 | // Initialize Debug logging wrappers for GL bindings. |
[email protected] | 218a5a2 | 2010-11-04 19:27:49 | [diff] [blame] | 41 | void InitializeDebugGLBindings(); |
42 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 43 | // Set the current GL implementation. |
44 | void SetGLImplementation(GLImplementation implementation); | ||||
45 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 46 | // Get the current GL implementation. |
47 | GLImplementation GetGLImplementation(); | ||||
48 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 49 | // Get the GL implementation with a given name. |
50 | GLImplementation GetNamedGLImplementation(const std::wstring& name); | ||||
51 | |||||
[email protected] | 363b20d | 2011-01-14 22:54:16 | [diff] [blame] | 52 | // Get the name of a GL implementation. |
53 | const char* GetGLImplementationName(GLImplementation implementation); | ||||
54 | |||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 55 | // Initialize the preferred GL binding from the given list. The preferred GL |
56 | // bindings depend on command line switches passed by the user and which GL | ||||
[email protected] | 7dac074 | 2011-02-04 22:32:59 | [diff] [blame^] | 57 | // implementation is the default on a given platform. |
58 | bool InitializeRequestedGLBindings( | ||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 59 | const GLImplementation* allowed_implementations_begin, |
[email protected] | 7dac074 | 2011-02-04 22:32:59 | [diff] [blame^] | 60 | const GLImplementation* allowed_implementations_end, |
61 | GLImplementation default_implementation); | ||||
[email protected] | 30aa5c1a | 2010-07-14 20:47:04 | [diff] [blame] | 62 | |
63 | // Add a native library to those searched for GL entry points. | ||||
64 | void AddGLNativeLibrary(base::NativeLibrary library); | ||||
65 | |||||
66 | // Set an additional function that will be called to find GL entry points. | ||||
67 | void SetGLGetProcAddressProc(GLGetProcAddressProc proc); | ||||
68 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 69 | // Find an entry point in the current GL implementation. |
70 | void* GetGLProcAddress(const char* name); | ||||
71 | |||||
72 | } // namespace gfx | ||||
73 | |||||
74 | #endif // APP_GFX_GL_GL_IMPLEMENTATION_H_ |