Index: ui/gl/gl_surface_ozone.cc |
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc |
index 064c5c62e3b481b48c938c52d267a525426816b0..3b2e76a05765dfacc60ce1c6e893c9ec119bb27d 100644 |
--- a/ui/gl/gl_surface_ozone.cc |
+++ b/ui/gl/gl_surface_ozone.cc |
@@ -44,7 +44,7 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { |
// GLSurface: |
bool Initialize() override; |
bool Resize(const gfx::Size& size) override; |
- bool SwapBuffers() override; |
+ gfx::SwapResult SwapBuffers() override; |
bool ScheduleOverlayPlane(int z_order, |
OverlayTransform transform, |
GLImage* image, |
@@ -87,11 +87,13 @@ bool GLSurfaceOzoneEGL::Resize(const gfx::Size& size) { |
return NativeViewGLSurfaceEGL::Resize(size); |
} |
-bool GLSurfaceOzoneEGL::SwapBuffers() { |
- if (!NativeViewGLSurfaceEGL::SwapBuffers()) |
- return false; |
+gfx::SwapResult GLSurfaceOzoneEGL::SwapBuffers() { |
+ gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); |
+ if (result != gfx::SwapResult::SWAP_ACK) |
+ return result; |
- return ozone_surface_->OnSwapBuffers(); |
+ return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK |
+ : gfx::SwapResult::SWAP_FAILED; |
} |
bool GLSurfaceOzoneEGL::ScheduleOverlayPlane(int z_order, |
@@ -141,7 +143,7 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { |
// GLSurface: |
bool Initialize() override; |
bool Resize(const gfx::Size& size) override; |
- bool SwapBuffers() override; |
+ gfx::SwapResult SwapBuffers() override; |
bool ScheduleOverlayPlane(int z_order, |
OverlayTransform transform, |
GLImage* image, |
@@ -150,7 +152,7 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { |
bool IsOffscreen() override; |
VSyncProvider* GetVSyncProvider() override; |
bool SupportsPostSubBuffer() override; |
- bool PostSubBuffer(int x, int y, int width, int height) override; |
+ gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
bool PostSubBufferAsync(int x, |
int y, |
@@ -192,7 +194,8 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { |
EGLSyncKHR InsertFence(); |
void FenceRetired(EGLSyncKHR fence, PendingFrame* frame); |
- void SwapCompleted(const SwapCompletionCallback& callback); |
+ void SwapCompleted(const SwapCompletionCallback& callback, |
+ gfx::SwapResult result); |
// The native surface. Deleting this is allowed to free the EGLNativeWindow. |
scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
@@ -265,14 +268,14 @@ bool GLSurfaceOzoneSurfaceless::Resize(const gfx::Size& size) { |
return SurfacelessEGL::Resize(size); |
} |
-bool GLSurfaceOzoneSurfaceless::SwapBuffers() { |
+gfx::SwapResult GLSurfaceOzoneSurfaceless::SwapBuffers() { |
glFlush(); |
// TODO: the following should be replaced by a per surface flush as it gets |
// implemented in GL drivers. |
if (has_implicit_external_sync_) { |
EGLSyncKHR fence = InsertFence(); |
if (!fence) |
- return false; |
+ return SwapResult::SWAP_FAILED; |
EGLDisplay display = GetDisplay(); |
WaitForFence(display, fence); |
@@ -284,7 +287,8 @@ bool GLSurfaceOzoneSurfaceless::SwapBuffers() { |
unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_); |
unsubmitted_frames_.back()->overlays.clear(); |
- return ozone_surface_->OnSwapBuffers(); |
+ return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK |
+ : gfx::SwapResult::SWAP_FAILED; |
} |
bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane(int z_order, |
OverlayTransform transform, |
@@ -304,13 +308,13 @@ VSyncProvider* GLSurfaceOzoneSurfaceless::GetVSyncProvider() { |
bool GLSurfaceOzoneSurfaceless::SupportsPostSubBuffer() { |
return true; |
} |
-bool GLSurfaceOzoneSurfaceless::PostSubBuffer(int x, |
- int y, |
- int width, |
- int height) { |
+gfx::SwapResult GLSurfaceOzoneSurfaceless::PostSubBuffer(int x, |
+ int y, |
+ int width, |
+ int height) { |
// The actual sub buffer handling is handled at higher layers. |
SwapBuffers(); |
- return true; |
+ return gfx::SwapResult::SWAP_ACK; |
} |
bool GLSurfaceOzoneSurfaceless::SwapBuffersAsync( |
const SwapCompletionCallback& callback) { |
@@ -320,7 +324,7 @@ bool GLSurfaceOzoneSurfaceless::SwapBuffersAsync( |
glFlush(); |
- base::Closure surface_swap_callback = |
+ SwapCompletionCallback surface_swap_callback = |
base::Bind(&GLSurfaceOzoneSurfaceless::SwapCompleted, |
weak_factory_.GetWeakPtr(), callback); |
@@ -395,8 +399,9 @@ void GLSurfaceOzoneSurfaceless::FenceRetired(EGLSyncKHR fence, |
} |
void GLSurfaceOzoneSurfaceless::SwapCompleted( |
- const SwapCompletionCallback& callback) { |
- callback.Run(); |
+ const SwapCompletionCallback& callback, |
+ gfx::SwapResult result) { |
+ callback.Run(result); |
swap_buffers_pending_ = false; |
SubmitFrame(); |
@@ -416,7 +421,7 @@ class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl |
bool OnMakeCurrent(GLContext* context) override; |
bool Resize(const gfx::Size& size) override; |
bool SupportsPostSubBuffer() override; |
- bool SwapBuffers() override; |
+ gfx::SwapResult SwapBuffers() override; |
bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
void Destroy() override; |
@@ -519,16 +524,17 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::SupportsPostSubBuffer() { |
return false; |
} |
-bool GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffers() { |
+gfx::SwapResult GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffers() { |
if (!images_[current_surface_]->ScheduleOverlayPlane( |
widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, |
gfx::Rect(GetSize()), gfx::RectF(1, 1))) |
- return false; |
- if (!GLSurfaceOzoneSurfaceless::SwapBuffers()) |
- return false; |
+ return gfx::SwapResult::SWAP_FAILED; |
+ gfx::SwapResult result = GLSurfaceOzoneSurfaceless::SwapBuffers(); |
+ if (result != gfx::SwapResult::SWAP_ACK) |
+ return result; |
current_surface_ ^= 1; |
BindFramebuffer(); |
- return true; |
+ return gfx::SwapResult::SWAP_ACK; |
} |
bool GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffersAsync( |