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

Side by Side Diff: ui/gfx/gl/gl_surface_egl.cc

Issue 7467007: Adding Wayland support for ui/gfx (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Adding missing WaylandDisplay include Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/gl/gl_surface_egl.h ('k') | ui/gfx/gl/gl_surface_wayland.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/gl/gl_surface_egl.h" 5 #include "ui/gfx/gl/gl_surface_egl.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/angle/include/EGL/egl.h" 10 #include "third_party/angle/include/EGL/egl.h"
11 #include "third_party/angle/include/EGL/eglext.h" 11 #include "third_party/angle/include/EGL/eglext.h"
12 #include "ui/gfx/gl/egl_util.h" 12 #include "ui/gfx/gl/egl_util.h"
13 13
14 // This header must come after the above third-party include, as 14 // This header must come after the above third-party include, as
15 // it brings in #defines that cause conflicts. 15 // it brings in #defines that cause conflicts.
16 #include "ui/gfx/gl/gl_bindings.h" 16 #include "ui/gfx/gl/gl_bindings.h"
17 17
18 #if defined(USE_X11) 18 #if defined(USE_X11) && !defined(USE_WAYLAND)
19 extern "C" { 19 extern "C" {
20 #include <X11/Xlib.h> 20 #include <X11/Xlib.h>
21 } 21 }
22 #endif 22 #endif
23 23
24 #if defined(USE_WAYLAND)
25 #include "ui/wayland/wayland_display.h"
26 #endif
27
24 namespace gfx { 28 namespace gfx {
25 29
26 namespace { 30 namespace {
27 EGLConfig g_config; 31 EGLConfig g_config;
28 EGLDisplay g_display; 32 EGLDisplay g_display;
29 EGLNativeDisplayType g_native_display; 33 EGLNativeDisplayType g_native_display;
30 EGLConfig g_software_config; 34 EGLConfig g_software_config;
31 EGLDisplay g_software_display; 35 EGLDisplay g_software_display;
32 EGLNativeDisplayType g_software_native_display; 36 EGLNativeDisplayType g_software_native_display;
33 } 37 }
34 38
35 GLSurfaceEGL::GLSurfaceEGL() { 39 GLSurfaceEGL::GLSurfaceEGL() {
36 } 40 }
37 41
38 GLSurfaceEGL::~GLSurfaceEGL() { 42 GLSurfaceEGL::~GLSurfaceEGL() {
39 } 43 }
40 44
41 bool GLSurfaceEGL::InitializeOneOff() { 45 bool GLSurfaceEGL::InitializeOneOff() {
42 static bool initialized = false; 46 static bool initialized = false;
43 if (initialized) 47 if (initialized)
44 return true; 48 return true;
45 49
46 #if defined(USE_X11) 50 #if defined(USE_WAYLAND)
51 g_native_display = ui::WaylandDisplay::Connect(NULL)->display();
52 #elif defined(USE_X11)
47 g_native_display = XOpenDisplay(NULL); 53 g_native_display = XOpenDisplay(NULL);
48 #else 54 #else
49 g_native_display = EGL_DEFAULT_DISPLAY; 55 g_native_display = EGL_DEFAULT_DISPLAY;
50 #endif 56 #endif
51 g_display = eglGetDisplay(g_native_display); 57 g_display = eglGetDisplay(g_native_display);
52 if (!g_display) { 58 if (!g_display) {
53 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); 59 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString();
54 return false; 60 return false;
55 } 61 }
56 62
57 if (!eglInitialize(g_display, NULL, NULL)) { 63 if (!eglInitialize(g_display, NULL, NULL)) {
58 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); 64 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString();
59 return false; 65 return false;
60 } 66 }
61 67
62 // Choose an EGL configuration. 68 // Choose an EGL configuration.
63 static const EGLint kConfigAttribs[] = { 69 static const EGLint kConfigAttribs[] = {
64 EGL_BUFFER_SIZE, 32, 70 EGL_BUFFER_SIZE, 32,
65 EGL_ALPHA_SIZE, 8, 71 EGL_ALPHA_SIZE, 8,
66 EGL_BLUE_SIZE, 8, 72 EGL_BLUE_SIZE, 8,
67 EGL_GREEN_SIZE, 8, 73 EGL_GREEN_SIZE, 8,
68 EGL_RED_SIZE, 8, 74 EGL_RED_SIZE, 8,
69 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 75 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
70 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, 76 EGL_SURFACE_TYPE, EGL_WINDOW_BIT
77 #if defined(USE_WAYLAND)
78 | EGL_PIXMAP_BIT,
79 #else
80 | EGL_PBUFFER_BIT,
81 #endif
71 EGL_NONE 82 EGL_NONE
72 }; 83 };
73 84
74 EGLint num_configs; 85 EGLint num_configs;
75 if (!eglChooseConfig(g_display, 86 if (!eglChooseConfig(g_display,
76 kConfigAttribs, 87 kConfigAttribs,
77 NULL, 88 NULL,
78 0, 89 0,
79 &num_configs)) { 90 &num_configs)) {
80 LOG(ERROR) << "eglChooseConfig failed failed with error " 91 LOG(ERROR) << "eglChooseConfig failed failed with error "
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 305
295 gfx::Size PbufferGLSurfaceEGL::GetSize() { 306 gfx::Size PbufferGLSurfaceEGL::GetSize() {
296 return size_; 307 return size_;
297 } 308 }
298 309
299 EGLSurface PbufferGLSurfaceEGL::GetHandle() { 310 EGLSurface PbufferGLSurfaceEGL::GetHandle() {
300 return surface_; 311 return surface_;
301 } 312 }
302 313
303 } // namespace gfx 314 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_surface_egl.h ('k') | ui/gfx/gl/gl_surface_wayland.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698