Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: ui/gl/gl_egl_api_implementation.cc

Issue 2629633003: Refactor GL bindings so there is no global GLApi or DriverGL. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_egl_api_implementation.h ('k') | ui/gl/gl_fence.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ui/gl/gl_egl_api_implementation.h ('k') | ui/gl/gl_fence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698