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 // This include must be here so that the includes provided transitively | 5 // This include must be here so that the includes provided transitively |
6 // by gl_surface_egl.h don't make it impossible to compile this code. | 6 // by gl_surface_egl.h don't make it impossible to compile this code. |
7 #include "third_party/mesa/src/include/GL/osmesa.h" | 7 #include "third_party/mesa/src/include/GL/osmesa.h" |
8 | 8 |
9 #include "ui/gl/gl_surface_egl.h" | 9 #include "ui/gl/gl_surface_egl.h" |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 GLSurfaceEGL::GLSurfaceEGL() {} | 96 GLSurfaceEGL::GLSurfaceEGL() {} |
97 | 97 |
98 bool GLSurfaceEGL::InitializeOneOff() { | 98 bool GLSurfaceEGL::InitializeOneOff() { |
99 static bool initialized = false; | 99 static bool initialized = false; |
100 if (initialized) | 100 if (initialized) |
101 return true; | 101 return true; |
102 | 102 |
103 #if defined (USE_OZONE) | |
104 ui::SurfaceFactoryOzone::GetInstance()->InitializeHardware(); | |
105 #endif | |
106 | |
107 #if defined(USE_X11) | 103 #if defined(USE_X11) |
108 g_native_display = base::MessagePumpForUI::GetDefaultXDisplay(); | 104 g_native_display = base::MessagePumpForUI::GetDefaultXDisplay(); |
109 #elif defined(OS_WIN) | 105 #elif defined(OS_WIN) |
110 g_native_display = EGL_DEFAULT_DISPLAY; | 106 g_native_display = EGL_DEFAULT_DISPLAY; |
111 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11)) { | 107 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11)) { |
112 g_native_display = EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE; | 108 g_native_display = EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE; |
113 } | 109 } |
| 110 #elif defined(USE_OZONE) |
| 111 if (!ui::SurfaceFactoryOzone::GetInstance()->InitializeHardware()) { |
| 112 LOG(ERROR) << "OZONE failed to initialize hardware"; |
| 113 return false; |
| 114 } |
| 115 g_native_display = ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); |
114 #else | 116 #else |
115 g_native_display = EGL_DEFAULT_DISPLAY; | 117 g_native_display = EGL_DEFAULT_DISPLAY; |
116 #endif | 118 #endif |
117 g_display = eglGetDisplay(g_native_display); | 119 g_display = eglGetDisplay(g_native_display); |
118 if (!g_display) { | 120 if (!g_display) { |
119 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); | 121 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); |
120 return false; | 122 return false; |
121 } | 123 } |
122 | 124 |
123 if (!eglInitialize(g_display, NULL, NULL)) { | 125 if (!eglInitialize(g_display, NULL, NULL)) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 return false; | 357 return false; |
356 } | 358 } |
357 | 359 |
358 bool NativeViewGLSurfaceEGL::SwapBuffers() { | 360 bool NativeViewGLSurfaceEGL::SwapBuffers() { |
359 if (!eglSwapBuffers(GetDisplay(), surface_)) { | 361 if (!eglSwapBuffers(GetDisplay(), surface_)) { |
360 DVLOG(1) << "eglSwapBuffers failed with error " | 362 DVLOG(1) << "eglSwapBuffers failed with error " |
361 << GetLastEGLErrorString(); | 363 << GetLastEGLErrorString(); |
362 return false; | 364 return false; |
363 } | 365 } |
364 | 366 |
| 367 #if defined(USE_OZONE) |
| 368 if (!ui::SurfaceFactoryOzone::GetInstance()->SwapBuffers(window_)) { |
| 369 DVLOG(1) << "Ozone failed to SwapBuffers"; |
| 370 return false; |
| 371 } |
| 372 #endif |
| 373 |
365 return true; | 374 return true; |
366 } | 375 } |
367 | 376 |
368 gfx::Size NativeViewGLSurfaceEGL::GetSize() { | 377 gfx::Size NativeViewGLSurfaceEGL::GetSize() { |
369 EGLint width; | 378 EGLint width; |
370 EGLint height; | 379 EGLint height; |
371 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || | 380 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || |
372 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { | 381 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { |
373 NOTREACHED() << "eglQuerySurface failed with error " | 382 NOTREACHED() << "eglQuerySurface failed with error " |
374 << GetLastEGLErrorString(); | 383 << GetLastEGLErrorString(); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 } | 683 } |
675 default: | 684 default: |
676 NOTREACHED(); | 685 NOTREACHED(); |
677 return NULL; | 686 return NULL; |
678 } | 687 } |
679 } | 688 } |
680 | 689 |
681 #endif | 690 #endif |
682 | 691 |
683 } // namespace gfx | 692 } // namespace gfx |
OLD | NEW |