Chromium Code Reviews| 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..96f77adc2e963f1701c71f573153e092fd73a8ac 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_ = |
| + 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) |
| @@ -860,6 +866,10 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() { |
| return surface_; |
| } |
| +bool NativeViewGLSurfaceEGL::SupportsSwapBuffersWithDamage() { |
| + return supports_swap_buffer_with_damage_; |
| +} |
| + |
| bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { |
| return supports_post_sub_buffer_; |
| } |
| @@ -872,6 +882,32 @@ bool NativeViewGLSurfaceEGL::BuffersFlipped() const { |
| return g_use_direct_composition; |
| } |
| +gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffersWithDamage(int x, |
| + int y, |
| + int width, |
| + int height) { |
| + DCHECK(supports_swap_buffer_with_damage_); |
| + UpdateSwapInterval(); |
| + if (!CommitAndClearPendingOverlays()) { |
| + DVLOG(1) << "Failed to commit pending overlay planes."; |
| + return gfx::SwapResult::SWAP_FAILED; |
| + } |
| + if (flips_vertically_) { |
| + // With EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE the contents are rendered |
| + // 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.
|
| + // bottom left. |
| + y = GetSize().height() - y - height; |
| + } |
| + |
| + 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; |
| +} |
| + |
| gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, |
| int y, |
| int width, |
| @@ -888,6 +924,7 @@ 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(); |