OLD | NEW |
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_context_egl.h" | 5 #include "ui/gfx/gl/gl_context_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 "ui/gfx/gl/gl_surface_egl.h" | |
12 #include "ui/gfx/gl/egl_util.h" | 11 #include "ui/gfx/gl/egl_util.h" |
| 12 #include "ui/gfx/gl/gl_surface.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) |
19 extern "C" { | 19 extern "C" { |
20 #include <X11/Xlib.h> | 20 #include <X11/Xlib.h> |
21 } | 21 } |
22 #endif | 22 #endif |
(...skipping 22 matching lines...) Expand all Loading... |
45 bool GLContextEGL::Initialize( | 45 bool GLContextEGL::Initialize( |
46 GLSurface* compatible_surface, GpuPreference gpu_preference) { | 46 GLSurface* compatible_surface, GpuPreference gpu_preference) { |
47 DCHECK(compatible_surface); | 47 DCHECK(compatible_surface); |
48 DCHECK(!context_); | 48 DCHECK(!context_); |
49 | 49 |
50 static const EGLint kContextAttributes[] = { | 50 static const EGLint kContextAttributes[] = { |
51 EGL_CONTEXT_CLIENT_VERSION, 2, | 51 EGL_CONTEXT_CLIENT_VERSION, 2, |
52 EGL_NONE | 52 EGL_NONE |
53 }; | 53 }; |
54 | 54 |
55 GLSurfaceEGL* egl_surface = static_cast<GLSurfaceEGL*>(compatible_surface); | 55 display_ = compatible_surface->GetDisplay(); |
56 display_ = egl_surface->GetDisplay(); | 56 config_ = compatible_surface->GetConfig(); |
57 config_ = egl_surface->GetConfig(); | |
58 | 57 |
59 context_ = eglCreateContext( | 58 context_ = eglCreateContext( |
60 display_, | 59 display_, |
61 config_, | 60 config_, |
62 share_group() ? share_group()->GetHandle() : NULL, | 61 share_group() ? share_group()->GetHandle() : NULL, |
63 kContextAttributes); | 62 kContextAttributes); |
64 if (!context_) { | 63 if (!context_) { |
65 LOG(ERROR) << "eglCreateContext failed with error " | 64 LOG(ERROR) << "eglCreateContext failed with error " |
66 << GetLastEGLErrorString(); | 65 << GetLastEGLErrorString(); |
67 Destroy(); | 66 Destroy(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 142 |
144 void GLContextEGL::SetSwapInterval(int interval) { | 143 void GLContextEGL::SetSwapInterval(int interval) { |
145 DCHECK(IsCurrent(NULL)); | 144 DCHECK(IsCurrent(NULL)); |
146 if (!eglSwapInterval(display_, interval)) { | 145 if (!eglSwapInterval(display_, interval)) { |
147 LOG(ERROR) << "eglSwapInterval failed with error " | 146 LOG(ERROR) << "eglSwapInterval failed with error " |
148 << GetLastEGLErrorString(); | 147 << GetLastEGLErrorString(); |
149 } | 148 } |
150 } | 149 } |
151 | 150 |
152 } // namespace gfx | 151 } // namespace gfx |
OLD | NEW |