| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ozone/platform/x11/x11_surface_factory.h" | 5 #include "ui/ozone/platform/x11/x11_surface_factory.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "third_party/khronos/EGL/egl.h" | 10 #include "third_party/khronos/EGL/egl.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 8, | 61 8, |
| 62 EGL_BLUE_SIZE, | 62 EGL_BLUE_SIZE, |
| 63 8, | 63 8, |
| 64 EGL_GREEN_SIZE, | 64 EGL_GREEN_SIZE, |
| 65 8, | 65 8, |
| 66 EGL_RED_SIZE, | 66 EGL_RED_SIZE, |
| 67 8, | 67 8, |
| 68 EGL_RENDERABLE_TYPE, | 68 EGL_RENDERABLE_TYPE, |
| 69 EGL_OPENGL_ES2_BIT, | 69 EGL_OPENGL_ES2_BIT, |
| 70 EGL_SURFACE_TYPE, | 70 EGL_SURFACE_TYPE, |
| 71 EGL_WINDOW_BIT, | 71 EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
| 72 EGL_NONE}; | 72 EGL_NONE}; |
| 73 | 73 |
| 74 // Get the depth of XWindow for surface | 74 // Get the depth of XWindow for surface |
| 75 XWindowAttributes win_attribs; | 75 XWindowAttributes win_attribs; |
| 76 if (XGetWindowAttributes(gfx::GetXDisplay(), widget_, &win_attribs)) { | 76 if (XGetWindowAttributes(gfx::GetXDisplay(), widget_, &win_attribs)) { |
| 77 config_attribs[kBufferSizeOffset] = win_attribs.depth; | 77 config_attribs[kBufferSizeOffset] = win_attribs.depth; |
| 78 } | 78 } |
| 79 | 79 |
| 80 EGLint num_configs; | 80 EGLint num_configs; |
| 81 if (!egl.choose_config.Run(config_attribs, &config, 1, &num_configs)) { | 81 if (!egl.choose_config.Run(config_attribs, &config, 1, &num_configs)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 gfx::AcceleratedWidget widget) { | 119 gfx::AcceleratedWidget widget) { |
| 120 return make_scoped_ptr(new X11SurfaceEGL(widget)); | 120 return make_scoped_ptr(new X11SurfaceEGL(widget)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool X11SurfaceFactory::LoadEGLGLES2Bindings( | 123 bool X11SurfaceFactory::LoadEGLGLES2Bindings( |
| 124 AddGLLibraryCallback add_gl_library, | 124 AddGLLibraryCallback add_gl_library, |
| 125 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 125 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
| 126 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); | 126 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); |
| 127 } | 127 } |
| 128 | 128 |
| 129 const int32_t* X11SurfaceFactory::GetEGLSurfaceProperties( |
| 130 const int32_t* desired_list) { |
| 131 static const EGLint kConfigAttribs[] = {EGL_BUFFER_SIZE, |
| 132 32, |
| 133 EGL_ALPHA_SIZE, |
| 134 8, |
| 135 EGL_BLUE_SIZE, |
| 136 8, |
| 137 EGL_GREEN_SIZE, |
| 138 8, |
| 139 EGL_RED_SIZE, |
| 140 8, |
| 141 EGL_RENDERABLE_TYPE, |
| 142 EGL_OPENGL_ES2_BIT, |
| 143 EGL_SURFACE_TYPE, |
| 144 EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
| 145 EGL_NONE}; |
| 146 return kConfigAttribs; |
| 147 } |
| 148 |
| 129 intptr_t X11SurfaceFactory::GetNativeDisplay() { | 149 intptr_t X11SurfaceFactory::GetNativeDisplay() { |
| 130 return reinterpret_cast<intptr_t>(gfx::GetXDisplay()); | 150 return reinterpret_cast<intptr_t>(gfx::GetXDisplay()); |
| 131 } | 151 } |
| 132 | 152 |
| 133 } // namespace ui | 153 } // namespace ui |
| OLD | NEW |