| 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 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 return config_; | 656 return config_; |
| 657 #endif | 657 #endif |
| 658 } | 658 } |
| 659 | 659 |
| 660 bool NativeViewGLSurfaceEGL::IsOffscreen() { | 660 bool NativeViewGLSurfaceEGL::IsOffscreen() { |
| 661 return false; | 661 return false; |
| 662 } | 662 } |
| 663 | 663 |
| 664 gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers() { | 664 bool NativeViewGLSurfaceEGL::SwapBuffers() { |
| 665 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", | 665 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", |
| 666 "width", GetSize().width(), | 666 "width", GetSize().width(), |
| 667 "height", GetSize().height()); | 667 "height", GetSize().height()); |
| 668 | 668 |
| 669 #if defined(OS_WIN) | 669 #if defined(OS_WIN) |
| 670 if (swap_interval_ != 0) { | 670 if (swap_interval_ != 0) { |
| 671 // This code is a simple way of enforcing that we only vsync if one surface | 671 // This code is a simple way of enforcing that we only vsync if one surface |
| 672 // is swapping per frame. This provides single window cases a stable refresh | 672 // is swapping per frame. This provides single window cases a stable refresh |
| 673 // while allowing multi-window cases to not slow down due to multiple syncs | 673 // while allowing multi-window cases to not slow down due to multiple syncs |
| 674 // on a single thread. A better way to fix this problem would be to have | 674 // on a single thread. A better way to fix this problem would be to have |
| (...skipping 22 matching lines...) Expand all Loading... |
| 697 vsync_override_ = false; | 697 vsync_override_ = false; |
| 698 } | 698 } |
| 699 | 699 |
| 700 swaps_this_generation_++; | 700 swaps_this_generation_++; |
| 701 } | 701 } |
| 702 #endif | 702 #endif |
| 703 | 703 |
| 704 if (!eglSwapBuffers(GetDisplay(), surface_)) { | 704 if (!eglSwapBuffers(GetDisplay(), surface_)) { |
| 705 DVLOG(1) << "eglSwapBuffers failed with error " | 705 DVLOG(1) << "eglSwapBuffers failed with error " |
| 706 << GetLastEGLErrorString(); | 706 << GetLastEGLErrorString(); |
| 707 return gfx::SwapResult::SWAP_FAILED; | 707 return false; |
| 708 } | 708 } |
| 709 | 709 |
| 710 return gfx::SwapResult::SWAP_ACK; | 710 return true; |
| 711 } | 711 } |
| 712 | 712 |
| 713 gfx::Size NativeViewGLSurfaceEGL::GetSize() { | 713 gfx::Size NativeViewGLSurfaceEGL::GetSize() { |
| 714 EGLint width; | 714 EGLint width; |
| 715 EGLint height; | 715 EGLint height; |
| 716 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || | 716 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || |
| 717 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { | 717 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { |
| 718 NOTREACHED() << "eglQuerySurface failed with error " | 718 NOTREACHED() << "eglQuerySurface failed with error " |
| 719 << GetLastEGLErrorString(); | 719 << GetLastEGLErrorString(); |
| 720 return gfx::Size(); | 720 return gfx::Size(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 } | 759 } |
| 760 | 760 |
| 761 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { | 761 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { |
| 762 return surface_; | 762 return surface_; |
| 763 } | 763 } |
| 764 | 764 |
| 765 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { | 765 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { |
| 766 return supports_post_sub_buffer_; | 766 return supports_post_sub_buffer_; |
| 767 } | 767 } |
| 768 | 768 |
| 769 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, | 769 bool NativeViewGLSurfaceEGL::PostSubBuffer( |
| 770 int y, | 770 int x, int y, int width, int height) { |
| 771 int width, | |
| 772 int height) { | |
| 773 DCHECK(supports_post_sub_buffer_); | 771 DCHECK(supports_post_sub_buffer_); |
| 774 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { | 772 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { |
| 775 DVLOG(1) << "eglPostSubBufferNV failed with error " | 773 DVLOG(1) << "eglPostSubBufferNV failed with error " |
| 776 << GetLastEGLErrorString(); | 774 << GetLastEGLErrorString(); |
| 777 return gfx::SwapResult::SWAP_FAILED; | 775 return false; |
| 778 } | 776 } |
| 779 return gfx::SwapResult::SWAP_ACK; | 777 return true; |
| 780 } | 778 } |
| 781 | 779 |
| 782 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { | 780 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { |
| 783 return vsync_provider_.get(); | 781 return vsync_provider_.get(); |
| 784 } | 782 } |
| 785 | 783 |
| 786 void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) { | 784 void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) { |
| 787 swap_interval_ = interval; | 785 swap_interval_ = interval; |
| 788 } | 786 } |
| 789 | 787 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 } | 848 } |
| 851 | 849 |
| 852 EGLConfig PbufferGLSurfaceEGL::GetConfig() { | 850 EGLConfig PbufferGLSurfaceEGL::GetConfig() { |
| 853 return g_config; | 851 return g_config; |
| 854 } | 852 } |
| 855 | 853 |
| 856 bool PbufferGLSurfaceEGL::IsOffscreen() { | 854 bool PbufferGLSurfaceEGL::IsOffscreen() { |
| 857 return true; | 855 return true; |
| 858 } | 856 } |
| 859 | 857 |
| 860 gfx::SwapResult PbufferGLSurfaceEGL::SwapBuffers() { | 858 bool PbufferGLSurfaceEGL::SwapBuffers() { |
| 861 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; | 859 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; |
| 862 return gfx::SwapResult::SWAP_FAILED; | 860 return false; |
| 863 } | 861 } |
| 864 | 862 |
| 865 gfx::Size PbufferGLSurfaceEGL::GetSize() { | 863 gfx::Size PbufferGLSurfaceEGL::GetSize() { |
| 866 return size_; | 864 return size_; |
| 867 } | 865 } |
| 868 | 866 |
| 869 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { | 867 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { |
| 870 if (size == size_) | 868 if (size == size_) |
| 871 return true; | 869 return true; |
| 872 | 870 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 } | 934 } |
| 937 | 935 |
| 938 bool SurfacelessEGL::IsOffscreen() { | 936 bool SurfacelessEGL::IsOffscreen() { |
| 939 return true; | 937 return true; |
| 940 } | 938 } |
| 941 | 939 |
| 942 bool SurfacelessEGL::IsSurfaceless() const { | 940 bool SurfacelessEGL::IsSurfaceless() const { |
| 943 return true; | 941 return true; |
| 944 } | 942 } |
| 945 | 943 |
| 946 gfx::SwapResult SurfacelessEGL::SwapBuffers() { | 944 bool SurfacelessEGL::SwapBuffers() { |
| 947 LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL."; | 945 LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL."; |
| 948 return gfx::SwapResult::SWAP_FAILED; | 946 return false; |
| 949 } | 947 } |
| 950 | 948 |
| 951 gfx::Size SurfacelessEGL::GetSize() { | 949 gfx::Size SurfacelessEGL::GetSize() { |
| 952 return size_; | 950 return size_; |
| 953 } | 951 } |
| 954 | 952 |
| 955 bool SurfacelessEGL::Resize(const gfx::Size& size) { | 953 bool SurfacelessEGL::Resize(const gfx::Size& size) { |
| 956 size_ = size; | 954 size_ = size; |
| 957 return true; | 955 return true; |
| 958 } | 956 } |
| 959 | 957 |
| 960 EGLSurface SurfacelessEGL::GetHandle() { | 958 EGLSurface SurfacelessEGL::GetHandle() { |
| 961 return EGL_NO_SURFACE; | 959 return EGL_NO_SURFACE; |
| 962 } | 960 } |
| 963 | 961 |
| 964 void* SurfacelessEGL::GetShareHandle() { | 962 void* SurfacelessEGL::GetShareHandle() { |
| 965 return NULL; | 963 return NULL; |
| 966 } | 964 } |
| 967 | 965 |
| 968 SurfacelessEGL::~SurfacelessEGL() { | 966 SurfacelessEGL::~SurfacelessEGL() { |
| 969 } | 967 } |
| 970 | 968 |
| 971 } // namespace gfx | 969 } // namespace gfx |
| OLD | NEW |