Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ui / gl / gl_implementation.h
blob7319b47c4dc826afdea4269f2584c2a0cf842c22
1 // Copyright (c) 2012 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.
5 #ifndef UI_GL_GL_IMPLEMENTATION_H_
6 #define UI_GL_GL_IMPLEMENTATION_H_
8 #include <string>
9 #include <vector>
11 #include "base/native_library.h"
12 #include "build/build_config.h"
13 #include "ui/gl/gl_export.h"
14 #include "ui/gl/gl_switches.h"
16 namespace gfx {
18 class GLContext;
20 // The GL implementation currently in use.
21 enum GLImplementation {
22 kGLImplementationNone,
23 kGLImplementationDesktopGL,
24 kGLImplementationOSMesaGL,
25 kGLImplementationAppleGL,
26 kGLImplementationEGLGLES2,
27 kGLImplementationMockGL
30 struct GL_EXPORT GLWindowSystemBindingInfo {
31 GLWindowSystemBindingInfo();
32 std::string vendor;
33 std::string version;
34 std::string extensions;
35 bool direct_rendering;
38 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls);
40 #if defined(OS_WIN)
41 typedef void* (WINAPI *GLGetProcAddressProc)(const char* name);
42 #else
43 typedef void* (*GLGetProcAddressProc)(const char* name);
44 #endif
46 // Initialize a particular GL implementation.
47 GL_EXPORT bool InitializeStaticGLBindings(GLImplementation implementation);
49 // Initialize function bindings that depend on the context for a GL
50 // implementation.
51 GL_EXPORT bool InitializeDynamicGLBindings(GLImplementation implementation,
52 GLContext* context);
54 // Initialize Debug logging wrappers for GL bindings.
55 void InitializeDebugGLBindings();
57 // Initialize stub methods for drawing operations in the GL bindings. The
58 // null draw bindings default to enabled, so that draw operations do nothing.
59 void InitializeNullDrawGLBindings();
61 // TODO(danakj): Remove this when all test suites are using null-draw.
62 GL_EXPORT bool HasInitializedNullDrawGLBindings();
64 // Once initialized, instantiating this turns the stub methods for drawing
65 // operations off allowing drawing will occur while the object is alive.
66 class GL_EXPORT DisableNullDrawGLBindings {
67 public:
68 DisableNullDrawGLBindings();
69 ~DisableNullDrawGLBindings();
71 private:
72 bool initial_enabled_;
75 GL_EXPORT void ClearGLBindings();
77 // Set the current GL implementation.
78 GL_EXPORT void SetGLImplementation(GLImplementation implementation);
80 // Get the current GL implementation.
81 GL_EXPORT GLImplementation GetGLImplementation();
83 // Does the underlying GL support all features from Desktop GL 2.0 that were
84 // removed from the ES 2.0 spec without requiring specific extension strings.
85 GL_EXPORT bool HasDesktopGLFeatures();
87 // Get the GL implementation with a given name.
88 GLImplementation GetNamedGLImplementation(const std::string& name);
90 // Get the name of a GL implementation.
91 const char* GetGLImplementationName(GLImplementation implementation);
93 // Add a native library to those searched for GL entry points.
94 void AddGLNativeLibrary(base::NativeLibrary library);
96 // Unloads all native libraries.
97 void UnloadGLNativeLibraries();
99 // Set an additional function that will be called to find GL entry points.
100 // Exported so that tests may set the function used in the mock implementation.
101 GL_EXPORT void SetGLGetProcAddressProc(GLGetProcAddressProc proc);
103 // Find an entry point in the current GL implementation. Note that the function
104 // may return a non-null pointer to something else than the GL function if an
105 // unsupported function is queried. Spec-compliant eglGetProcAddress and
106 // glxGetProcAddress are allowed to return garbage for unsupported functions,
107 // and when querying functions from the EGL library supplied by Android, it may
108 // return a function that prints a log message about the function being
109 // unsupported.
110 void* GetGLProcAddress(const char* name);
112 // Return information about the GL window system binding implementation (e.g.,
113 // EGL, GLX, WGL). Returns true if the information was retrieved successfully.
114 GL_EXPORT bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info);
116 } // namespace gfx
118 #endif // UI_GL_GL_IMPLEMENTATION_H_