Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 2302393002: Support swap damage rect using eglSwapBuffersWithDamageKHR (Closed)
Patch Set: Added new SwapBuffersWithDamage entry point Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 622
623 return g_display; 623 return g_display;
624 } 624 }
625 625
626 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) 626 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window)
627 : window_(window), 627 : window_(window),
628 size_(1, 1), 628 size_(1, 1),
629 enable_fixed_size_angle_(false), 629 enable_fixed_size_angle_(false),
630 surface_(NULL), 630 surface_(NULL),
631 supports_post_sub_buffer_(false), 631 supports_post_sub_buffer_(false),
632 supports_swap_buffer_with_damage_(false),
632 flips_vertically_(false), 633 flips_vertically_(false),
633 swap_interval_(1) { 634 swap_interval_(1) {
634 #if defined(OS_ANDROID) 635 #if defined(OS_ANDROID)
635 if (window) 636 if (window)
636 ANativeWindow_acquire(window); 637 ANativeWindow_acquire(window);
637 #endif 638 #endif
638 639
639 #if defined(OS_WIN) 640 #if defined(OS_WIN)
640 vsync_override_ = false; 641 vsync_override_ = false;
641 swap_generation_ = 0; 642 swap_generation_ = 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 return false; 715 return false;
715 } 716 }
716 717
717 if (g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { 718 if (g_driver_egl.ext.b_EGL_NV_post_sub_buffer) {
718 EGLint surfaceVal; 719 EGLint surfaceVal;
719 EGLBoolean retVal = eglQuerySurface( 720 EGLBoolean retVal = eglQuerySurface(
720 GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal); 721 GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal);
721 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; 722 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
722 } 723 }
723 724
725 supports_swap_buffer_with_damage_ =
726 g_driver_egl.ext.b_EGL_KHR_swap_buffers_with_damage &&
727 base::CommandLine::ForCurrentProcess()->HasSwitch(
728 switches::kEnableSwapBuffersWithDamage);
729
724 if (sync_provider) 730 if (sync_provider)
725 vsync_provider_.reset(sync_provider.release()); 731 vsync_provider_.reset(sync_provider.release());
726 else if (g_egl_sync_control_supported) 732 else if (g_egl_sync_control_supported)
727 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_)); 733 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_));
728 return true; 734 return true;
729 } 735 }
730 736
731 bool NativeViewGLSurfaceEGL::InitializeNativeWindow() { 737 bool NativeViewGLSurfaceEGL::InitializeNativeWindow() {
732 return true; 738 return true;
733 } 739 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 LOG(ERROR) << "Failed to create surface."; 859 LOG(ERROR) << "Failed to create surface.";
854 return false; 860 return false;
855 } 861 }
856 return true; 862 return true;
857 } 863 }
858 864
859 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { 865 EGLSurface NativeViewGLSurfaceEGL::GetHandle() {
860 return surface_; 866 return surface_;
861 } 867 }
862 868
869 bool NativeViewGLSurfaceEGL::SupportsSwapBuffersWithDamage() {
870 return supports_swap_buffer_with_damage_;
871 }
872
863 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { 873 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
864 return supports_post_sub_buffer_; 874 return supports_post_sub_buffer_;
865 } 875 }
866 876
867 bool NativeViewGLSurfaceEGL::FlipsVertically() const { 877 bool NativeViewGLSurfaceEGL::FlipsVertically() const {
868 return flips_vertically_; 878 return flips_vertically_;
869 } 879 }
870 880
871 bool NativeViewGLSurfaceEGL::BuffersFlipped() const { 881 bool NativeViewGLSurfaceEGL::BuffersFlipped() const {
872 return g_use_direct_composition; 882 return g_use_direct_composition;
873 } 883 }
874 884
885 gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffersWithDamage(int x,
886 int y,
887 int width,
888 int height) {
889 DCHECK(supports_swap_buffer_with_damage_);
890 UpdateSwapInterval();
891 if (!CommitAndClearPendingOverlays()) {
892 DVLOG(1) << "Failed to commit pending overlay planes.";
893 return gfx::SwapResult::SWAP_FAILED;
894 }
895 if (flips_vertically_) {
896 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered
897 // inverted, but the PostSubBuffer rectangle is still measured from the
piman 2016/09/07 17:19:41 nit: PostSubBuffer -> damage ?
halliwell 2016/09/08 04:21:34 Done.
898 // bottom left.
899 y = GetSize().height() - y - height;
900 }
901
902 EGLint damage_rect[4] = {x, y, width, height};
903 if (!eglSwapBuffersWithDamageKHR(GetDisplay(), surface_, damage_rect, 1)) {
904 DVLOG(1) << "eglSwapBuffersWithDamageKHR failed with error "
905 << GetLastEGLErrorString();
906 return gfx::SwapResult::SWAP_FAILED;
907 }
908 return gfx::SwapResult::SWAP_ACK;
909 }
910
875 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, 911 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
876 int y, 912 int y,
877 int width, 913 int width,
878 int height) { 914 int height) {
879 DCHECK(supports_post_sub_buffer_); 915 DCHECK(supports_post_sub_buffer_);
880 UpdateSwapInterval(); 916 UpdateSwapInterval();
881 if (!CommitAndClearPendingOverlays()) { 917 if (!CommitAndClearPendingOverlays()) {
882 DVLOG(1) << "Failed to commit pending overlay planes."; 918 DVLOG(1) << "Failed to commit pending overlay planes.";
883 return gfx::SwapResult::SWAP_FAILED; 919 return gfx::SwapResult::SWAP_FAILED;
884 } 920 }
885 if (flips_vertically_) { 921 if (flips_vertically_) {
886 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered 922 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered
887 // inverted, but the PostSubBuffer rectangle is still measured from the 923 // inverted, but the PostSubBuffer rectangle is still measured from the
888 // bottom left. 924 // bottom left.
889 y = GetSize().height() - y - height; 925 y = GetSize().height() - y - height;
890 } 926 }
927
891 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { 928 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
892 DVLOG(1) << "eglPostSubBufferNV failed with error " 929 DVLOG(1) << "eglPostSubBufferNV failed with error "
893 << GetLastEGLErrorString(); 930 << GetLastEGLErrorString();
894 return gfx::SwapResult::SWAP_FAILED; 931 return gfx::SwapResult::SWAP_FAILED;
895 } 932 }
896 return gfx::SwapResult::SWAP_ACK; 933 return gfx::SwapResult::SWAP_ACK;
897 } 934 }
898 935
899 bool NativeViewGLSurfaceEGL::SupportsCommitOverlayPlanes() { 936 bool NativeViewGLSurfaceEGL::SupportsCommitOverlayPlanes() {
900 #if defined(OS_ANDROID) 937 #if defined(OS_ANDROID)
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 } 1183 }
1147 1184
1148 void* SurfacelessEGL::GetShareHandle() { 1185 void* SurfacelessEGL::GetShareHandle() {
1149 return NULL; 1186 return NULL;
1150 } 1187 }
1151 1188
1152 SurfacelessEGL::~SurfacelessEGL() { 1189 SurfacelessEGL::~SurfacelessEGL() {
1153 } 1190 }
1154 1191
1155 } // namespace gl 1192 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698