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: Update GLSurfaceAdapter 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 631
632 return g_display; 632 return g_display;
633 } 633 }
634 634
635 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) 635 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window)
636 : window_(window), 636 : window_(window),
637 size_(1, 1), 637 size_(1, 1),
638 enable_fixed_size_angle_(false), 638 enable_fixed_size_angle_(false),
639 surface_(NULL), 639 surface_(NULL),
640 supports_post_sub_buffer_(false), 640 supports_post_sub_buffer_(false),
641 supports_swap_buffer_with_damage_(false),
641 flips_vertically_(false), 642 flips_vertically_(false),
642 swap_interval_(1) { 643 swap_interval_(1) {
643 #if defined(OS_ANDROID) 644 #if defined(OS_ANDROID)
644 if (window) 645 if (window)
645 ANativeWindow_acquire(window); 646 ANativeWindow_acquire(window);
646 #endif 647 #endif
647 648
648 #if defined(OS_WIN) 649 #if defined(OS_WIN)
649 vsync_override_ = false; 650 vsync_override_ = false;
650 swap_generation_ = 0; 651 swap_generation_ = 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return false; 724 return false;
724 } 725 }
725 726
726 if (g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { 727 if (g_driver_egl.ext.b_EGL_NV_post_sub_buffer) {
727 EGLint surfaceVal; 728 EGLint surfaceVal;
728 EGLBoolean retVal = eglQuerySurface( 729 EGLBoolean retVal = eglQuerySurface(
729 GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal); 730 GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal);
730 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; 731 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
731 } 732 }
732 733
734 supports_swap_buffer_with_damage_ =
735 g_driver_egl.ext.b_EGL_KHR_swap_buffers_with_damage &&
736 base::CommandLine::ForCurrentProcess()->HasSwitch(
737 switches::kEnableSwapBuffersWithDamage);
738
733 if (sync_provider) 739 if (sync_provider)
734 vsync_provider_.reset(sync_provider.release()); 740 vsync_provider_.reset(sync_provider.release());
735 else if (g_egl_sync_control_supported) 741 else if (g_egl_sync_control_supported)
736 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_)); 742 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_));
737 return true; 743 return true;
738 } 744 }
739 745
740 bool NativeViewGLSurfaceEGL::InitializeNativeWindow() { 746 bool NativeViewGLSurfaceEGL::InitializeNativeWindow() {
741 return true; 747 return true;
742 } 748 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 LOG(ERROR) << "Failed to create surface."; 868 LOG(ERROR) << "Failed to create surface.";
863 return false; 869 return false;
864 } 870 }
865 return true; 871 return true;
866 } 872 }
867 873
868 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { 874 EGLSurface NativeViewGLSurfaceEGL::GetHandle() {
869 return surface_; 875 return surface_;
870 } 876 }
871 877
878 bool NativeViewGLSurfaceEGL::SupportsSwapBuffersWithDamage() {
879 return supports_swap_buffer_with_damage_;
880 }
881
872 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { 882 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
873 return supports_post_sub_buffer_; 883 return supports_post_sub_buffer_;
874 } 884 }
875 885
876 bool NativeViewGLSurfaceEGL::FlipsVertically() const { 886 bool NativeViewGLSurfaceEGL::FlipsVertically() const {
877 return flips_vertically_; 887 return flips_vertically_;
878 } 888 }
879 889
880 bool NativeViewGLSurfaceEGL::BuffersFlipped() const { 890 bool NativeViewGLSurfaceEGL::BuffersFlipped() const {
881 return g_use_direct_composition; 891 return g_use_direct_composition;
882 } 892 }
883 893
894 gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffersWithDamage(int x,
895 int y,
896 int width,
897 int height) {
898 DCHECK(supports_swap_buffer_with_damage_);
899 UpdateSwapInterval();
900 if (!CommitAndClearPendingOverlays()) {
901 DVLOG(1) << "Failed to commit pending overlay planes.";
902 return gfx::SwapResult::SWAP_FAILED;
903 }
904 if (flips_vertically_) {
905 // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered
906 // inverted, but the damage rectangle is still measured from the
907 // bottom left.
908 y = GetSize().height() - y - height;
909 }
910
911 EGLint damage_rect[4] = {x, y, width, height};
912 if (!eglSwapBuffersWithDamageKHR(GetDisplay(), surface_, damage_rect, 1)) {
913 DVLOG(1) << "eglSwapBuffersWithDamageKHR failed with error "
914 << GetLastEGLErrorString();
915 return gfx::SwapResult::SWAP_FAILED;
916 }
917 return gfx::SwapResult::SWAP_ACK;
918 }
919
884 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, 920 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
885 int y, 921 int y,
886 int width, 922 int width,
887 int height) { 923 int height) {
888 DCHECK(supports_post_sub_buffer_); 924 DCHECK(supports_post_sub_buffer_);
889 UpdateSwapInterval(); 925 UpdateSwapInterval();
890 if (!CommitAndClearPendingOverlays()) { 926 if (!CommitAndClearPendingOverlays()) {
891 DVLOG(1) << "Failed to commit pending overlay planes."; 927 DVLOG(1) << "Failed to commit pending overlay planes.";
892 return gfx::SwapResult::SWAP_FAILED; 928 return gfx::SwapResult::SWAP_FAILED;
893 } 929 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 } 1191 }
1156 1192
1157 void* SurfacelessEGL::GetShareHandle() { 1193 void* SurfacelessEGL::GetShareHandle() {
1158 return NULL; 1194 return NULL;
1159 } 1195 }
1160 1196
1161 SurfacelessEGL::~SurfacelessEGL() { 1197 SurfacelessEGL::~SurfacelessEGL() {
1162 } 1198 }
1163 1199
1164 } // namespace gl 1200 } // 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