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_surface_egl.h" | 5 #include "ui/gl/gl_surface_egl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "ui/gl/egl_util.h" | 24 #include "ui/gl/egl_util.h" |
25 #include "ui/gl/gl_context.h" | 25 #include "ui/gl/gl_context.h" |
26 #include "ui/gl/gl_context_egl.h" | 26 #include "ui/gl/gl_context_egl.h" |
27 #include "ui/gl/gl_image.h" | 27 #include "ui/gl/gl_image.h" |
28 #include "ui/gl/gl_implementation.h" | 28 #include "ui/gl/gl_implementation.h" |
29 #include "ui/gl/gl_surface_stub.h" | 29 #include "ui/gl/gl_surface_stub.h" |
30 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
31 #include "ui/gl/scoped_make_current.h" | 31 #include "ui/gl/scoped_make_current.h" |
32 #include "ui/gl/sync_control_vsync_provider.h" | 32 #include "ui/gl/sync_control_vsync_provider.h" |
33 | 33 |
34 #if defined(OS_ANDROID) | |
35 #include <android/native_window_jni.h> | |
36 #endif | |
37 | |
38 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 34 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
39 extern "C" { | 35 extern "C" { |
40 #include <X11/Xlib.h> | 36 #include <X11/Xlib.h> |
41 #define Status int | 37 #define Status int |
42 } | 38 } |
43 #include "ui/gfx/x/x11_switches.h" // nogncheck | 39 #include "ui/base/x/x11_util_internal.h" // nogncheck |
40 #endif | |
41 | |
42 #if defined(OS_ANDROID) | |
43 #include <android/native_window_jni.h> | |
44 #endif | 44 #endif |
45 | 45 |
46 #if !defined(EGL_FIXED_SIZE_ANGLE) | 46 #if !defined(EGL_FIXED_SIZE_ANGLE) |
47 #define EGL_FIXED_SIZE_ANGLE 0x3201 | 47 #define EGL_FIXED_SIZE_ANGLE 0x3201 |
48 #endif | 48 #endif |
49 | 49 |
50 #if !defined(EGL_OPENGL_ES3_BIT) | 50 #if !defined(EGL_OPENGL_ES3_BIT) |
51 #define EGL_OPENGL_ES3_BIT 0x00000040 | 51 #define EGL_OPENGL_ES3_BIT 0x00000040 |
52 #endif | 52 #endif |
53 | 53 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 | 168 |
169 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); | 169 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
170 display_attribs.push_back(platform_type); | 170 display_attribs.push_back(platform_type); |
171 | 171 |
172 if (warpDevice) { | 172 if (warpDevice) { |
173 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); | 173 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); |
174 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); | 174 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); |
175 } | 175 } |
176 | 176 |
177 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 177 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
178 std::string visualid_str = | 178 Visual* visual; |
179 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 179 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
180 switches::kX11VisualID); | 180 true, &visual, nullptr, nullptr, nullptr); |
Julien Isorce Samsung
2016/09/28 17:42:51
This assumes that the returned visual is the same
Tom (Use chromium acct)
2016/09/28 18:36:01
Yes
| |
181 unsigned int visualid = 0; | |
182 bool succeed = base::StringToUint(visualid_str, &visualid); | |
183 DCHECK(succeed); | |
184 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); | 181 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); |
185 display_attribs.push_back((EGLint)visualid); | 182 display_attribs.push_back(static_cast<EGLint>(XVisualIDFromVisual(visual))); |
186 #endif | 183 #endif |
187 | 184 |
188 display_attribs.push_back(EGL_NONE); | 185 display_attribs.push_back(EGL_NONE); |
189 | 186 |
190 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, | 187 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
191 reinterpret_cast<void*>(native_display), | 188 reinterpret_cast<void*>(native_display), |
192 &display_attribs[0]); | 189 &display_attribs[0]); |
193 } | 190 } |
194 | 191 |
195 EGLDisplay GetDisplayFromType(DisplayType display_type, | 192 EGLDisplay GetDisplayFromType(DisplayType display_type, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 264 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
268 switches::kEnableUnsafeES3APIs)) { | 265 switches::kEnableUnsafeES3APIs)) { |
269 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 266 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
270 } | 267 } |
271 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 268 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
272 | 269 |
273 EGLint buffer_size = 32; | 270 EGLint buffer_size = 32; |
274 EGLint alpha_size = 8; | 271 EGLint alpha_size = 8; |
275 | 272 |
276 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 273 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
277 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 274 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
278 switches::kWindowDepth)) { | 275 true, nullptr, &buffer_size, nullptr, nullptr); |
279 std::string depth = | 276 alpha_size = buffer_size == 32 ? 8 : 0; |
280 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
281 switches::kWindowDepth); | |
282 | |
283 bool succeed = base::StringToInt(depth, &buffer_size); | |
284 DCHECK(succeed); | |
285 | |
286 alpha_size = buffer_size == 32 ? 8 : 0; | |
287 } | |
288 #endif | 277 #endif |
289 | 278 |
290 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) | 279 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) |
291 ? EGL_DONT_CARE | 280 ? EGL_DONT_CARE |
292 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; | 281 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; |
293 | 282 |
294 for (auto renderable_type : renderable_types) { | 283 for (auto renderable_type : renderable_types) { |
295 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 284 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
296 buffer_size, | 285 buffer_size, |
297 EGL_ALPHA_SIZE, | 286 EGL_ALPHA_SIZE, |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 } | 1180 } |
1192 | 1181 |
1193 void* SurfacelessEGL::GetShareHandle() { | 1182 void* SurfacelessEGL::GetShareHandle() { |
1194 return NULL; | 1183 return NULL; |
1195 } | 1184 } |
1196 | 1185 |
1197 SurfacelessEGL::~SurfacelessEGL() { | 1186 SurfacelessEGL::~SurfacelessEGL() { |
1198 } | 1187 } |
1199 | 1188 |
1200 } // namespace gl | 1189 } // namespace gl |
OLD | NEW |