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 8352ff6b1f501b4a7091092720272ccd4ce7476a..21b9f159619e0cd268b19cf6382452ef6e0a09d5 100644 |
| --- a/ui/gl/gl_surface_egl.cc |
| +++ b/ui/gl/gl_surface_egl.cc |
| @@ -683,6 +683,9 @@ gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers() { |
| return gfx::SwapResult::SWAP_FAILED; |
| } |
| + if (SupportsCommitOverlayPlanes() && !CommitAndClearPendingOverlays()) |
|
piman
2015/12/01 01:06:45
SupportsCommitOverlayPlanes() seems orthogonal to
watk
2015/12/01 01:55:55
That makes a lot of sense. Done.
|
| + return gfx::SwapResult::SWAP_FAILED; |
| + |
| return gfx::SwapResult::SWAP_ACK; |
| } |
| @@ -752,9 +755,26 @@ gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, |
| << GetLastEGLErrorString(); |
| return gfx::SwapResult::SWAP_FAILED; |
| } |
| + if (SupportsCommitOverlayPlanes() && !CommitAndClearPendingOverlays()) |
|
piman
2015/12/01 01:06:45
(same here)
watk
2015/12/01 01:55:55
Done.
|
| + return gfx::SwapResult::SWAP_FAILED; |
| return gfx::SwapResult::SWAP_ACK; |
| } |
| +bool NativeViewGLSurfaceEGL::SupportsCommitOverlayPlanes() { |
| +#if defined(OS_ANDROID) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +gfx::SwapResult NativeViewGLSurfaceEGL::CommitOverlayPlanes() { |
| + DCHECK(SupportsCommitOverlayPlanes()); |
| + return CommitAndClearPendingOverlays() |
| + ? gfx::SwapResult::SWAP_ACK |
| + : gfx::SwapResult::SWAP_FAILED; |
| +} |
| + |
| VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { |
| return vsync_provider_.get(); |
| } |
| @@ -764,15 +784,13 @@ bool NativeViewGLSurfaceEGL::ScheduleOverlayPlane(int z_order, |
| gl::GLImage* image, |
| const Rect& bounds_rect, |
| const RectF& crop_rect) { |
| -#if defined(OS_ANDROID) |
| - // Overlay planes are used on Android for fullscreen video. The image is |
| - // expected to update the plane as soon as possible to display the video frame |
| - // chosen for this vsync interval. |
| - return image->ScheduleOverlayPlane(window_, z_order, transform, bounds_rect, |
| - crop_rect); |
| -#else |
| +#if !defined(OS_ANDROID) |
| NOTIMPLEMENTED(); |
| return false; |
| +#else |
| + pending_overlays_.push_back( |
| + GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect)); |
| + return true; |
| #endif |
| } |
| @@ -788,6 +806,17 @@ NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { |
| #endif |
| } |
| +bool NativeViewGLSurfaceEGL::CommitAndClearPendingOverlays() { |
| + bool success = true; |
| + for (const auto& overlay : pending_overlays_) { |
| + // It's expected that GLImage::ScheduleOverlayPlane will overlay contents on |
| + // the screen now. |
| + success &= overlay.ScheduleOverlayPlane(window_); |
| + } |
| + pending_overlays_.clear(); |
| + return success; |
| +} |
| + |
| PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) |
| : size_(size), |
| surface_(NULL) { |