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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_egl.cc
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 27bde64f6e28411f18fa7fbfc93abad010c33d04..70e59e7871d4ef2b5d18ba5b339149fe6d4ce3c8 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -629,6 +629,7 @@ NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window)
enable_fixed_size_angle_(false),
surface_(NULL),
supports_post_sub_buffer_(false),
+ supports_swap_buffer_with_damage_(false),
flips_vertically_(false),
swap_interval_(1) {
#if defined(OS_ANDROID)
@@ -721,6 +722,11 @@ bool NativeViewGLSurfaceEGL::Initialize(
supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
}
+ supports_swap_buffer_with_damage_ =
+ gfx::g_driver_egl.ext.b_EGL_KHR_swap_buffers_with_damage &&
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableSwapBuffersWithDamage);
+
if (sync_provider)
vsync_provider_.reset(sync_provider.release());
else if (g_egl_sync_control_supported)
@@ -861,7 +867,7 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() {
}
bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
- return supports_post_sub_buffer_;
+ return supports_post_sub_buffer_ || supports_swap_buffer_with_damage_;
}
bool NativeViewGLSurfaceEGL::FlipsVertically() const {
@@ -876,7 +882,7 @@ gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
int y,
int width,
int height) {
- DCHECK(supports_post_sub_buffer_);
+ 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
UpdateSwapInterval();
if (!CommitAndClearPendingOverlays()) {
DVLOG(1) << "Failed to commit pending overlay planes.";
@@ -888,10 +894,20 @@ gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
// bottom left.
y = GetSize().height() - y - height;
}
- if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
- DVLOG(1) << "eglPostSubBufferNV failed with error "
- << GetLastEGLErrorString();
- return gfx::SwapResult::SWAP_FAILED;
+
+ if (supports_post_sub_buffer_) {
+ if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
+ DVLOG(1) << "eglPostSubBufferNV failed with error "
+ << GetLastEGLErrorString();
+ return gfx::SwapResult::SWAP_FAILED;
+ }
+ } else {
+ EGLint damage_rect[4] = {x, y, width, height};
+ if (!eglSwapBuffersWithDamageKHR(GetDisplay(), surface_, damage_rect, 1)) {
+ DVLOG(1) << "eglSwapBuffersWithDamageKHR failed with error "
+ << GetLastEGLErrorString();
+ return gfx::SwapResult::SWAP_FAILED;
+ }
}
return gfx::SwapResult::SWAP_ACK;
}
« 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