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

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

Issue 1151093006: Added disabling EGL extensions support with --disable-extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied nits Created 5 years, 6 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_tests.gyp » ('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
7 #include "base/command_line.h"
8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h"
10 #include "ui/gl/gl_context.h"
6 #include "ui/gl/gl_implementation.h" 11 #include "ui/gl/gl_implementation.h"
7 12
8 namespace gfx { 13 namespace gfx {
9 14
10 RealEGLApi* g_real_egl; 15 RealEGLApi* g_real_egl;
11 16
12 void InitializeStaticGLBindingsEGL() { 17 void InitializeStaticGLBindingsEGL() {
13 if (!g_real_egl) { 18 if (!g_real_egl) {
14 g_real_egl = new RealEGLApi(); 19 g_real_egl = new RealEGLApi();
15 } 20 }
16 g_real_egl->Initialize(&g_driver_egl); 21 g_real_egl->Initialize(&g_driver_egl);
17 g_current_egl_context = g_real_egl; 22 g_current_egl_context = g_real_egl;
18 g_driver_egl.InitializeStaticBindings(); 23 g_driver_egl.InitializeStaticBindings();
24
25 g_real_egl->InitializeFilteredExtensions();
19 } 26 }
20 27
21 void InitializeDebugGLBindingsEGL() { 28 void InitializeDebugGLBindingsEGL() {
22 g_driver_egl.InitializeDebugBindings(); 29 g_driver_egl.InitializeDebugBindings();
23 } 30 }
24 31
25 void ClearGLBindingsEGL() { 32 void ClearGLBindingsEGL() {
26 if (g_real_egl) { 33 if (g_real_egl) {
27 delete g_real_egl; 34 delete g_real_egl;
28 g_real_egl = NULL; 35 g_real_egl = NULL;
(...skipping 19 matching lines...) Expand all
48 driver_ = driver; 55 driver_ = driver;
49 } 56 }
50 57
51 RealEGLApi::RealEGLApi() { 58 RealEGLApi::RealEGLApi() {
52 } 59 }
53 60
54 RealEGLApi::~RealEGLApi() { 61 RealEGLApi::~RealEGLApi() {
55 } 62 }
56 63
57 void RealEGLApi::Initialize(DriverEGL* driver) { 64 void RealEGLApi::Initialize(DriverEGL* driver) {
65 InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess());
66 }
67
68 void RealEGLApi::InitializeWithCommandLine(DriverEGL* driver,
69 base::CommandLine* command_line) {
70 DCHECK(command_line);
58 InitializeBase(driver); 71 InitializeBase(driver);
72
73 const std::string disabled_extensions = command_line->GetSwitchValueASCII(
74 switches::kDisableGLExtensions);
75 if (!disabled_extensions.empty()) {
76 Tokenize(disabled_extensions, ", ;", &disabled_exts_);
77 }
78 }
79
80 void RealEGLApi::InitializeFilteredExtensions() {
81 if (!disabled_exts_.empty() && filtered_exts_.empty()) {
82 std::vector<std::string> platform_extensions_vec;
83 std::string platform_ext = DriverEGL::GetPlatformExtensions();
84 base::SplitString(platform_ext, ' ', &platform_extensions_vec);
85
86 std::vector<std::string> client_extensions_vec;
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 }
101
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 }
114 return EGLApiBase::eglQueryStringFn(dpy, name);
59 } 115 }
60 116
61 TraceEGLApi::~TraceEGLApi() { 117 TraceEGLApi::~TraceEGLApi() {
62 } 118 }
63 119
64 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { 120 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) {
65 EGLDisplay display = eglGetCurrentDisplay(); 121 EGLDisplay display = eglGetCurrentDisplay();
66 const char* vendor = eglQueryString(display, EGL_VENDOR); 122 const char* vendor = eglQueryString(display, EGL_VENDOR);
67 const char* version = eglQueryString(display, EGL_VERSION); 123 const char* version = eglQueryString(display, EGL_VERSION);
68 const char* extensions = eglQueryString(display, EGL_EXTENSIONS); 124 const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
69 *info = GLWindowSystemBindingInfo(); 125 *info = GLWindowSystemBindingInfo();
70 if (vendor) 126 if (vendor)
71 info->vendor = vendor; 127 info->vendor = vendor;
72 if (version) 128 if (version)
73 info->version = version; 129 info->version = version;
74 if (extensions) 130 if (extensions)
75 info->extensions = extensions; 131 info->extensions = extensions;
76 return true; 132 return true;
77 } 133 }
78 134
79 } // namespace gfx 135 } // namespace gfx
80 136
81 137
OLDNEW
« no previous file with comments | « ui/gl/gl_egl_api_implementation.h ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698