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

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

Issue 2302393002: Support swap damage rect using eglSwapBuffersWithDamageKHR (Closed)
Patch Set: 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
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 gfx::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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
863 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { 869 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
864 return supports_post_sub_buffer_; 870 return supports_post_sub_buffer_ || supports_swap_buffer_with_damage_;
865 } 871 }
866 872
867 bool NativeViewGLSurfaceEGL::FlipsVertically() const { 873 bool NativeViewGLSurfaceEGL::FlipsVertically() const {
868 return flips_vertically_; 874 return flips_vertically_;
869 } 875 }
870 876
871 bool NativeViewGLSurfaceEGL::BuffersFlipped() const { 877 bool NativeViewGLSurfaceEGL::BuffersFlipped() const {
872 return g_use_direct_composition; 878 return g_use_direct_composition;
873 } 879 }
874 880
875 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, 881 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
876 int y, 882 int y,
877 int width, 883 int width,
878 int height) { 884 int height) {
879 DCHECK(supports_post_sub_buffer_); 885 DCHECK(supports_post_sub_buffer_ || supports_swap_buffer_with_damage_);
piman 2016/09/02 18:25:47 Well, the semantics of eglPostSubBufferNV and of e
halliwell 2016/09/07 03:17:07 And yes, I understood the difference between this
880 UpdateSwapInterval(); 886 UpdateSwapInterval();
881 if (!CommitAndClearPendingOverlays()) { 887 if (!CommitAndClearPendingOverlays()) {
882 DVLOG(1) << "Failed to commit pending overlay planes."; 888 DVLOG(1) << "Failed to commit pending overlay planes.";
883 return gfx::SwapResult::SWAP_FAILED; 889 return gfx::SwapResult::SWAP_FAILED;
884 } 890 }
885 if (flips_vertically_) { 891 if (flips_vertically_) {
886 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered 892 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered
887 // inverted, but the PostSubBuffer rectangle is still measured from the 893 // inverted, but the PostSubBuffer rectangle is still measured from the
888 // bottom left. 894 // bottom left.
889 y = GetSize().height() - y - height; 895 y = GetSize().height() - y - height;
890 } 896 }
891 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { 897
892 DVLOG(1) << "eglPostSubBufferNV failed with error " 898 if (supports_post_sub_buffer_) {
893 << GetLastEGLErrorString(); 899 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
894 return gfx::SwapResult::SWAP_FAILED; 900 DVLOG(1) << "eglPostSubBufferNV failed with error "
901 << GetLastEGLErrorString();
902 return gfx::SwapResult::SWAP_FAILED;
903 }
904 } else {
905 EGLint damage_rect[4] = {x, y, width, height};
906 if (!eglSwapBuffersWithDamageKHR(GetDisplay(), surface_, damage_rect, 1)) {
907 DVLOG(1) << "eglSwapBuffersWithDamageKHR failed with error "
908 << GetLastEGLErrorString();
909 return gfx::SwapResult::SWAP_FAILED;
910 }
895 } 911 }
896 return gfx::SwapResult::SWAP_ACK; 912 return gfx::SwapResult::SWAP_ACK;
897 } 913 }
898 914
899 bool NativeViewGLSurfaceEGL::SupportsCommitOverlayPlanes() { 915 bool NativeViewGLSurfaceEGL::SupportsCommitOverlayPlanes() {
900 #if defined(OS_ANDROID) 916 #if defined(OS_ANDROID)
901 return true; 917 return true;
902 #else 918 #else
903 return false; 919 return false;
904 #endif 920 #endif
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 } 1162 }
1147 1163
1148 void* SurfacelessEGL::GetShareHandle() { 1164 void* SurfacelessEGL::GetShareHandle() {
1149 return NULL; 1165 return NULL;
1150 } 1166 }
1151 1167
1152 SurfacelessEGL::~SurfacelessEGL() { 1168 SurfacelessEGL::~SurfacelessEGL() {
1153 } 1169 }
1154 1170
1155 } // namespace gl 1171 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698