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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EGLNativeDisplayType g_native_display; | 119 EGLNativeDisplayType g_native_display; |
120 | 120 |
121 const char* g_egl_extensions = NULL; | 121 const char* g_egl_extensions = NULL; |
122 bool g_egl_create_context_robustness_supported = false; | 122 bool g_egl_create_context_robustness_supported = false; |
123 bool g_egl_sync_control_supported = false; | 123 bool g_egl_sync_control_supported = false; |
124 bool g_egl_window_fixed_size_supported = false; | 124 bool g_egl_window_fixed_size_supported = false; |
125 bool g_egl_surfaceless_context_supported = false; | 125 bool g_egl_surfaceless_context_supported = false; |
126 bool g_egl_surface_orientation_supported = false; | 126 bool g_egl_surface_orientation_supported = false; |
127 bool g_use_direct_composition = false; | 127 bool g_use_direct_composition = false; |
128 | 128 |
129 class EGLSyncControlVSyncProvider : public gl::SyncControlVSyncProvider { | 129 class EGLSyncControlVSyncProvider : public SyncControlVSyncProvider { |
130 public: | 130 public: |
131 explicit EGLSyncControlVSyncProvider(EGLSurface surface) | 131 explicit EGLSyncControlVSyncProvider(EGLSurface surface) |
132 : SyncControlVSyncProvider(), | 132 : SyncControlVSyncProvider(), |
133 surface_(surface) { | 133 surface_(surface) { |
134 } | 134 } |
135 | 135 |
136 ~EGLSyncControlVSyncProvider() override {} | 136 ~EGLSyncControlVSyncProvider() override {} |
137 | 137 |
138 protected: | 138 protected: |
139 bool GetSyncValues(int64_t* system_time, | 139 bool GetSyncValues(int64_t* system_time, |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 655 |
656 if (g_egl_window_fixed_size_supported && enable_fixed_size_angle_) { | 656 if (g_egl_window_fixed_size_supported && enable_fixed_size_angle_) { |
657 egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); | 657 egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); |
658 egl_window_attributes.push_back(EGL_TRUE); | 658 egl_window_attributes.push_back(EGL_TRUE); |
659 egl_window_attributes.push_back(EGL_WIDTH); | 659 egl_window_attributes.push_back(EGL_WIDTH); |
660 egl_window_attributes.push_back(size_.width()); | 660 egl_window_attributes.push_back(size_.width()); |
661 egl_window_attributes.push_back(EGL_HEIGHT); | 661 egl_window_attributes.push_back(EGL_HEIGHT); |
662 egl_window_attributes.push_back(size_.height()); | 662 egl_window_attributes.push_back(size_.height()); |
663 } | 663 } |
664 | 664 |
665 if (gl::g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { | 665 if (g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { |
666 egl_window_attributes.push_back(EGL_POST_SUB_BUFFER_SUPPORTED_NV); | 666 egl_window_attributes.push_back(EGL_POST_SUB_BUFFER_SUPPORTED_NV); |
667 egl_window_attributes.push_back(EGL_TRUE); | 667 egl_window_attributes.push_back(EGL_TRUE); |
668 } | 668 } |
669 | 669 |
670 if (g_egl_surface_orientation_supported) { | 670 if (g_egl_surface_orientation_supported) { |
671 EGLint attrib; | 671 EGLint attrib; |
672 eglGetConfigAttrib(GetDisplay(), GetConfig(), | 672 eglGetConfigAttrib(GetDisplay(), GetConfig(), |
673 EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &attrib); | 673 EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &attrib); |
674 flips_vertically_ = (attrib == EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE); | 674 flips_vertically_ = (attrib == EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE); |
675 } | 675 } |
(...skipping 16 matching lines...) Expand all Loading... |
692 surface_ = eglCreateWindowSurface( | 692 surface_ = eglCreateWindowSurface( |
693 GetDisplay(), GetConfig(), window_, &egl_window_attributes[0]); | 693 GetDisplay(), GetConfig(), window_, &egl_window_attributes[0]); |
694 | 694 |
695 if (!surface_) { | 695 if (!surface_) { |
696 LOG(ERROR) << "eglCreateWindowSurface failed with error " | 696 LOG(ERROR) << "eglCreateWindowSurface failed with error " |
697 << GetLastEGLErrorString(); | 697 << GetLastEGLErrorString(); |
698 Destroy(); | 698 Destroy(); |
699 return false; | 699 return false; |
700 } | 700 } |
701 | 701 |
702 if (gl::g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { | 702 if (g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { |
703 EGLint surfaceVal; | 703 EGLint surfaceVal; |
704 EGLBoolean retVal = eglQuerySurface( | 704 EGLBoolean retVal = eglQuerySurface( |
705 GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal); | 705 GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal); |
706 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; | 706 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; |
707 } | 707 } |
708 | 708 |
709 if (sync_provider) | 709 if (sync_provider) |
710 vsync_provider_.reset(sync_provider.release()); | 710 vsync_provider_.reset(sync_provider.release()); |
711 else if (g_egl_sync_control_supported) | 711 else if (g_egl_sync_control_supported) |
712 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_)); | 712 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_)); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 : gfx::SwapResult::SWAP_FAILED; | 891 : gfx::SwapResult::SWAP_FAILED; |
892 } | 892 } |
893 | 893 |
894 gfx::VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { | 894 gfx::VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { |
895 return vsync_provider_.get(); | 895 return vsync_provider_.get(); |
896 } | 896 } |
897 | 897 |
898 bool NativeViewGLSurfaceEGL::ScheduleOverlayPlane( | 898 bool NativeViewGLSurfaceEGL::ScheduleOverlayPlane( |
899 int z_order, | 899 int z_order, |
900 gfx::OverlayTransform transform, | 900 gfx::OverlayTransform transform, |
901 gl::GLImage* image, | 901 GLImage* image, |
902 const gfx::Rect& bounds_rect, | 902 const gfx::Rect& bounds_rect, |
903 const gfx::RectF& crop_rect) { | 903 const gfx::RectF& crop_rect) { |
904 #if !defined(OS_ANDROID) | 904 #if !defined(OS_ANDROID) |
905 NOTIMPLEMENTED(); | 905 NOTIMPLEMENTED(); |
906 return false; | 906 return false; |
907 #else | 907 #else |
908 pending_overlays_.push_back( | 908 pending_overlays_.push_back( |
909 GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect)); | 909 GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect)); |
910 return true; | 910 return true; |
911 #endif | 911 #endif |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 | 1049 |
1050 EGLSurface PbufferGLSurfaceEGL::GetHandle() { | 1050 EGLSurface PbufferGLSurfaceEGL::GetHandle() { |
1051 return surface_; | 1051 return surface_; |
1052 } | 1052 } |
1053 | 1053 |
1054 void* PbufferGLSurfaceEGL::GetShareHandle() { | 1054 void* PbufferGLSurfaceEGL::GetShareHandle() { |
1055 #if defined(OS_ANDROID) | 1055 #if defined(OS_ANDROID) |
1056 NOTREACHED(); | 1056 NOTREACHED(); |
1057 return NULL; | 1057 return NULL; |
1058 #else | 1058 #else |
1059 if (!gl::g_driver_egl.ext.b_EGL_ANGLE_query_surface_pointer) | 1059 if (!g_driver_egl.ext.b_EGL_ANGLE_query_surface_pointer) |
1060 return NULL; | 1060 return NULL; |
1061 | 1061 |
1062 if (!gl::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle) | 1062 if (!g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle) |
1063 return NULL; | 1063 return NULL; |
1064 | 1064 |
1065 void* handle; | 1065 void* handle; |
1066 if (!eglQuerySurfacePointerANGLE(g_display, | 1066 if (!eglQuerySurfacePointerANGLE(g_display, |
1067 GetHandle(), | 1067 GetHandle(), |
1068 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, | 1068 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, |
1069 &handle)) { | 1069 &handle)) { |
1070 return NULL; | 1070 return NULL; |
1071 } | 1071 } |
1072 | 1072 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 } | 1124 } |
1125 | 1125 |
1126 void* SurfacelessEGL::GetShareHandle() { | 1126 void* SurfacelessEGL::GetShareHandle() { |
1127 return NULL; | 1127 return NULL; |
1128 } | 1128 } |
1129 | 1129 |
1130 SurfacelessEGL::~SurfacelessEGL() { | 1130 SurfacelessEGL::~SurfacelessEGL() { |
1131 } | 1131 } |
1132 | 1132 |
1133 } // namespace gl | 1133 } // namespace gl |
OLD | NEW |