| 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 11 matching lines...) Expand all Loading... |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 24 #include "ui/gl/egl_util.h" | 24 #include "ui/gl/egl_util.h" |
| 25 #include "ui/gl/gl_context.h" | 25 #include "ui/gl/gl_context.h" |
| 26 #include "ui/gl/gl_context_egl.h" | 26 #include "ui/gl/gl_context_egl.h" |
| 27 #include "ui/gl/gl_image.h" | 27 #include "ui/gl/gl_image.h" |
| 28 #include "ui/gl/gl_implementation.h" | 28 #include "ui/gl/gl_implementation.h" |
| 29 #include "ui/gl/gl_surface_stub.h" | 29 #include "ui/gl/gl_surface_stub.h" |
| 30 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
| 31 #include "ui/gl/scoped_make_current.h" | 31 #include "ui/gl/scoped_make_current.h" |
| 32 #include "ui/gl/sync_control_vsync_provider.h" | |
| 33 | 32 |
| 34 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 33 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 35 extern "C" { | 34 extern "C" { |
| 36 #include <X11/Xlib.h> | 35 #include <X11/Xlib.h> |
| 37 #define Status int | 36 #define Status int |
| 38 } | 37 } |
| 39 #include "ui/base/x/x11_util_internal.h" // nogncheck | 38 #include "ui/base/x/x11_util_internal.h" // nogncheck |
| 40 #endif | 39 #endif |
| 41 | 40 |
| 42 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 EGLNativeDisplayType g_native_display = EGL_DEFAULT_DISPLAY; | 120 EGLNativeDisplayType g_native_display = EGL_DEFAULT_DISPLAY; |
| 122 | 121 |
| 123 const char* g_egl_extensions = nullptr; | 122 const char* g_egl_extensions = nullptr; |
| 124 bool g_egl_create_context_robustness_supported = false; | 123 bool g_egl_create_context_robustness_supported = false; |
| 125 bool g_egl_sync_control_supported = false; | 124 bool g_egl_sync_control_supported = false; |
| 126 bool g_egl_window_fixed_size_supported = false; | 125 bool g_egl_window_fixed_size_supported = false; |
| 127 bool g_egl_surfaceless_context_supported = false; | 126 bool g_egl_surfaceless_context_supported = false; |
| 128 bool g_egl_surface_orientation_supported = false; | 127 bool g_egl_surface_orientation_supported = false; |
| 129 bool g_use_direct_composition = false; | 128 bool g_use_direct_composition = false; |
| 130 | 129 |
| 131 class EGLSyncControlVSyncProvider : public SyncControlVSyncProvider { | |
| 132 public: | |
| 133 explicit EGLSyncControlVSyncProvider(EGLSurface surface) | |
| 134 : SyncControlVSyncProvider(), | |
| 135 surface_(surface) { | |
| 136 } | |
| 137 | |
| 138 ~EGLSyncControlVSyncProvider() override {} | |
| 139 | |
| 140 protected: | |
| 141 bool GetSyncValues(int64_t* system_time, | |
| 142 int64_t* media_stream_counter, | |
| 143 int64_t* swap_buffer_counter) override { | |
| 144 uint64_t u_system_time, u_media_stream_counter, u_swap_buffer_counter; | |
| 145 bool result = eglGetSyncValuesCHROMIUM( | |
| 146 g_display, surface_, &u_system_time, | |
| 147 &u_media_stream_counter, &u_swap_buffer_counter) == EGL_TRUE; | |
| 148 if (result) { | |
| 149 *system_time = static_cast<int64_t>(u_system_time); | |
| 150 *media_stream_counter = static_cast<int64_t>(u_media_stream_counter); | |
| 151 *swap_buffer_counter = static_cast<int64_t>(u_swap_buffer_counter); | |
| 152 } | |
| 153 return result; | |
| 154 } | |
| 155 | |
| 156 bool GetMscRate(int32_t* numerator, int32_t* denominator) override { | |
| 157 return false; | |
| 158 } | |
| 159 | |
| 160 private: | |
| 161 EGLSurface surface_; | |
| 162 | |
| 163 DISALLOW_COPY_AND_ASSIGN(EGLSyncControlVSyncProvider); | |
| 164 }; | |
| 165 | |
| 166 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, | 130 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, |
| 167 EGLenum platform_type, | 131 EGLenum platform_type, |
| 168 bool warpDevice) { | 132 bool warpDevice) { |
| 169 std::vector<EGLint> display_attribs; | 133 std::vector<EGLint> display_attribs; |
| 170 | 134 |
| 171 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); | 135 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
| 172 display_attribs.push_back(platform_type); | 136 display_attribs.push_back(platform_type); |
| 173 | 137 |
| 174 if (warpDevice) { | 138 if (warpDevice) { |
| 175 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); | 139 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 394 } |
| 431 } | 395 } |
| 432 | 396 |
| 433 // If no displays are available due to missing angle extensions or invalid | 397 // If no displays are available due to missing angle extensions or invalid |
| 434 // flags, request the default display. | 398 // flags, request the default display. |
| 435 if (init_displays->empty()) { | 399 if (init_displays->empty()) { |
| 436 init_displays->push_back(DEFAULT); | 400 init_displays->push_back(DEFAULT); |
| 437 } | 401 } |
| 438 } | 402 } |
| 439 | 403 |
| 404 EGLSyncControlVSyncProvider::EGLSyncControlVSyncProvider(EGLSurface surface) |
| 405 : SyncControlVSyncProvider(), surface_(surface) {} |
| 406 |
| 407 EGLSyncControlVSyncProvider::~EGLSyncControlVSyncProvider() {} |
| 408 |
| 409 bool EGLSyncControlVSyncProvider::GetSyncValues(int64_t* system_time, |
| 410 int64_t* media_stream_counter, |
| 411 int64_t* swap_buffer_counter) { |
| 412 uint64_t u_system_time, u_media_stream_counter, u_swap_buffer_counter; |
| 413 bool result = eglGetSyncValuesCHROMIUM(g_display, surface_, &u_system_time, |
| 414 &u_media_stream_counter, |
| 415 &u_swap_buffer_counter) == EGL_TRUE; |
| 416 if (result) { |
| 417 *system_time = static_cast<int64_t>(u_system_time); |
| 418 *media_stream_counter = static_cast<int64_t>(u_media_stream_counter); |
| 419 *swap_buffer_counter = static_cast<int64_t>(u_swap_buffer_counter); |
| 420 } |
| 421 return result; |
| 422 } |
| 423 |
| 424 bool EGLSyncControlVSyncProvider::GetMscRate(int32_t* numerator, |
| 425 int32_t* denominator) { |
| 426 return false; |
| 427 } |
| 428 |
| 440 GLSurfaceEGL::GLSurfaceEGL() {} | 429 GLSurfaceEGL::GLSurfaceEGL() {} |
| 441 | 430 |
| 442 GLSurface::Format GLSurfaceEGL::GetFormat() { | 431 GLSurface::Format GLSurfaceEGL::GetFormat() { |
| 443 return format_; | 432 return format_; |
| 444 } | 433 } |
| 445 | 434 |
| 446 EGLDisplay GLSurfaceEGL::GetDisplay() { | 435 EGLDisplay GLSurfaceEGL::GetDisplay() { |
| 447 return g_display; | 436 return g_display; |
| 448 } | 437 } |
| 449 | 438 |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 } | 1179 } |
| 1191 | 1180 |
| 1192 void* SurfacelessEGL::GetShareHandle() { | 1181 void* SurfacelessEGL::GetShareHandle() { |
| 1193 return NULL; | 1182 return NULL; |
| 1194 } | 1183 } |
| 1195 | 1184 |
| 1196 SurfacelessEGL::~SurfacelessEGL() { | 1185 SurfacelessEGL::~SurfacelessEGL() { |
| 1197 } | 1186 } |
| 1198 | 1187 |
| 1199 } // namespace gl | 1188 } // namespace gl |
| OLD | NEW |