summaryrefslogtreecommitdiffstats
path: root/ui/gl
diff options
context:
space:
mode:
authorachaulk <achaulk@chromium.org>2015-05-28 18:36:21 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-29 01:36:56 +0000
commitc794eda78e9ba3c46b550b433e9fe5a248d40104 (patch)
tree8054088552654845102920183531ee33d1c12914 /ui/gl
parentbcb07449ce226e9263cf4f2637a1656377782e17 (diff)
downloadchromium_src-c794eda78e9ba3c46b550b433e9fe5a248d40104.zip
chromium_src-c794eda78e9ba3c46b550b433e9fe5a248d40104.tar.gz
chromium_src-c794eda78e9ba3c46b550b433e9fe5a248d40104.tar.bz2
Adding status to swap buffers completion
This will give us more options than completing all swaps successfully, or losing context BUG=476966 TBR=torne - approved interface change Review URL: https://codereview.chromium.org/1084173004 Cr-Commit-Position: refs/heads/master@{#331906}
Diffstat (limited to 'ui/gl')
-rw-r--r--ui/gl/gl_surface.cc24
-rw-r--r--ui/gl/gl_surface.h11
-rw-r--r--ui/gl/gl_surface_egl.cc24
-rw-r--r--ui/gl/gl_surface_egl.h8
-rw-r--r--ui/gl/gl_surface_glx.cc16
-rw-r--r--ui/gl/gl_surface_glx.h6
-rw-r--r--ui/gl/gl_surface_mac.cc4
-rw-r--r--ui/gl/gl_surface_osmesa.cc8
-rw-r--r--ui/gl/gl_surface_osmesa.h4
-rw-r--r--ui/gl/gl_surface_ozone.cc56
-rw-r--r--ui/gl/gl_surface_stub.cc4
-rw-r--r--ui/gl/gl_surface_stub.h2
-rw-r--r--ui/gl/gl_surface_wgl.cc13
-rw-r--r--ui/gl/gl_surface_wgl.h4
-rw-r--r--ui/gl/gl_surface_win.cc16
-rw-r--r--ui/gl/gl_surface_x11.cc20
16 files changed, 121 insertions, 99 deletions
diff --git a/ui/gl/gl_surface.cc b/ui/gl/gl_surface.cc
index 4769092..8a60ca5 100644
--- a/ui/gl/gl_surface.cc
+++ b/ui/gl/gl_surface.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/threading/thread_local.h"
#include "base/trace_event/trace_event.h"
+#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
@@ -194,13 +195,13 @@ unsigned int GLSurface::GetBackingFrameBufferObject() {
bool GLSurface::SwapBuffersAsync(const SwapCompletionCallback& callback) {
DCHECK(!IsSurfaceless());
- bool success = SwapBuffers();
- callback.Run();
- return success;
+ gfx::SwapResult result = SwapBuffers();
+ callback.Run(result);
+ return result == gfx::SwapResult::SWAP_ACK;
}
-bool GLSurface::PostSubBuffer(int x, int y, int width, int height) {
- return false;
+gfx::SwapResult GLSurface::PostSubBuffer(int x, int y, int width, int height) {
+ return gfx::SwapResult::SWAP_FAILED;
}
bool GLSurface::PostSubBufferAsync(int x,
@@ -208,9 +209,9 @@ bool GLSurface::PostSubBufferAsync(int x,
int width,
int height,
const SwapCompletionCallback& callback) {
- bool success = PostSubBuffer(x, y, width, height);
- callback.Run();
- return success;
+ gfx::SwapResult result = PostSubBuffer(x, y, width, height);
+ callback.Run(result);
+ return result == gfx::SwapResult::SWAP_ACK;
}
bool GLSurface::OnMakeCurrent(GLContext* context) {
@@ -319,7 +320,7 @@ bool GLSurfaceAdapter::IsOffscreen() {
return surface_->IsOffscreen();
}
-bool GLSurfaceAdapter::SwapBuffers() {
+gfx::SwapResult GLSurfaceAdapter::SwapBuffers() {
return surface_->SwapBuffers();
}
@@ -328,7 +329,10 @@ bool GLSurfaceAdapter::SwapBuffersAsync(
return surface_->SwapBuffersAsync(callback);
}
-bool GLSurfaceAdapter::PostSubBuffer(int x, int y, int width, int height) {
+gfx::SwapResult GLSurfaceAdapter::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
return surface_->PostSubBuffer(x, y, width, height);
}
diff --git a/ui/gl/gl_surface.h b/ui/gl/gl_surface.h
index b67ca69..9fee0a3 100644
--- a/ui/gl/gl_surface.h
+++ b/ui/gl/gl_surface.h
@@ -15,6 +15,7 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/overlay_transform.h"
+#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_implementation.h"
@@ -58,7 +59,7 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
// Swaps front and back buffers. This has no effect for off-screen
// contexts.
- virtual bool SwapBuffers() = 0;
+ virtual gfx::SwapResult SwapBuffers() = 0;
// Get the size of the surface.
virtual gfx::Size GetSize() = 0;
@@ -73,7 +74,7 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
// FBO. Otherwise returns 0.
virtual unsigned int GetBackingFrameBufferObject();
- typedef base::Callback<void()> SwapCompletionCallback;
+ typedef base::Callback<void(SwapResult)> SwapCompletionCallback;
// Swaps front and back buffers. This has no effect for off-screen
// contexts. On some platforms, we want to send SwapBufferAck only after the
// surface is displayed on screen. The callback can be used to delay sending
@@ -82,7 +83,7 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback);
// Copy part of the backbuffer to the frontbuffer.
- virtual bool PostSubBuffer(int x, int y, int width, int height);
+ virtual gfx::SwapResult PostSubBuffer(int x, int y, int width, int height);
// Copy part of the backbuffer to the frontbuffer. On some platforms, we want
// to send SwapBufferAck only after the surface is displayed on screen. The
@@ -204,9 +205,9 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface {
bool Recreate() override;
bool DeferDraws() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
bool SwapBuffersAsync(const SwapCompletionCallback& callback) 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 PostSubBufferAsync(int x,
int y,
int width,
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index b6cf38f..4d64da7 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -661,7 +661,7 @@ bool NativeViewGLSurfaceEGL::IsOffscreen() {
return false;
}
-bool NativeViewGLSurfaceEGL::SwapBuffers() {
+gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers() {
TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers",
"width", GetSize().width(),
"height", GetSize().height());
@@ -704,10 +704,10 @@ bool NativeViewGLSurfaceEGL::SwapBuffers() {
if (!eglSwapBuffers(GetDisplay(), surface_)) {
DVLOG(1) << "eglSwapBuffers failed with error "
<< GetLastEGLErrorString();
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
gfx::Size NativeViewGLSurfaceEGL::GetSize() {
@@ -766,15 +766,17 @@ bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
return supports_post_sub_buffer_;
}
-bool NativeViewGLSurfaceEGL::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
DCHECK(supports_post_sub_buffer_);
if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
DVLOG(1) << "eglPostSubBufferNV failed with error "
<< GetLastEGLErrorString();
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() {
@@ -855,9 +857,9 @@ bool PbufferGLSurfaceEGL::IsOffscreen() {
return true;
}
-bool PbufferGLSurfaceEGL::SwapBuffers() {
+gfx::SwapResult PbufferGLSurfaceEGL::SwapBuffers() {
NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL.";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size PbufferGLSurfaceEGL::GetSize() {
@@ -941,9 +943,9 @@ bool SurfacelessEGL::IsSurfaceless() const {
return true;
}
-bool SurfacelessEGL::SwapBuffers() {
+gfx::SwapResult SurfacelessEGL::SwapBuffers() {
LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL.";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size SurfacelessEGL::GetSize() {
diff --git a/ui/gl/gl_surface_egl.h b/ui/gl/gl_surface_egl.h
index c643855..07d0271 100644
--- a/ui/gl/gl_surface_egl.h
+++ b/ui/gl/gl_surface_egl.h
@@ -80,11 +80,11 @@ class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL {
bool Resize(const gfx::Size& size) override;
bool Recreate() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
EGLSurface GetHandle() 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;
VSyncProvider* GetVSyncProvider() override;
// Create a NativeViewGLSurfaceEGL with an externally provided VSyncProvider.
@@ -130,7 +130,7 @@ class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL {
bool Initialize() override;
void Destroy() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
bool Resize(const gfx::Size& size) override;
EGLSurface GetHandle() override;
@@ -159,7 +159,7 @@ class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL {
void Destroy() override;
bool IsOffscreen() override;
bool IsSurfaceless() const override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
bool Resize(const gfx::Size& size) override;
EGLSurface GetHandle() override;
diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
index 0602dfa..b021a42 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -540,13 +540,13 @@ bool NativeViewGLSurfaceGLX::IsOffscreen() {
return false;
}
-bool NativeViewGLSurfaceGLX::SwapBuffers() {
+gfx::SwapResult NativeViewGLSurfaceGLX::SwapBuffers() {
TRACE_EVENT2("gpu", "NativeViewGLSurfaceGLX:RealSwapBuffers",
"width", GetSize().width(),
"height", GetSize().height());
glXSwapBuffers(g_display, GetDrawableHandle());
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
gfx::Size NativeViewGLSurfaceGLX::GetSize() {
@@ -567,11 +567,13 @@ void* NativeViewGLSurfaceGLX::GetConfig() {
return config_;
}
-bool NativeViewGLSurfaceGLX::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult NativeViewGLSurfaceGLX::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
DCHECK(gfx::g_driver_glx.ext.b_GLX_MESA_copy_sub_buffer);
glXCopySubBufferMESA(g_display, GetDrawableHandle(), x, y, width, height);
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() {
@@ -617,9 +619,9 @@ bool UnmappedNativeViewGLSurfaceGLX::IsOffscreen() {
return true;
}
-bool UnmappedNativeViewGLSurfaceGLX::SwapBuffers() {
+gfx::SwapResult UnmappedNativeViewGLSurfaceGLX::SwapBuffers() {
NOTREACHED() << "Attempted to call SwapBuffers on an unmapped window.";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size UnmappedNativeViewGLSurfaceGLX::GetSize() {
diff --git a/ui/gl/gl_surface_glx.h b/ui/gl/gl_surface_glx.h
index 46b044f..1db5e4c 100644
--- a/ui/gl/gl_surface_glx.h
+++ b/ui/gl/gl_surface_glx.h
@@ -61,12 +61,12 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX,
void Destroy() override;
bool Resize(const gfx::Size& size) override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
bool SupportsPostSubBuffer() override;
void* GetConfig() override;
- bool PostSubBuffer(int x, int y, int width, int height) override;
+ gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
VSyncProvider* GetVSyncProvider() override;
protected:
@@ -103,7 +103,7 @@ class GL_EXPORT UnmappedNativeViewGLSurfaceGLX : public GLSurfaceGLX {
bool Initialize() override;
void Destroy() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
void* GetConfig() override;
diff --git a/ui/gl/gl_surface_mac.cc b/ui/gl/gl_surface_mac.cc
index 85e9714..0aea62f 100644
--- a/ui/gl/gl_surface_mac.cc
+++ b/ui/gl/gl_surface_mac.cc
@@ -32,9 +32,9 @@ class GL_EXPORT NoOpGLSurface : public GLSurface {
bool Initialize() override { return true; }
void Destroy() override {}
bool IsOffscreen() override { return true; }
- bool SwapBuffers() override {
+ gfx::SwapResult SwapBuffers() override {
NOTREACHED() << "Cannot call SwapBuffers on a NoOpGLSurface.";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size GetSize() override { return size_; }
void* GetHandle() override { return NULL; }
diff --git a/ui/gl/gl_surface_osmesa.cc b/ui/gl/gl_surface_osmesa.cc
index 7f1b1ad..00acc95 100644
--- a/ui/gl/gl_surface_osmesa.cc
+++ b/ui/gl/gl_surface_osmesa.cc
@@ -84,9 +84,9 @@ bool GLSurfaceOSMesa::IsOffscreen() {
return true;
}
-bool GLSurfaceOSMesa::SwapBuffers() {
+gfx::SwapResult GLSurfaceOSMesa::SwapBuffers() {
NOTREACHED() << "Should not call SwapBuffers on an GLSurfaceOSMesa.";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size GLSurfaceOSMesa::GetSize() {
@@ -107,7 +107,9 @@ GLSurfaceOSMesa::~GLSurfaceOSMesa() {
bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; }
-bool GLSurfaceOSMesaHeadless::SwapBuffers() { return true; }
+gfx::SwapResult GLSurfaceOSMesaHeadless::SwapBuffers() {
+ return gfx::SwapResult::SWAP_ACK;
+}
GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless()
: GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)) {
diff --git a/ui/gl/gl_surface_osmesa.h b/ui/gl/gl_surface_osmesa.h
index cd65e65..1aa90bd 100644
--- a/ui/gl/gl_surface_osmesa.h
+++ b/ui/gl/gl_surface_osmesa.h
@@ -25,7 +25,7 @@ class GL_EXPORT GLSurfaceOSMesa : public GLSurface {
void Destroy() override;
bool Resize(const gfx::Size& new_size) override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
unsigned GetFormat() override;
@@ -49,7 +49,7 @@ class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa {
explicit GLSurfaceOSMesaHeadless();
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
protected:
~GLSurfaceOSMesaHeadless() override;
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index 064c5c6..3b2e76a 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(
diff --git a/ui/gl/gl_surface_stub.cc b/ui/gl/gl_surface_stub.cc
index a27d2af..c49165f 100644
--- a/ui/gl/gl_surface_stub.cc
+++ b/ui/gl/gl_surface_stub.cc
@@ -13,8 +13,8 @@ bool GLSurfaceStub::IsOffscreen() {
return false;
}
-bool GLSurfaceStub::SwapBuffers() {
- return true;
+gfx::SwapResult GLSurfaceStub::SwapBuffers() {
+ return gfx::SwapResult::SWAP_ACK;
}
gfx::Size GLSurfaceStub::GetSize() {
diff --git a/ui/gl/gl_surface_stub.h b/ui/gl/gl_surface_stub.h
index 1bdd32a..bf21573 100644
--- a/ui/gl/gl_surface_stub.h
+++ b/ui/gl/gl_surface_stub.h
@@ -17,7 +17,7 @@ class GL_EXPORT GLSurfaceStub : public GLSurface {
// Implement GLSurface.
void Destroy() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
diff --git a/ui/gl/gl_surface_wgl.cc b/ui/gl/gl_surface_wgl.cc
index 698539f..82e34ec 100644
--- a/ui/gl/gl_surface_wgl.cc
+++ b/ui/gl/gl_surface_wgl.cc
@@ -250,7 +250,7 @@ bool NativeViewGLSurfaceWGL::IsOffscreen() {
return false;
}
-bool NativeViewGLSurfaceWGL::SwapBuffers() {
+gfx::SwapResult NativeViewGLSurfaceWGL::SwapBuffers() {
TRACE_EVENT2("gpu", "NativeViewGLSurfaceWGL:RealSwapBuffers",
"width", GetSize().width(),
"height", GetSize().height());
@@ -259,18 +259,19 @@ bool NativeViewGLSurfaceWGL::SwapBuffers() {
// it as it moves.
RECT rect;
if (!GetClientRect(window_, &rect))
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
if (!MoveWindow(child_window_,
0,
0,
rect.right - rect.left,
rect.bottom - rect.top,
FALSE)) {
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
DCHECK(device_context_);
- return ::SwapBuffers(device_context_) == TRUE;
+ return ::SwapBuffers(device_context_) == TRUE ? gfx::SwapResult::SWAP_ACK
+ : gfx::SwapResult::SWAP_FAILED;
}
gfx::Size NativeViewGLSurfaceWGL::GetSize() {
@@ -345,9 +346,9 @@ bool PbufferGLSurfaceWGL::IsOffscreen() {
return true;
}
-bool PbufferGLSurfaceWGL::SwapBuffers() {
+gfx::SwapResult PbufferGLSurfaceWGL::SwapBuffers() {
NOTREACHED() << "Attempted to call SwapBuffers on a pbuffer.";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size PbufferGLSurfaceWGL::GetSize() {
diff --git a/ui/gl/gl_surface_wgl.h b/ui/gl/gl_surface_wgl.h
index e4548da..934e9f3 100644
--- a/ui/gl/gl_surface_wgl.h
+++ b/ui/gl/gl_surface_wgl.h
@@ -37,7 +37,7 @@ class NativeViewGLSurfaceWGL : public GLSurfaceWGL {
bool Initialize() override;
void Destroy() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
@@ -61,7 +61,7 @@ class PbufferGLSurfaceWGL : public GLSurfaceWGL {
bool Initialize() override;
void Destroy() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
diff --git a/ui/gl/gl_surface_win.cc b/ui/gl/gl_surface_win.cc
index 7f6dfd7..c416e6b 100644
--- a/ui/gl/gl_surface_win.cc
+++ b/ui/gl/gl_surface_win.cc
@@ -37,9 +37,9 @@ class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa {
bool Initialize() override;
void Destroy() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() 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;
private:
~NativeViewGLSurfaceOSMesa() override;
@@ -208,7 +208,7 @@ bool NativeViewGLSurfaceOSMesa::IsOffscreen() {
return false;
}
-bool NativeViewGLSurfaceOSMesa::SwapBuffers() {
+gfx::SwapResult NativeViewGLSurfaceOSMesa::SwapBuffers() {
DCHECK(device_context_);
gfx::Size size = GetSize();
@@ -241,15 +241,17 @@ bool NativeViewGLSurfaceOSMesa::SwapBuffers() {
DIB_RGB_COLORS,
SRCCOPY);
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
bool NativeViewGLSurfaceOSMesa::SupportsPostSubBuffer() {
return true;
}
-bool NativeViewGLSurfaceOSMesa::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult NativeViewGLSurfaceOSMesa::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
DCHECK(device_context_);
gfx::Size size = GetSize();
@@ -282,7 +284,7 @@ bool NativeViewGLSurfaceOSMesa::PostSubBuffer(
DIB_RGB_COLORS,
SRCCOPY);
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
diff --git a/ui/gl/gl_surface_x11.cc b/ui/gl/gl_surface_x11.cc
index f7d6a41..4e14a43 100644
--- a/ui/gl/gl_surface_x11.cc
+++ b/ui/gl/gl_surface_x11.cc
@@ -32,9 +32,9 @@ class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa {
void Destroy() override;
bool Resize(const gfx::Size& new_size) override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() 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;
protected:
~NativeViewGLSurfaceOSMesa() override;
@@ -181,7 +181,7 @@ bool NativeViewGLSurfaceOSMesa::IsOffscreen() {
return false;
}
-bool NativeViewGLSurfaceOSMesa::SwapBuffers() {
+gfx::SwapResult NativeViewGLSurfaceOSMesa::SwapBuffers() {
TRACE_EVENT2("gpu", "NativeViewGLSurfaceOSMesa:RealSwapBuffers",
"width", GetSize().width(),
"height", GetSize().height());
@@ -191,7 +191,7 @@ bool NativeViewGLSurfaceOSMesa::SwapBuffers() {
XWindowAttributes attributes;
if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) {
LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << ".";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
// Copy the frame into the pixmap.
@@ -216,15 +216,17 @@ bool NativeViewGLSurfaceOSMesa::SwapBuffers() {
0,
0);
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
bool NativeViewGLSurfaceOSMesa::SupportsPostSubBuffer() {
return true;
}
-bool NativeViewGLSurfaceOSMesa::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult NativeViewGLSurfaceOSMesa::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
gfx::Size size = GetSize();
// Move (0,0) from lower-left to upper-left
@@ -233,7 +235,7 @@ bool NativeViewGLSurfaceOSMesa::PostSubBuffer(
XWindowAttributes attributes;
if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) {
LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << ".";
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
// Copy the frame into the pixmap.
@@ -264,7 +266,7 @@ bool NativeViewGLSurfaceOSMesa::PostSubBuffer(
x,
y);
- return true;
+ return gfx::SwapResult::SWAP_ACK;
}
NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() {