| 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 #include "ui/gl/gl_surface_egl.h" | 5 #include "ui/gl/gl_surface_egl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
| 27 #include "ui/gl/gl_surface_stub.h" | 27 #include "ui/gl/gl_surface_stub.h" |
| 28 #include "ui/gl/gl_switches.h" | 28 #include "ui/gl/gl_switches.h" |
| 29 #include "ui/gl/scoped_make_current.h" | 29 #include "ui/gl/scoped_make_current.h" |
| 30 #include "ui/gl/sync_control_vsync_provider.h" | 30 #include "ui/gl/sync_control_vsync_provider.h" |
| 31 | 31 |
| 32 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
| 33 #include <android/native_window_jni.h> | 33 #include <android/native_window_jni.h> |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if defined(USE_OZONE) |
| 37 #include "ui/ozone/public/ozone_platform.h" |
| 38 #include "ui/ozone/public/surface_factory_ozone.h" |
| 39 #endif |
| 40 |
| 36 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 41 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 37 extern "C" { | 42 extern "C" { |
| 38 #include <X11/Xlib.h> | 43 #include <X11/Xlib.h> |
| 39 #define Status int | 44 #define Status int |
| 40 } | 45 } |
| 41 #include "ui/base/x/x11_util_internal.h" | 46 #include "ui/base/x/x11_util_internal.h" |
| 42 #include "ui/gfx/x/x11_switches.h" | 47 #include "ui/gfx/x/x11_switches.h" |
| 43 #endif | 48 #endif |
| 44 | 49 |
| 45 #if !defined(EGL_FIXED_SIZE_ANGLE) | 50 #if !defined(EGL_FIXED_SIZE_ANGLE) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 EGL_GREEN_SIZE, 6, | 306 EGL_GREEN_SIZE, 6, |
| 302 EGL_RED_SIZE, 5, | 307 EGL_RED_SIZE, 5, |
| 303 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, | 308 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| 304 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | 309 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
| 305 EGL_NONE | 310 EGL_NONE |
| 306 }; | 311 }; |
| 307 if (format == GLSurface::SURFACE_RGB565) { | 312 if (format == GLSurface::SURFACE_RGB565) { |
| 308 choose_attributes = config_attribs_565; | 313 choose_attributes = config_attribs_565; |
| 309 } | 314 } |
| 310 | 315 |
| 316 const EGLint* config_attribs; |
| 317 #if defined(USE_OZONE) |
| 318 config_attribs = ui::OzonePlatform::GetInstance() |
| 319 ->GetSurfaceFactoryOzone() |
| 320 ->GetEGLSurfaceProperties(choose_attributes); |
| 321 #else |
| 322 config_attribs = choose_attributes; |
| 323 #endif |
| 324 |
| 311 EGLint num_configs; | 325 EGLint num_configs; |
| 312 EGLint config_size = 1; | 326 EGLint config_size = 1; |
| 313 EGLConfig config = nullptr; | 327 EGLConfig config = nullptr; |
| 314 EGLConfig* config_data = &config; | 328 EGLConfig* config_data = &config; |
| 315 // Validate if there are any configs for given attribs. | 329 // Validate if there are any configs for given attribs. |
| 316 if (!ValidateEglConfig(g_display, choose_attributes, &num_configs)) { | 330 if (!ValidateEglConfig(g_display, config_attribs, &num_configs)) { |
| 317 return config; | 331 return config; |
| 318 } | 332 } |
| 319 | 333 |
| 320 scoped_ptr<EGLConfig[]> matching_configs(new EGLConfig[num_configs]); | 334 scoped_ptr<EGLConfig[]> matching_configs(new EGLConfig[num_configs]); |
| 321 if (format == GLSurface::SURFACE_RGB565) { | 335 if (format == GLSurface::SURFACE_RGB565) { |
| 322 config_size = num_configs; | 336 config_size = num_configs; |
| 323 config_data = matching_configs.get(); | 337 config_data = matching_configs.get(); |
| 324 } | 338 } |
| 325 | 339 |
| 326 if (!eglChooseConfig(g_display, choose_attributes, config_data, config_size, | 340 if (!eglChooseConfig(g_display, config_attribs, config_data, config_size, |
| 327 &num_configs)) { | 341 &num_configs)) { |
| 328 LOG(ERROR) << "eglChooseConfig failed with error " | 342 LOG(ERROR) << "eglChooseConfig failed with error " |
| 329 << GetLastEGLErrorString(); | 343 << GetLastEGLErrorString(); |
| 330 return config; | 344 return config; |
| 331 } | 345 } |
| 332 | 346 |
| 333 if (format == GLSurface::SURFACE_RGB565) { | 347 if (format == GLSurface::SURFACE_RGB565) { |
| 334 // Because of the EGL config sort order, we have to iterate | 348 // Because of the EGL config sort order, we have to iterate |
| 335 // through all of them (it'll put higher sum(R,G,B) bits | 349 // through all of them (it'll put higher sum(R,G,B) bits |
| 336 // first with the above attribs). | 350 // first with the above attribs). |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 } | 1121 } |
| 1108 | 1122 |
| 1109 void* SurfacelessEGL::GetShareHandle() { | 1123 void* SurfacelessEGL::GetShareHandle() { |
| 1110 return NULL; | 1124 return NULL; |
| 1111 } | 1125 } |
| 1112 | 1126 |
| 1113 SurfacelessEGL::~SurfacelessEGL() { | 1127 SurfacelessEGL::~SurfacelessEGL() { |
| 1114 } | 1128 } |
| 1115 | 1129 |
| 1116 } // namespace gfx | 1130 } // namespace gfx |
| OLD | NEW |