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

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

Issue 1203513004: Respect the disabled extension list during binding initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 5 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_glx_api_implementation.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 {
14 std::string FilterExtensionList(
15 const char* extensions,
16 const std::vector<std::string>& disabled_extensions) {
17 if (extensions == NULL)
18 return "";
19 std::vector<std::string> extension_vec;
20 base::SplitString(extensions, ' ', &extension_vec);
21 extension_vec.erase(std::remove_if(
22 extension_vec.begin(), extension_vec.end(),
23 [&disabled_extensions](const std::string& ext) {
24 return std::find(disabled_extensions.begin(), disabled_extensions.end(),
25 ext) != disabled_extensions.end();
26 }), extension_vec.end());
27 return JoinString(extension_vec, " ");
28 }
29 }
30
13 namespace gfx { 31 namespace gfx {
14 32
15 RealEGLApi* g_real_egl; 33 RealEGLApi* g_real_egl;
16 34
17 void InitializeStaticGLBindingsEGL() { 35 void InitializeStaticGLBindingsEGL() {
36 g_driver_egl.InitializeStaticBindings();
18 if (!g_real_egl) { 37 if (!g_real_egl) {
19 g_real_egl = new RealEGLApi(); 38 g_real_egl = new RealEGLApi();
20 } 39 }
21 g_real_egl->Initialize(&g_driver_egl); 40 g_real_egl->Initialize(&g_driver_egl);
22 g_current_egl_context = g_real_egl; 41 g_current_egl_context = g_real_egl;
23 g_driver_egl.InitializeStaticBindings(); 42 g_driver_egl.InitializeExtensionBindings();
24
25 g_real_egl->InitializeFilteredExtensions();
26 } 43 }
27 44
28 void InitializeDebugGLBindingsEGL() { 45 void InitializeDebugGLBindingsEGL() {
29 g_driver_egl.InitializeDebugBindings(); 46 g_driver_egl.InitializeDebugBindings();
30 } 47 }
31 48
32 void ClearGLBindingsEGL() { 49 void ClearGLBindingsEGL() {
33 if (g_real_egl) { 50 if (g_real_egl) {
34 delete g_real_egl; 51 delete g_real_egl;
35 g_real_egl = NULL; 52 g_real_egl = NULL;
(...skipping 29 matching lines...) Expand all
65 InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); 82 InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess());
66 } 83 }
67 84
68 void RealEGLApi::InitializeWithCommandLine(DriverEGL* driver, 85 void RealEGLApi::InitializeWithCommandLine(DriverEGL* driver,
69 base::CommandLine* command_line) { 86 base::CommandLine* command_line) {
70 DCHECK(command_line); 87 DCHECK(command_line);
71 InitializeBase(driver); 88 InitializeBase(driver);
72 89
73 const std::string disabled_extensions = command_line->GetSwitchValueASCII( 90 const std::string disabled_extensions = command_line->GetSwitchValueASCII(
74 switches::kDisableGLExtensions); 91 switches::kDisableGLExtensions);
92 disabled_exts_.clear();
93 filtered_exts_.clear();
75 if (!disabled_extensions.empty()) { 94 if (!disabled_extensions.empty()) {
76 Tokenize(disabled_extensions, ", ;", &disabled_exts_); 95 Tokenize(disabled_extensions, ", ;", &disabled_exts_);
77 } 96 }
78 } 97 }
79 98
80 void RealEGLApi::InitializeFilteredExtensions() { 99 const char* RealEGLApi::eglQueryStringFn(EGLDisplay dpy, EGLint name) {
81 if (!disabled_exts_.empty() && filtered_exts_.empty()) { 100 if (name == EGL_EXTENSIONS) {
82 std::vector<std::string> platform_extensions_vec; 101 auto it = filtered_exts_.find(dpy);
83 std::string platform_ext = DriverEGL::GetPlatformExtensions(); 102 if (it == filtered_exts_.end()) {
84 base::SplitString(platform_ext, ' ', &platform_extensions_vec); 103 it = filtered_exts_.insert(std::make_pair(
85 104 dpy, FilterExtensionList(EGLApiBase::eglQueryStringFn(dpy, name),
86 std::vector<std::string> client_extensions_vec; 105 disabled_exts_))).first;
87 std::string client_ext = DriverEGL::GetClientExtensions();
88 base::SplitString(client_ext, ' ', &client_extensions_vec);
89
90 // Filter out extensions from the command line.
91 for (const std::string& disabled_ext : disabled_exts_) {
92 platform_extensions_vec.erase(std::remove(platform_extensions_vec.begin(),
93 platform_extensions_vec.end(),
94 disabled_ext),
95 platform_extensions_vec.end());
96 client_extensions_vec.erase(std::remove(client_extensions_vec.begin(),
97 client_extensions_vec.end(),
98 disabled_ext),
99 client_extensions_vec.end());
100 } 106 }
101 107 return (*it).second.c_str();
102 // Construct filtered extensions string for GL_EXTENSIONS string lookups.
103 filtered_exts_ = JoinString(platform_extensions_vec, " ");
104 if (!platform_extensions_vec.empty() && !client_extensions_vec.empty())
105 filtered_exts_ += " ";
106 filtered_exts_ += JoinString(client_extensions_vec, " ");
107 }
108 }
109
110 const char* RealEGLApi::eglQueryStringFn(EGLDisplay dpy, EGLint name) {
111 if (!filtered_exts_.empty() && name == EGL_EXTENSIONS) {
112 return filtered_exts_.c_str();
113 } 108 }
114 return EGLApiBase::eglQueryStringFn(dpy, name); 109 return EGLApiBase::eglQueryStringFn(dpy, name);
115 } 110 }
116 111
117 TraceEGLApi::~TraceEGLApi() { 112 TraceEGLApi::~TraceEGLApi() {
118 } 113 }
119 114
120 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { 115 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) {
121 EGLDisplay display = eglGetCurrentDisplay(); 116 EGLDisplay display = eglGetCurrentDisplay();
122 const char* vendor = eglQueryString(display, EGL_VENDOR); 117 const char* vendor = eglQueryString(display, EGL_VENDOR);
123 const char* version = eglQueryString(display, EGL_VERSION); 118 const char* version = eglQueryString(display, EGL_VERSION);
124 const char* extensions = eglQueryString(display, EGL_EXTENSIONS); 119 const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
125 *info = GLWindowSystemBindingInfo(); 120 *info = GLWindowSystemBindingInfo();
126 if (vendor) 121 if (vendor)
127 info->vendor = vendor; 122 info->vendor = vendor;
128 if (version) 123 if (version)
129 info->version = version; 124 info->version = version;
130 if (extensions) 125 if (extensions)
131 info->extensions = extensions; 126 info->extensions = extensions;
132 return true; 127 return true;
133 } 128 }
134 129
135 } // namespace gfx 130 } // namespace gfx
136 131
137 132
OLDNEW
« no previous file with comments | « ui/gl/gl_egl_api_implementation.h ('k') | ui/gl/gl_glx_api_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698