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

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

Issue 10009024: Remove WAYLAND port (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 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_linux.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) 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/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 "base/message_loop.h" 10 #include "base/message_loop.h"
11 #if !defined(OS_ANDROID) 11 #if !defined(OS_ANDROID)
12 #include "third_party/angle/include/EGL/egl.h" 12 #include "third_party/angle/include/EGL/egl.h"
13 #include "third_party/angle/include/EGL/eglext.h" 13 #include "third_party/angle/include/EGL/eglext.h"
14 #endif 14 #endif
15 #include "ui/gfx/gl/egl_util.h" 15 #include "ui/gfx/gl/egl_util.h"
16 #include "ui/gfx/gl/gl_context.h" 16 #include "ui/gfx/gl/gl_context.h"
17 17
18 #if defined(OS_ANDROID) 18 #if defined(OS_ANDROID)
19 #include <EGL/egl.h> 19 #include <EGL/egl.h>
20 #endif 20 #endif
21 21
22 // This header must come after the above third-party include, as 22 // This header must come after the above third-party include, as
23 // it brings in #defines that cause conflicts. 23 // it brings in #defines that cause conflicts.
24 #include "ui/gfx/gl/gl_bindings.h" 24 #include "ui/gfx/gl/gl_bindings.h"
25 25
26 #if defined(USE_X11) && !defined(USE_WAYLAND) 26 #if defined(USE_X11)
27 extern "C" { 27 extern "C" {
28 #include <X11/Xlib.h> 28 #include <X11/Xlib.h>
29 } 29 }
30 #endif 30 #endif
31 31
32 #if defined(USE_WAYLAND)
33 #include "ui/wayland/wayland_display.h"
34 #endif
35
36 namespace gfx { 32 namespace gfx {
37 33
38 namespace { 34 namespace {
39 EGLConfig g_config; 35 EGLConfig g_config;
40 EGLDisplay g_display; 36 EGLDisplay g_display;
41 EGLNativeDisplayType g_native_display; 37 EGLNativeDisplayType g_native_display;
42 EGLConfig g_software_config; 38 EGLConfig g_software_config;
43 EGLDisplay g_software_display; 39 EGLDisplay g_software_display;
44 EGLNativeDisplayType g_software_native_display; 40 EGLNativeDisplayType g_software_native_display;
45 } 41 }
46 42
47 GLSurfaceEGL::GLSurfaceEGL() : software_(false) { 43 GLSurfaceEGL::GLSurfaceEGL() : software_(false) {
48 } 44 }
49 45
50 GLSurfaceEGL::~GLSurfaceEGL() { 46 GLSurfaceEGL::~GLSurfaceEGL() {
51 } 47 }
52 48
53 bool GLSurfaceEGL::InitializeOneOff() { 49 bool GLSurfaceEGL::InitializeOneOff() {
54 static bool initialized = false; 50 static bool initialized = false;
55 if (initialized) 51 if (initialized)
56 return true; 52 return true;
57 53
58 #if defined(USE_WAYLAND) 54 #if defined(USE_X11)
59 g_native_display = ui::WaylandDisplay::Connect(NULL)->display();
60 #elif defined(USE_X11)
61 g_native_display = base::MessagePumpForUI::GetDefaultXDisplay(); 55 g_native_display = base::MessagePumpForUI::GetDefaultXDisplay();
62 #else 56 #else
63 g_native_display = EGL_DEFAULT_DISPLAY; 57 g_native_display = EGL_DEFAULT_DISPLAY;
64 #endif 58 #endif
65 g_display = eglGetDisplay(g_native_display); 59 g_display = eglGetDisplay(g_native_display);
66 if (!g_display) { 60 if (!g_display) {
67 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); 61 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString();
68 return false; 62 return false;
69 } 63 }
70 64
71 if (!eglInitialize(g_display, NULL, NULL)) { 65 if (!eglInitialize(g_display, NULL, NULL)) {
72 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); 66 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString();
73 return false; 67 return false;
74 } 68 }
75 69
76 // Choose an EGL configuration. 70 // Choose an EGL configuration.
77 static const EGLint kConfigAttribs[] = { 71 static const EGLint kConfigAttribs[] = {
78 EGL_BUFFER_SIZE, 32, 72 EGL_BUFFER_SIZE, 32,
79 EGL_ALPHA_SIZE, 8, 73 EGL_ALPHA_SIZE, 8,
80 EGL_BLUE_SIZE, 8, 74 EGL_BLUE_SIZE, 8,
81 EGL_GREEN_SIZE, 8, 75 EGL_GREEN_SIZE, 8,
82 EGL_RED_SIZE, 8, 76 EGL_RED_SIZE, 8,
83 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 77 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
84 EGL_SURFACE_TYPE, EGL_WINDOW_BIT 78 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
85 #if defined(USE_WAYLAND)
86 | EGL_PIXMAP_BIT,
87 #else
88 | EGL_PBUFFER_BIT,
89 #endif
90 EGL_NONE 79 EGL_NONE
91 }; 80 };
92 81
93 EGLint num_configs; 82 EGLint num_configs;
94 if (!eglChooseConfig(g_display, 83 if (!eglChooseConfig(g_display,
95 kConfigAttribs, 84 kConfigAttribs,
96 NULL, 85 NULL,
97 0, 86 0,
98 &num_configs)) { 87 &num_configs)) {
99 LOG(ERROR) << "eglChooseConfig failed failed with error " 88 LOG(ERROR) << "eglChooseConfig failed failed with error "
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, 389 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE,
401 &handle)) { 390 &handle)) {
402 return NULL; 391 return NULL;
403 } 392 }
404 393
405 return handle; 394 return handle;
406 #endif 395 #endif
407 } 396 }
408 397
409 } // namespace gfx 398 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_surface_egl.h ('k') | ui/gfx/gl/gl_surface_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698