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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 << GetLastEGLErrorString(); | 739 << GetLastEGLErrorString(); |
740 } | 740 } |
741 surface_ = NULL; | 741 surface_ = NULL; |
742 } | 742 } |
743 } | 743 } |
744 | 744 |
745 bool NativeViewGLSurfaceEGL::IsOffscreen() { | 745 bool NativeViewGLSurfaceEGL::IsOffscreen() { |
746 return false; | 746 return false; |
747 } | 747 } |
748 | 748 |
749 gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers() { | 749 void NativeViewGLSurfaceEGL::UpdateSwapInterval() { |
750 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", | |
751 "width", GetSize().width(), | |
752 "height", GetSize().height()); | |
753 | |
754 #if defined(OS_WIN) | 750 #if defined(OS_WIN) |
755 if (swap_interval_ != 0) { | 751 if (swap_interval_ != 0) { |
756 // This code is a simple way of enforcing that we only vsync if one surface | 752 // This code is a simple way of enforcing that we only vsync if one surface |
757 // is swapping per frame. This provides single window cases a stable refresh | 753 // is swapping per frame. This provides single window cases a stable refresh |
758 // while allowing multi-window cases to not slow down due to multiple syncs | 754 // while allowing multi-window cases to not slow down due to multiple syncs |
759 // on a single thread. A better way to fix this problem would be to have | 755 // on a single thread. A better way to fix this problem would be to have |
760 // each surface present on its own thread. | 756 // each surface present on its own thread. |
761 | 757 |
762 if (current_swap_generation_ == swap_generation_) { | 758 if (current_swap_generation_ == swap_generation_) { |
763 if (swaps_this_generation_ > 1) | 759 if (swaps_this_generation_ > 1) |
(...skipping 14 matching lines...) Expand all Loading... |
778 } | 774 } |
779 } else if (vsync_override_) { | 775 } else if (vsync_override_) { |
780 // Only one window swapping, so let the normal vsync setting take over | 776 // Only one window swapping, so let the normal vsync setting take over |
781 eglSwapInterval(GetDisplay(), swap_interval_); | 777 eglSwapInterval(GetDisplay(), swap_interval_); |
782 vsync_override_ = false; | 778 vsync_override_ = false; |
783 } | 779 } |
784 | 780 |
785 swaps_this_generation_++; | 781 swaps_this_generation_++; |
786 } | 782 } |
787 #endif | 783 #endif |
| 784 } |
| 785 |
| 786 gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers() { |
| 787 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", |
| 788 "width", GetSize().width(), |
| 789 "height", GetSize().height()); |
| 790 |
| 791 UpdateSwapInterval(); |
788 | 792 |
789 if (!CommitAndClearPendingOverlays()) { | 793 if (!CommitAndClearPendingOverlays()) { |
790 DVLOG(1) << "Failed to commit pending overlay planes."; | 794 DVLOG(1) << "Failed to commit pending overlay planes."; |
791 return gfx::SwapResult::SWAP_FAILED; | 795 return gfx::SwapResult::SWAP_FAILED; |
792 } | 796 } |
793 | 797 |
794 if (!eglSwapBuffers(GetDisplay(), surface_)) { | 798 if (!eglSwapBuffers(GetDisplay(), surface_)) { |
795 DVLOG(1) << "eglSwapBuffers failed with error " | 799 DVLOG(1) << "eglSwapBuffers failed with error " |
796 << GetLastEGLErrorString(); | 800 << GetLastEGLErrorString(); |
797 return gfx::SwapResult::SWAP_FAILED; | 801 return gfx::SwapResult::SWAP_FAILED; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 868 |
865 bool NativeViewGLSurfaceEGL::BuffersFlipped() const { | 869 bool NativeViewGLSurfaceEGL::BuffersFlipped() const { |
866 return g_use_direct_composition; | 870 return g_use_direct_composition; |
867 } | 871 } |
868 | 872 |
869 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, | 873 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, |
870 int y, | 874 int y, |
871 int width, | 875 int width, |
872 int height) { | 876 int height) { |
873 DCHECK(supports_post_sub_buffer_); | 877 DCHECK(supports_post_sub_buffer_); |
| 878 UpdateSwapInterval(); |
874 if (!CommitAndClearPendingOverlays()) { | 879 if (!CommitAndClearPendingOverlays()) { |
875 DVLOG(1) << "Failed to commit pending overlay planes."; | 880 DVLOG(1) << "Failed to commit pending overlay planes."; |
876 return gfx::SwapResult::SWAP_FAILED; | 881 return gfx::SwapResult::SWAP_FAILED; |
877 } | 882 } |
878 if (flips_vertically_) { | 883 if (flips_vertically_) { |
879 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered | 884 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered |
880 // inverted, but the PostSubBuffer rectangle is still measured from the | 885 // inverted, but the PostSubBuffer rectangle is still measured from the |
881 // bottom left. | 886 // bottom left. |
882 y = GetSize().height() - y - height; | 887 y = GetSize().height() - y - height; |
883 } | 888 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 } | 1144 } |
1140 | 1145 |
1141 void* SurfacelessEGL::GetShareHandle() { | 1146 void* SurfacelessEGL::GetShareHandle() { |
1142 return NULL; | 1147 return NULL; |
1143 } | 1148 } |
1144 | 1149 |
1145 SurfacelessEGL::~SurfacelessEGL() { | 1150 SurfacelessEGL::~SurfacelessEGL() { |
1146 } | 1151 } |
1147 | 1152 |
1148 } // namespace gl | 1153 } // namespace gl |
OLD | NEW |