OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/gl_egl_api_implementation.h" | 5 #include "ui/gl/gl_egl_api_implementation.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
11 #include "ui/gl/gl_implementation.h" | 11 #include "ui/gl/gl_implementation.h" |
12 | 12 |
13 namespace gl { | 13 namespace gl { |
14 | 14 |
15 namespace { | 15 RealEGLApi* g_real_egl = nullptr; |
16 | 16 DebugEGLApi* g_debug_egl = nullptr; |
17 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { | |
18 glClearDepthf(static_cast<GLclampf>(depth)); | |
19 } | |
20 | |
21 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, | |
22 GLclampd z_far) { | |
23 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); | |
24 } | |
25 | |
26 } // namespace | |
27 | |
28 RealEGLApi* g_real_egl; | |
29 | 17 |
30 void InitializeStaticGLBindingsEGL() { | 18 void InitializeStaticGLBindingsEGL() { |
31 g_driver_egl.InitializeStaticBindings(); | 19 g_driver_egl.InitializeStaticBindings(); |
32 if (!g_real_egl) { | 20 if (!g_real_egl) { |
33 g_real_egl = new RealEGLApi(); | 21 g_real_egl = new RealEGLApi(); |
34 } | 22 } |
35 g_real_egl->Initialize(&g_driver_egl); | 23 g_real_egl->Initialize(&g_driver_egl); |
36 g_current_egl_context = g_real_egl; | 24 g_current_egl_context = g_real_egl; |
37 | |
38 // These two functions take single precision float rather than double | |
39 // precision float parameters in GLES. | |
40 ::gl::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; | |
41 ::gl::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; | |
42 } | 25 } |
43 | 26 |
44 void InitializeDebugGLBindingsEGL() { | 27 void InitializeDebugGLBindingsEGL() { |
45 g_driver_egl.InitializeDebugBindings(); | 28 if (!g_debug_egl) { |
| 29 g_debug_egl = new DebugEGLApi(g_real_egl); |
| 30 } |
| 31 g_current_egl_context = g_debug_egl; |
46 } | 32 } |
47 | 33 |
48 void ClearBindingsEGL() { | 34 void ClearBindingsEGL() { |
| 35 if (g_debug_egl) { |
| 36 delete g_debug_egl; |
| 37 g_debug_egl = NULL; |
| 38 } |
49 if (g_real_egl) { | 39 if (g_real_egl) { |
50 delete g_real_egl; | 40 delete g_real_egl; |
51 g_real_egl = NULL; | 41 g_real_egl = NULL; |
52 } | 42 } |
53 g_current_egl_context = NULL; | 43 g_current_egl_context = NULL; |
54 g_driver_egl.ClearBindings(); | 44 g_driver_egl.ClearBindings(); |
55 } | 45 } |
56 | 46 |
57 EGLApi::EGLApi() { | 47 EGLApi::EGLApi() { |
58 } | 48 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 if (it == filtered_exts_.end()) { | 93 if (it == filtered_exts_.end()) { |
104 it = filtered_exts_.insert(std::make_pair( | 94 it = filtered_exts_.insert(std::make_pair( |
105 dpy, FilterGLExtensionList(EGLApiBase::eglQueryStringFn(dpy, name), | 95 dpy, FilterGLExtensionList(EGLApiBase::eglQueryStringFn(dpy, name), |
106 disabled_exts_))).first; | 96 disabled_exts_))).first; |
107 } | 97 } |
108 return (*it).second.c_str(); | 98 return (*it).second.c_str(); |
109 } | 99 } |
110 return EGLApiBase::eglQueryStringFn(dpy, name); | 100 return EGLApiBase::eglQueryStringFn(dpy, name); |
111 } | 101 } |
112 | 102 |
| 103 DebugEGLApi::DebugEGLApi(EGLApi* egl_api) : egl_api_(egl_api) {} |
| 104 |
| 105 DebugEGLApi::~DebugEGLApi() {} |
| 106 |
113 TraceEGLApi::~TraceEGLApi() { | 107 TraceEGLApi::~TraceEGLApi() { |
114 } | 108 } |
115 | 109 |
116 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { | 110 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { |
117 EGLDisplay display = eglGetCurrentDisplay(); | 111 EGLDisplay display = eglGetCurrentDisplay(); |
118 const char* vendor = eglQueryString(display, EGL_VENDOR); | 112 const char* vendor = eglQueryString(display, EGL_VENDOR); |
119 const char* version = eglQueryString(display, EGL_VERSION); | 113 const char* version = eglQueryString(display, EGL_VERSION); |
120 const char* extensions = eglQueryString(display, EGL_EXTENSIONS); | 114 const char* extensions = eglQueryString(display, EGL_EXTENSIONS); |
121 *info = GLWindowSystemBindingInfo(); | 115 *info = GLWindowSystemBindingInfo(); |
122 if (vendor) | 116 if (vendor) |
123 info->vendor = vendor; | 117 info->vendor = vendor; |
124 if (version) | 118 if (version) |
125 info->version = version; | 119 info->version = version; |
126 if (extensions) | 120 if (extensions) |
127 info->extensions = extensions; | 121 info->extensions = extensions; |
128 return true; | 122 return true; |
129 } | 123 } |
130 | 124 |
131 } // namespace gl | 125 } // namespace gl |
OLD | NEW |