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 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/string_number_conversions.h" | |
16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
19 #include "ui/gl/egl_util.h" | 20 #include "ui/gl/egl_util.h" |
20 #include "ui/gl/gl_context.h" | 21 #include "ui/gl/gl_context.h" |
21 #include "ui/gl/gl_implementation.h" | 22 #include "ui/gl/gl_implementation.h" |
22 #include "ui/gl/gl_surface_stub.h" | 23 #include "ui/gl/gl_surface_stub.h" |
23 #include "ui/gl/gl_switches.h" | 24 #include "ui/gl/gl_switches.h" |
24 #include "ui/gl/scoped_make_current.h" | 25 #include "ui/gl/scoped_make_current.h" |
25 #include "ui/gl/sync_control_vsync_provider.h" | 26 #include "ui/gl/sync_control_vsync_provider.h" |
26 | 27 |
27 #if defined(USE_X11) | 28 #if defined(USE_X11) |
28 extern "C" { | 29 extern "C" { |
29 #include <X11/Xlib.h> | 30 #include <X11/Xlib.h> |
30 } | 31 } |
31 #endif | 32 #endif |
32 | 33 |
33 #if defined (USE_OZONE) | 34 #if defined (USE_OZONE) |
34 #include "ui/ozone/public/ozone_platform.h" | 35 #include "ui/ozone/public/ozone_platform.h" |
35 #include "ui/ozone/public/surface_factory_ozone.h" | 36 #include "ui/ozone/public/surface_factory_ozone.h" |
36 #endif | 37 #endif |
37 | 38 |
39 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
40 #include "ui/gfx/x/x11_switches.h" | |
41 #endif | |
42 | |
38 #if !defined(EGL_FIXED_SIZE_ANGLE) | 43 #if !defined(EGL_FIXED_SIZE_ANGLE) |
39 #define EGL_FIXED_SIZE_ANGLE 0x3201 | 44 #define EGL_FIXED_SIZE_ANGLE 0x3201 |
40 #endif | 45 #endif |
41 | 46 |
42 #if !defined(EGL_OPENGL_ES3_BIT) | 47 #if !defined(EGL_OPENGL_ES3_BIT) |
43 #define EGL_OPENGL_ES3_BIT 0x00000040 | 48 #define EGL_OPENGL_ES3_BIT 0x00000040 |
44 #endif | 49 #endif |
45 | 50 |
46 // From ANGLE's egl/eglext.h. | 51 // From ANGLE's egl/eglext.h. |
47 | 52 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 if (g_display == EGL_NO_DISPLAY) | 271 if (g_display == EGL_NO_DISPLAY) |
267 return false; | 272 return false; |
268 | 273 |
269 // Choose an EGL configuration. | 274 // Choose an EGL configuration. |
270 // On X this is only used for PBuffer surfaces. | 275 // On X this is only used for PBuffer surfaces. |
271 EGLint renderable_type = EGL_OPENGL_ES2_BIT; | 276 EGLint renderable_type = EGL_OPENGL_ES2_BIT; |
272 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 277 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
273 switches::kEnableUnsafeES3APIs)) { | 278 switches::kEnableUnsafeES3APIs)) { |
274 renderable_type = EGL_OPENGL_ES3_BIT; | 279 renderable_type = EGL_OPENGL_ES3_BIT; |
275 } | 280 } |
281 | |
282 EGLint buffer_size = 32; | |
283 EGLint alpha_size = 8; | |
284 | |
285 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
286 bool succeed = | |
287 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kWindowDepth); | |
288 DCHECK(succeed); | |
piman
2015/11/20 01:44:41
This code may be called outside of the full chrome
Julien Isorce Samsung
2015/11/20 09:13:56
Ah ok, thx. At minimum I'll add a if.
| |
289 | |
290 std::string depth = | |
291 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
292 switches::kWindowDepth); | |
293 succeed = base::StringToInt(depth, &buffer_size); | |
294 DCHECK(succeed); | |
295 | |
296 alpha_size = buffer_size == 32 ? 8 : 0; | |
297 #endif | |
298 | |
276 const EGLint kConfigAttribs[] = { | 299 const EGLint kConfigAttribs[] = { |
277 EGL_BUFFER_SIZE, 32, | 300 EGL_BUFFER_SIZE, buffer_size, |
278 EGL_ALPHA_SIZE, 8, | 301 EGL_ALPHA_SIZE, alpha_size, |
279 EGL_BLUE_SIZE, 8, | 302 EGL_BLUE_SIZE, 8, |
280 EGL_GREEN_SIZE, 8, | 303 EGL_GREEN_SIZE, 8, |
281 EGL_RED_SIZE, 8, | 304 EGL_RED_SIZE, 8, |
282 EGL_RENDERABLE_TYPE, renderable_type, | 305 EGL_RENDERABLE_TYPE, renderable_type, |
283 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | 306 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
284 EGL_NONE | 307 EGL_NONE |
285 }; | 308 }; |
286 | 309 |
287 #if defined(USE_OZONE) | 310 #if defined(USE_OZONE) |
288 const EGLint* config_attribs = ui::OzonePlatform::GetInstance() | 311 const EGLint* config_attribs = ui::OzonePlatform::GetInstance() |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 } | 937 } |
915 | 938 |
916 void* SurfacelessEGL::GetShareHandle() { | 939 void* SurfacelessEGL::GetShareHandle() { |
917 return NULL; | 940 return NULL; |
918 } | 941 } |
919 | 942 |
920 SurfacelessEGL::~SurfacelessEGL() { | 943 SurfacelessEGL::~SurfacelessEGL() { |
921 } | 944 } |
922 | 945 |
923 } // namespace gfx | 946 } // namespace gfx |
OLD | NEW |