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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); | 171 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
172 display_attribs.push_back(platform_type); | 172 display_attribs.push_back(platform_type); |
173 | 173 |
174 if (warpDevice) { | 174 if (warpDevice) { |
175 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); | 175 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); |
176 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); | 176 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); |
177 } | 177 } |
178 | 178 |
179 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 179 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
180 std::string visualid_str = | 180 Visual* visual; |
181 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 181 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
182 switches::kX11VisualID); | 182 true, &visual, nullptr, nullptr, nullptr); |
183 unsigned int visualid = 0; | |
184 bool succeed = base::StringToUint(visualid_str, &visualid); | |
185 DCHECK(succeed); | |
186 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); | 183 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); |
187 display_attribs.push_back((EGLint)visualid); | 184 display_attribs.push_back(static_cast<EGLint>(XVisualIDFromVisual(visual))); |
188 #endif | 185 #endif |
189 | 186 |
190 display_attribs.push_back(EGL_NONE); | 187 display_attribs.push_back(EGL_NONE); |
191 | 188 |
192 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, | 189 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
193 reinterpret_cast<void*>(native_display), | 190 reinterpret_cast<void*>(native_display), |
194 &display_attribs[0]); | 191 &display_attribs[0]); |
195 } | 192 } |
196 | 193 |
197 EGLDisplay GetDisplayFromType(DisplayType display_type, | 194 EGLDisplay GetDisplayFromType(DisplayType display_type, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 260 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
264 switches::kEnableUnsafeES3APIs)) { | 261 switches::kEnableUnsafeES3APIs)) { |
265 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 262 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
266 } | 263 } |
267 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 264 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
268 | 265 |
269 EGLint buffer_size = 32; | 266 EGLint buffer_size = 32; |
270 EGLint alpha_size = 8; | 267 EGLint alpha_size = 8; |
271 | 268 |
272 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 269 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
273 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 270 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
274 switches::kWindowDepth)) { | 271 true, nullptr, &buffer_size, nullptr, nullptr); |
275 std::string depth = | 272 alpha_size = buffer_size == 32 ? 8 : 0; |
276 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
277 switches::kWindowDepth); | |
278 | |
279 bool succeed = base::StringToInt(depth, &buffer_size); | |
280 DCHECK(succeed); | |
281 | |
282 alpha_size = buffer_size == 32 ? 8 : 0; | |
283 } | |
284 #endif | 273 #endif |
285 | 274 |
286 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) | 275 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) |
287 ? EGL_DONT_CARE | 276 ? EGL_DONT_CARE |
288 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; | 277 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; |
289 | 278 |
290 for (auto renderable_type : renderable_types) { | 279 for (auto renderable_type : renderable_types) { |
291 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 280 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
292 buffer_size, | 281 buffer_size, |
293 EGL_ALPHA_SIZE, | 282 EGL_ALPHA_SIZE, |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 } | 1190 } |
1202 | 1191 |
1203 void* SurfacelessEGL::GetShareHandle() { | 1192 void* SurfacelessEGL::GetShareHandle() { |
1204 return NULL; | 1193 return NULL; |
1205 } | 1194 } |
1206 | 1195 |
1207 SurfacelessEGL::~SurfacelessEGL() { | 1196 SurfacelessEGL::~SurfacelessEGL() { |
1208 } | 1197 } |
1209 | 1198 |
1210 } // namespace gl | 1199 } // namespace gl |
OLD | NEW |