summaryrefslogtreecommitdiffstats
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
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}
-rw-r--r--android_webview/browser/aw_gl_surface.cc4
-rw-r--r--android_webview/browser/aw_gl_surface.h2
-rw-r--r--content/browser/compositor/gpu_browser_compositor_output_surface.cc3
-rw-r--r--content/browser/compositor/gpu_browser_compositor_output_surface.h7
-rw-r--r--content/browser/renderer_host/compositor_impl_android.cc8
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.cc8
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.h7
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc6
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h4
-rw-r--r--content/common/gpu/gpu_messages.h7
-rw-r--r--content/common/gpu/image_transport_surface.cc29
-rw-r--r--content/common/gpu/image_transport_surface.h8
-rw-r--r--content/common/gpu/image_transport_surface_android.cc4
-rw-r--r--content/common/gpu/image_transport_surface_fbo_mac.h4
-rw-r--r--content/common/gpu/image_transport_surface_fbo_mac.mm14
-rw-r--r--content/common/gpu/image_transport_surface_mac.mm6
-rw-r--r--content/common/gpu/null_transport_surface.cc12
-rw-r--r--content/common/gpu/null_transport_surface.h4
-rw-r--r--gpu/command_buffer/service/gl_surface_mock.h8
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc5
-rw-r--r--ui/gfx/gfx.gyp1
-rw-r--r--ui/gfx/swap_result.h19
-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
-rw-r--r--ui/ozone/platform/cast/surface_ozone_egl_cast.cc2
-rw-r--r--ui/ozone/platform/drm/gpu/crtc_controller.cc10
-rw-r--r--ui/ozone/platform/drm/gpu/drm_surface.cc4
-rw-r--r--ui/ozone/platform/drm/gpu/drm_window.cc5
-rw-r--r--ui/ozone/platform/drm/gpu/drm_window.h6
-rw-r--r--ui/ozone/platform/drm/gpu/gbm_surface.cc14
-rw-r--r--ui/ozone/platform/drm/gpu/gbm_surface.h3
-rw-r--r--ui/ozone/platform/drm/gpu/gbm_surfaceless.cc6
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_controller.cc5
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_controller.h5
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc4
-rw-r--r--ui/ozone/platform/drm/gpu/page_flip_request.cc21
-rw-r--r--ui/ozone/platform/drm/gpu/page_flip_request.h11
-rw-r--r--ui/ozone/platform/drm/gpu/screen_manager_unittest.cc5
-rw-r--r--ui/ozone/platform/egltest/ozone_platform_egltest.cc2
-rw-r--r--ui/ozone/public/surface_ozone_egl.h4
54 files changed, 307 insertions, 190 deletions
diff --git a/android_webview/browser/aw_gl_surface.cc b/android_webview/browser/aw_gl_surface.cc
index 5ff9272..a542275 100644
--- a/android_webview/browser/aw_gl_surface.cc
+++ b/android_webview/browser/aw_gl_surface.cc
@@ -21,8 +21,8 @@ unsigned int AwGLSurface::GetBackingFrameBufferObject() {
return fbo_;
}
-bool AwGLSurface::SwapBuffers() {
- return true;
+gfx::SwapResult AwGLSurface::SwapBuffers() {
+ return gfx::SwapResult::SWAP_ACK;
}
gfx::Size AwGLSurface::GetSize() {
diff --git a/android_webview/browser/aw_gl_surface.h b/android_webview/browser/aw_gl_surface.h
index 128b5515..6366a35 100644
--- a/android_webview/browser/aw_gl_surface.h
+++ b/android_webview/browser/aw_gl_surface.h
@@ -20,7 +20,7 @@ class GL_EXPORT AwGLSurface : public gfx::GLSurface {
void Destroy() override;
bool IsOffscreen() override;
unsigned int GetBackingFrameBufferObject() override;
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
gfx::Size GetSize() override;
void* GetHandle() override;
void* GetDisplay() override;
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
index 273f40b..943a27a 100644
--- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc
+++ b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
@@ -105,7 +105,8 @@ void GpuBrowserCompositorOutputSurface::SwapBuffers(
}
void GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted(
- const std::vector<ui::LatencyInfo>& latency_info) {
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result) {
#if defined(OS_MACOSX)
// On Mac, delay acknowledging the swap to the output surface client until
// it has been drawn, see OnSurfaceDisplayed();
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.h b/content/browser/compositor/gpu_browser_compositor_output_surface.h
index 1259858..e1d1a49 100644
--- a/content/browser/compositor/gpu_browser_compositor_output_surface.h
+++ b/content/browser/compositor/gpu_browser_compositor_output_surface.h
@@ -7,6 +7,7 @@
#include "base/cancelable_callback.h"
#include "content/browser/compositor/browser_compositor_output_surface.h"
+#include "ui/gfx/swap_result.h"
namespace ui {
class CompositorVSyncManager;
@@ -58,9 +59,11 @@ class GpuBrowserCompositorOutputSurface
#endif
CommandBufferProxyImpl* GetCommandBufferProxy();
- void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info);
+ void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result);
- base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&)>
+ base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&,
+ gfx::SwapResult)>
swap_buffers_completion_callback_;
base::CancelableCallback<void(base::TimeTicks timebase,
base::TimeDelta interval)>
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 9ee5ef6..f5ec1e5 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -60,6 +60,7 @@
#include "third_party/skia/include/core/SkMallocPixelRef.h"
#include "ui/android/window_android.h"
#include "ui/gfx/android/device_display_info.h"
+#include "ui/gfx/swap_result.h"
namespace content {
@@ -118,13 +119,14 @@ class OutputSurfaceWithoutParent : public cc::OutputSurface {
return command_buffer_proxy;
}
- void OnSwapBuffersCompleted(
- const std::vector<ui::LatencyInfo>& latency_info) {
+ void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result) {
RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
OutputSurface::OnSwapBuffersComplete();
}
- base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&)>
+ base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&,
+ gfx::SwapResult)>
swap_buffers_completion_callback_;
scoped_refptr<base::MessageLoopProxy> main_thread_;
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 8ca94b3..36e6459 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -598,14 +598,16 @@ gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const {
}
void CommandBufferProxyImpl::OnSwapBuffersCompleted(
- const std::vector<ui::LatencyInfo>& latency_info) {
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result) {
if (!swap_buffers_completion_callback_.is_null()) {
if (!ui::LatencyInfo::Verify(
latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) {
- swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>());
+ swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>(),
+ result);
return;
}
- swap_buffers_completion_callback_.Run(latency_info);
+ swap_buffers_completion_callback_.Run(latency_info, result);
}
}
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h
index 4bd2006b..9f85bb2 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.h
+++ b/content/common/gpu/client/command_buffer_proxy_impl.h
@@ -22,6 +22,7 @@
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "ipc/ipc_listener.h"
#include "ui/events/latency_info.h"
+#include "ui/gfx/swap_result.h"
struct GPUCommandBufferConsoleMessage;
@@ -136,7 +137,8 @@ class CommandBufferProxyImpl
void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info);
using SwapBuffersCompletionCallback =
- base::Callback<void(const std::vector<ui::LatencyInfo>& latency_info)>;
+ base::Callback<void(const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result)>;
void SetSwapBuffersCompletionCallback(
const SwapBuffersCompletionCallback& callback);
@@ -180,7 +182,8 @@ class CommandBufferProxyImpl
void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message);
void OnSetMemoryAllocation(const gpu::MemoryAllocation& allocation);
void OnSignalSyncPointAck(uint32 id);
- void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info);
+ void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result);
void OnUpdateVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval);
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index bb4044a..729f66d 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -1107,8 +1107,10 @@ uint64 GpuCommandBufferStub::GetMemoryUsage() const {
}
void GpuCommandBufferStub::SendSwapBuffersCompleted(
- const std::vector<ui::LatencyInfo>& latency_info) {
- Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result) {
+ Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info,
+ result));
}
void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index c9e215c..24ba37a 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -27,6 +27,7 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gpu_preference.h"
#include "url/gurl.h"
@@ -148,7 +149,8 @@ class GpuCommandBufferStub
uint64 GetMemoryUsage() const;
void SendSwapBuffersCompleted(
- const std::vector<ui::LatencyInfo>& latency_info);
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result);
void SendUpdateVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval);
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 6bdec50..2f30dac 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -33,6 +33,7 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/swap_result.h"
#include "ui/gl/gpu_preference.h"
#if defined(OS_ANDROID)
@@ -52,6 +53,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(gfx::GpuPreference,
gfx::GpuPreferenceLast)
IPC_ENUM_TRAITS_MAX_VALUE(gfx::SurfaceType,
gfx::SURFACE_TYPE_LAST)
+IPC_ENUM_TRAITS_MAX_VALUE(gfx::SwapResult, gfx::SwapResult::SWAP_RESULT_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(gpu::MemoryAllocation::PriorityCutoff,
gpu::MemoryAllocation::CUTOFF_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(gpu::error::Error, gpu::error::kErrorLast)
@@ -558,8 +560,9 @@ IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_Destroyed,
gpu::error::Error /* error */)
// Tells the browser that SwapBuffers returned and passes latency info
-IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SwapBuffersCompleted,
- std::vector<ui::LatencyInfo> /* latency_info */)
+IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SwapBuffersCompleted,
+ std::vector<ui::LatencyInfo> /* latency_info */,
+ gfx::SwapResult /* result */)
// Tells the browser about updated parameters for vsync alignment.
IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_UpdateVSyncParameters,
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index ac5eb2e..6d2808f 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -187,7 +187,7 @@ void PassThroughImageTransportSurface::SetLatencyInfo(
latency_info_.push_back(latency_info[i]);
}
-bool PassThroughImageTransportSurface::SwapBuffers() {
+gfx::SwapResult PassThroughImageTransportSurface::SwapBuffers() {
// GetVsyncValues before SwapBuffers to work around Mali driver bug:
// crbug.com/223558.
SendVSyncUpdateIfAvailable();
@@ -206,12 +206,16 @@ bool PassThroughImageTransportSurface::SwapBuffers() {
new std::vector<ui::LatencyInfo>();
latency_info_ptr->swap(latency_info_);
return gfx::GLSurfaceAdapter::SwapBuffersAsync(base::Bind(
- &PassThroughImageTransportSurface::SwapBuffersCallBack,
- weak_ptr_factory_.GetWeakPtr(), base::Owned(latency_info_ptr)));
+ &PassThroughImageTransportSurface::SwapBuffersCallBack,
+ weak_ptr_factory_.GetWeakPtr(), base::Owned(latency_info_ptr)))
+ ? gfx::SwapResult::SWAP_ACK
+ : gfx::SwapResult::SWAP_FAILED;
}
-bool PassThroughImageTransportSurface::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult PassThroughImageTransportSurface::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
SendVSyncUpdateIfAvailable();
base::TimeTicks swap_time = base::TimeTicks::Now();
@@ -228,14 +232,17 @@ bool PassThroughImageTransportSurface::PostSubBuffer(
new std::vector<ui::LatencyInfo>();
latency_info_ptr->swap(latency_info_);
return gfx::GLSurfaceAdapter::PostSubBufferAsync(
- x, y, width, height,
- base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack,
- weak_ptr_factory_.GetWeakPtr(),
- base::Owned(latency_info_ptr)));
+ x, y, width, height,
+ base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Owned(latency_info_ptr)))
+ ? gfx::SwapResult::SWAP_ACK
+ : gfx::SwapResult::SWAP_FAILED;
}
void PassThroughImageTransportSurface::SwapBuffersCallBack(
- std::vector<ui::LatencyInfo>* latency_info_ptr) {
+ std::vector<ui::LatencyInfo>* latency_info_ptr,
+ gfx::SwapResult result) {
base::TimeTicks swap_ack_time = base::TimeTicks::Now();
for (auto& latency : *latency_info_ptr) {
latency.AddLatencyNumberWithTimestamp(
@@ -243,7 +250,7 @@ void PassThroughImageTransportSurface::SwapBuffersCallBack(
swap_ack_time, 1);
}
- helper_->stub()->SendSwapBuffersCompleted(*latency_info_ptr);
+ helper_->stub()->SendSwapBuffersCompleted(*latency_info_ptr, result);
}
bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
diff --git a/content/common/gpu/image_transport_surface.h b/content/common/gpu/image_transport_surface.h
index d3f2e85..c0bceab 100644
--- a/content/common/gpu/image_transport_surface.h
+++ b/content/common/gpu/image_transport_surface.h
@@ -19,6 +19,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_surface.h"
struct AcceleratedSurfaceMsg_BufferPresented_Params;
@@ -175,8 +176,8 @@ class PassThroughImageTransportSurface
// GLSurface implementation.
bool Initialize() override;
void Destroy() override;
- bool SwapBuffers() override;
- bool PostSubBuffer(int x, int y, int width, int height) override;
+ gfx::SwapResult SwapBuffers() override;
+ gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
bool OnMakeCurrent(gfx::GLContext* context) override;
// ImageTransportSurface implementation.
@@ -196,7 +197,8 @@ class PassThroughImageTransportSurface
// If updated vsync parameters can be determined, send this information to
// the browser.
virtual void SendVSyncUpdateIfAvailable();
- void SwapBuffersCallBack(std::vector<ui::LatencyInfo>* latency_info_ptr);
+ void SwapBuffersCallBack(std::vector<ui::LatencyInfo>* latency_info_ptr,
+ gfx::SwapResult result);
ImageTransportHelper* GetHelper() { return helper_.get(); }
diff --git a/content/common/gpu/image_transport_surface_android.cc b/content/common/gpu/image_transport_surface_android.cc
index 6d67df2..56030ef 100644
--- a/content/common/gpu/image_transport_surface_android.cc
+++ b/content/common/gpu/image_transport_surface_android.cc
@@ -59,7 +59,7 @@ class DirectSurfaceAndroid : public PassThroughImageTransportSurface {
gfx::GLSurface* surface);
// gfx::GLSurface implementation.
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
protected:
~DirectSurfaceAndroid() override;
@@ -123,7 +123,7 @@ DirectSurfaceAndroid::DirectSurfaceAndroid(GpuChannelManager* manager,
DirectSurfaceAndroid::~DirectSurfaceAndroid() {}
-bool DirectSurfaceAndroid::SwapBuffers() {
+gfx::SwapResult DirectSurfaceAndroid::SwapBuffers() {
DidAccessGpu();
return PassThroughImageTransportSurface::SwapBuffers();
}
diff --git a/content/common/gpu/image_transport_surface_fbo_mac.h b/content/common/gpu/image_transport_surface_fbo_mac.h
index d5a0c20..d39e2459 100644
--- a/content/common/gpu/image_transport_surface_fbo_mac.h
+++ b/content/common/gpu/image_transport_surface_fbo_mac.h
@@ -71,8 +71,8 @@ class ImageTransportSurfaceFBO
void Destroy() override;
bool DeferDraws() override;
bool IsOffscreen() override;
- bool SwapBuffers() override;
- bool PostSubBuffer(int x, int y, int width, int height) override;
+ gfx::SwapResult SwapBuffers() override;
+ gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
bool SupportsPostSubBuffer() override;
gfx::Size GetSize() override;
void* GetHandle() override;
diff --git a/content/common/gpu/image_transport_surface_fbo_mac.mm b/content/common/gpu/image_transport_surface_fbo_mac.mm
index f1aa838..102a6b3 100644
--- a/content/common/gpu/image_transport_surface_fbo_mac.mm
+++ b/content/common/gpu/image_transport_surface_fbo_mac.mm
@@ -169,9 +169,10 @@ void ImageTransportSurfaceFBO::AdjustBufferAllocation() {
}
}
-bool ImageTransportSurfaceFBO::SwapBuffers() {
+gfx::SwapResult ImageTransportSurfaceFBO::SwapBuffers() {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers");
- return SwapBuffersInternal();
+ return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK
+ : gfx::SwapResult::SWAP_FAILED;
}
bool ImageTransportSurfaceFBO::SwapBuffersInternal() {
@@ -208,10 +209,13 @@ void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) {
context_->share_group()->SetRendererID(renderer_id);
}
-bool ImageTransportSurfaceFBO::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult ImageTransportSurfaceFBO::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer");
- return SwapBuffersInternal();
+ return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK
+ : gfx::SwapResult::SWAP_FAILED;
}
bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() {
diff --git a/content/common/gpu/image_transport_surface_mac.mm b/content/common/gpu/image_transport_surface_mac.mm
index 7966d5a..04b6bc3 100644
--- a/content/common/gpu/image_transport_surface_mac.mm
+++ b/content/common/gpu/image_transport_surface_mac.mm
@@ -28,15 +28,15 @@ class DRTSurfaceOSMesa : public gfx::GLSurfaceOSMesa {
: GLSurfaceOSMesa(gfx::OSMesaSurfaceFormatRGBA, gfx::Size(1, 1)) {}
// Implement a subset of GLSurface.
- bool SwapBuffers() override;
+ gfx::SwapResult SwapBuffers() override;
private:
~DRTSurfaceOSMesa() override {}
DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa);
};
-bool DRTSurfaceOSMesa::SwapBuffers() {
- return true;
+gfx::SwapResult DRTSurfaceOSMesa::SwapBuffers() {
+ return gfx::SwapResult::SWAP_ACK;
}
bool g_allow_os_mesa = false;
diff --git a/content/common/gpu/null_transport_surface.cc b/content/common/gpu/null_transport_surface.cc
index ebcea85..33521a0 100644
--- a/content/common/gpu/null_transport_surface.cc
+++ b/content/common/gpu/null_transport_surface.cc
@@ -49,15 +49,17 @@ void NullTransportSurface::Destroy() {
// Do not destroy |surface_| since we use the shared offscreen surface.
}
-bool NullTransportSurface::SwapBuffers() {
+gfx::SwapResult NullTransportSurface::SwapBuffers() {
NOTIMPLEMENTED();
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
-bool NullTransportSurface::PostSubBuffer(
- int x, int y, int width, int height) {
+gfx::SwapResult NullTransportSurface::PostSubBuffer(int x,
+ int y,
+ int width,
+ int height) {
NOTIMPLEMENTED();
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
void NullTransportSurface::SendVSyncUpdateIfAvailable() {
diff --git a/content/common/gpu/null_transport_surface.h b/content/common/gpu/null_transport_surface.h
index 53f86fc..8b78d15 100644
--- a/content/common/gpu/null_transport_surface.h
+++ b/content/common/gpu/null_transport_surface.h
@@ -23,8 +23,8 @@ class NullTransportSurface : public PassThroughImageTransportSurface {
// gfx::GLSurfaceAdapter implementation.
bool Initialize() override;
void Destroy() override;
- bool SwapBuffers() override;
- bool PostSubBuffer(int x, int y, int width, int height) override;
+ gfx::SwapResult SwapBuffers() override;
+ gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
bool OnMakeCurrent(gfx::GLContext* context) override;
protected:
diff --git a/gpu/command_buffer/service/gl_surface_mock.h b/gpu/command_buffer/service/gl_surface_mock.h
index 0652be6..1d756d4 100644
--- a/gpu/command_buffer/service/gl_surface_mock.h
+++ b/gpu/command_buffer/service/gl_surface_mock.h
@@ -5,8 +5,9 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_SURFACE_MOCK_H_
#define GPU_COMMAND_BUFFER_SERVICE_GL_SURFACE_MOCK_H_
-#include "ui/gl/gl_surface.h"
#include "testing/gmock/include/gmock/gmock.h"
+#include "ui/gfx/swap_result.h"
+#include "ui/gl/gl_surface.h"
namespace gpu {
@@ -18,8 +19,9 @@ class GLSurfaceMock : public gfx::GLSurface {
MOCK_METHOD0(Destroy, void());
MOCK_METHOD1(Resize, bool(const gfx::Size& size));
MOCK_METHOD0(IsOffscreen, bool());
- MOCK_METHOD0(SwapBuffers, bool());
- MOCK_METHOD4(PostSubBuffer, bool(int x, int y, int width, int height));
+ MOCK_METHOD0(SwapBuffers, gfx::SwapResult());
+ MOCK_METHOD4(PostSubBuffer,
+ gfx::SwapResult(int x, int y, int width, int height));
MOCK_METHOD0(SupportsPostSubBuffer, bool());
MOCK_METHOD0(GetSize, gfx::Size());
MOCK_METHOD0(GetHandle, void*());
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 1e8e80f..951bbd6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -8485,7 +8485,8 @@ error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(
gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer(
is_offscreen ? offscreen_size_ : surface_->GetSize());
}
- if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) {
+ if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height) !=
+ gfx::SwapResult::SWAP_FAILED) {
return error::kNoError;
} else {
LOG(ERROR) << "Context lost because PostSubBuffer failed.";
@@ -11018,7 +11019,7 @@ void GLES2DecoderImpl::DoSwapBuffers() {
glFlush();
}
} else {
- if (!surface_->SwapBuffers()) {
+ if (surface_->SwapBuffers() == gfx::SwapResult::SWAP_FAILED) {
LOG(ERROR) << "Context lost because SwapBuffers failed.";
if (!CheckResetStatus()) {
MarkContextLost(error::kUnknown);
diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp
index 5c72178..5f315f9 100644
--- a/ui/gfx/gfx.gyp
+++ b/ui/gfx/gfx.gyp
@@ -278,6 +278,7 @@
'skbitmap_operations.h',
'skia_util.cc',
'skia_util.h',
+ 'swap_result.h',
'switches.cc',
'switches.h',
'sys_color_change_listener.cc',
diff --git a/ui/gfx/swap_result.h b/ui/gfx/swap_result.h
new file mode 100644
index 0000000..32a6c5a
--- /dev/null
+++ b/ui/gfx/swap_result.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_SWAP_RESULT_H_
+#define UI_GFX_SWAP_RESULT_H_
+
+namespace gfx {
+
+enum class SwapResult {
+ SWAP_ACK,
+ SWAP_FAILED,
+ SWAP_NAK_RECREATE_BUFFERS,
+ SWAP_RESULT_LAST = SWAP_NAK_RECREATE_BUFFERS,
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_SWAP_RESULT_H_
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() {
diff --git a/ui/ozone/platform/cast/surface_ozone_egl_cast.cc b/ui/ozone/platform/cast/surface_ozone_egl_cast.cc
index 9170240..56dee58 100644
--- a/ui/ozone/platform/cast/surface_ozone_egl_cast.cc
+++ b/ui/ozone/platform/cast/surface_ozone_egl_cast.cc
@@ -23,7 +23,7 @@ bool SurfaceOzoneEglCast::OnSwapBuffers() {
bool SurfaceOzoneEglCast::OnSwapBuffersAsync(
const SwapCompletionCallback& callback) {
- callback.Run();
+ callback.Run(gfx::SwapResult::SWAP_ACK);
return true;
}
diff --git a/ui/ozone/platform/drm/gpu/crtc_controller.cc b/ui/ozone/platform/drm/gpu/crtc_controller.cc
index 6aa5795..cf82f68 100644
--- a/ui/ozone/platform/drm/gpu/crtc_controller.cc
+++ b/ui/ozone/platform/drm/gpu/crtc_controller.cc
@@ -76,7 +76,7 @@ bool CrtcController::SchedulePageFlip(
const OverlayPlane* primary = OverlayPlane::GetPrimaryPlane(overlays);
if (!primary) {
LOG(ERROR) << "No primary plane to display on crtc " << crtc_;
- page_flip_request->Signal();
+ page_flip_request->Signal(gfx::SwapResult::SWAP_ACK);
return true;
}
DCHECK(primary->buffer.get());
@@ -86,19 +86,19 @@ bool CrtcController::SchedulePageFlip(
<< mode_.hdisplay << "x" << mode_.vdisplay << " got "
<< primary->buffer->GetSize().ToString() << " for"
<< " crtc=" << crtc_ << " connector=" << connector_;
- page_flip_request->Signal();
+ page_flip_request->Signal(gfx::SwapResult::SWAP_ACK);
return true;
}
if (!drm_->plane_manager()->AssignOverlayPlanes(plane_list, overlays, crtc_,
this)) {
PLOG(ERROR) << "Failed to assign overlay planes for crtc " << crtc_;
- page_flip_request->Signal();
+ page_flip_request->Signal(gfx::SwapResult::SWAP_FAILED);
return false;
}
if (test_only) {
- page_flip_request->Signal();
+ page_flip_request->Signal(gfx::SwapResult::SWAP_ACK);
} else {
pending_planes_ = overlays;
page_flip_request_ = page_flip_request;
@@ -164,7 +164,7 @@ void CrtcController::SignalPageFlipRequest() {
// locally to avoid deleting the object we are making a call on.
scoped_refptr<PageFlipRequest> last_request;
last_request.swap(page_flip_request_);
- last_request->Signal();
+ last_request->Signal(gfx::SwapResult::SWAP_ACK);
}
}
diff --git a/ui/ozone/platform/drm/gpu/drm_surface.cc b/ui/ozone/platform/drm/gpu/drm_surface.cc
index ccf0ce7..6528dbf 100644
--- a/ui/ozone/platform/drm/gpu/drm_surface.cc
+++ b/ui/ozone/platform/drm/gpu/drm_surface.cc
@@ -20,6 +20,8 @@
namespace ui {
namespace {
+void EmptyPageFlipCallback(gfx::SwapResult result) {
+}
scoped_refptr<DrmBuffer> AllocateBuffer(const scoped_refptr<DrmDevice>& drm,
const gfx::Size& size) {
@@ -71,7 +73,7 @@ void DrmSurface::PresentCanvas(const gfx::Rect& damage) {
UpdateNativeSurface(damage);
window_delegate_->SchedulePageFlip(true /* is_sync */,
- base::Bind(&base::DoNothing));
+ base::Bind(&EmptyPageFlipCallback));
// Update our front buffer pointer.
front_buffer_ ^= 1;
diff --git a/ui/ozone/platform/drm/gpu/drm_window.cc b/ui/ozone/platform/drm/gpu/drm_window.cc
index 2e5b26e..b2f7a46 100644
--- a/ui/ozone/platform/drm/gpu/drm_window.cc
+++ b/ui/ozone/platform/drm/gpu/drm_window.cc
@@ -124,7 +124,8 @@ void DrmWindow::QueueOverlayPlane(const OverlayPlane& plane) {
pending_planes_.push_back(plane);
}
-bool DrmWindow::SchedulePageFlip(bool is_sync, const base::Closure& callback) {
+bool DrmWindow::SchedulePageFlip(bool is_sync,
+ const SwapCompletionCallback& callback) {
last_submitted_planes_.clear();
last_submitted_planes_.swap(pending_planes_);
last_swap_sync_ = is_sync;
@@ -134,7 +135,7 @@ bool DrmWindow::SchedulePageFlip(bool is_sync, const base::Closure& callback) {
callback);
}
- callback.Run();
+ callback.Run(gfx::SwapResult::SWAP_ACK);
return true;
}
diff --git a/ui/ozone/platform/drm/gpu/drm_window.h b/ui/ozone/platform/drm/gpu/drm_window.h
index 74e1e53..1164f17 100644
--- a/ui/ozone/platform/drm/gpu/drm_window.h
+++ b/ui/ozone/platform/drm/gpu/drm_window.h
@@ -11,8 +11,11 @@
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/swap_result.h"
#include "ui/ozone/ozone_export.h"
#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
+#include "ui/ozone/platform/drm/gpu/page_flip_request.h"
+#include "ui/ozone/public/surface_ozone_egl.h"
class SkBitmap;
@@ -79,7 +82,8 @@ class OZONE_EXPORT DrmWindow {
// immediately, otherwise queue up on the window and forward when the hardware
// is once again ready.
void QueueOverlayPlane(const OverlayPlane& plane);
- bool SchedulePageFlip(bool is_sync, const base::Closure& callback);
+
+ bool SchedulePageFlip(bool is_sync, const SwapCompletionCallback& callback);
// Returns the last buffer associated with this window.
const OverlayPlane* GetLastModesetBuffer();
diff --git a/ui/ozone/platform/drm/gpu/gbm_surface.cc b/ui/ozone/platform/drm/gpu/gbm_surface.cc
index 8b5b167..08a32f4 100644
--- a/ui/ozone/platform/drm/gpu/gbm_surface.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_surface.cc
@@ -19,6 +19,9 @@ namespace ui {
namespace {
+void DoNothing(gfx::SwapResult) {
+}
+
class GbmSurfaceBuffer : public GbmBufferBase {
public:
static scoped_refptr<GbmSurfaceBuffer> CreateBuffer(
@@ -131,7 +134,7 @@ bool GbmSurface::ResizeNativeWindow(const gfx::Size& viewport_size) {
}
bool GbmSurface::OnSwapBuffers() {
- return OnSwapBuffersAsync(base::Bind(&base::DoNothing));
+ return OnSwapBuffersAsync(base::Bind(&DoNothing));
}
bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
@@ -144,7 +147,7 @@ bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
primary = GbmSurfaceBuffer::CreateBuffer(gbm_, pending_buffer);
if (!primary.get()) {
LOG(ERROR) << "Failed to associate the buffer with the controller";
- callback.Run();
+ callback.Run(gfx::SwapResult::SWAP_FAILED);
return false;
}
}
@@ -155,7 +158,7 @@ bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
if (!GbmSurfaceless::OnSwapBuffersAsync(
base::Bind(&GbmSurface::OnSwapBuffersCallback,
weak_factory_.GetWeakPtr(), callback, pending_buffer))) {
- callback.Run();
+ callback.Run(gfx::SwapResult::SWAP_FAILED);
return false;
}
@@ -163,13 +166,14 @@ bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
}
void GbmSurface::OnSwapBuffersCallback(const SwapCompletionCallback& callback,
- gbm_bo* pending_buffer) {
+ gbm_bo* pending_buffer,
+ gfx::SwapResult result) {
// If there was a frontbuffer, it is no longer active. Release it back to GBM.
if (current_buffer_)
gbm_surface_release_buffer(native_surface_, current_buffer_);
current_buffer_ = pending_buffer;
- callback.Run();
+ callback.Run(result);
}
} // namespace ui
diff --git a/ui/ozone/platform/drm/gpu/gbm_surface.h b/ui/ozone/platform/drm/gpu/gbm_surface.h
index 65ec8c7..45757ec 100644
--- a/ui/ozone/platform/drm/gpu/gbm_surface.h
+++ b/ui/ozone/platform/drm/gpu/gbm_surface.h
@@ -39,7 +39,8 @@ class GbmSurface : public GbmSurfaceless {
private:
void OnSwapBuffersCallback(const SwapCompletionCallback& callback,
- gbm_bo* pending_buffer);
+ gbm_bo* pending_buffer,
+ gfx::SwapResult result);
scoped_refptr<GbmDevice> gbm_;
diff --git a/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc b/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
index c906cfd..244b8ab 100644
--- a/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
@@ -14,6 +14,10 @@
#include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
namespace ui {
+namespace {
+void EmptyPageFlipCallback(gfx::SwapResult result) {
+}
+} // namespace
GbmSurfaceless::GbmSurfaceless(DrmWindow* window_delegate,
DrmDeviceManager* drm_device_manager)
@@ -35,7 +39,7 @@ bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) {
bool GbmSurfaceless::OnSwapBuffers() {
return window_delegate_->SchedulePageFlip(true /* is_sync */,
- base::Bind(&base::DoNothing));
+ base::Bind(&EmptyPageFlipCallback));
}
bool GbmSurfaceless::OnSwapBuffersAsync(
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
index 3fbfe7f..07cd837 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
@@ -14,6 +14,7 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/swap_result.h"
#include "ui/ozone/platform/drm/gpu/crtc_controller.h"
#include "ui/ozone/platform/drm/gpu/drm_buffer.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
@@ -63,14 +64,14 @@ bool HardwareDisplayController::SchedulePageFlip(
const OverlayPlaneList& plane_list,
bool is_sync,
bool test_only,
- const base::Closure& callback) {
+ const PageFlipCallback& callback) {
TRACE_EVENT0("drm", "HDC::SchedulePageFlip");
DCHECK(!is_disabled_);
// Ignore requests with no planes to schedule.
if (plane_list.empty()) {
- callback.Run();
+ callback.Run(gfx::SwapResult::SWAP_ACK);
return true;
}
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.h b/ui/ozone/platform/drm/gpu/hardware_display_controller.h
index b09d547..3772c35 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.h
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.h
@@ -17,6 +17,7 @@
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
+#include "ui/gfx/swap_result.h"
#include "ui/ozone/ozone_export.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
@@ -86,6 +87,8 @@ class DrmDevice;
// framebuffers. Though, in this case, it would be possible to have all
// connectors active if some use the same CRTC to mirror the display.
class OZONE_EXPORT HardwareDisplayController {
+ typedef base::Callback<void(gfx::SwapResult)> PageFlipCallback;
+
public:
HardwareDisplayController(scoped_ptr<CrtcController> controller,
const gfx::Point& origin);
@@ -123,7 +126,7 @@ class OZONE_EXPORT HardwareDisplayController {
bool SchedulePageFlip(const OverlayPlaneList& plane_list,
bool is_sync,
bool test_only,
- const base::Closure& callback);
+ const PageFlipCallback& callback);
// Set the hardware cursor to show the contents of |surface|.
bool SetCursor(const scoped_refptr<ScanoutBuffer>& buffer);
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc b/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
index 0ff9473..da99c07 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
@@ -54,7 +54,7 @@ class HardwareDisplayControllerTest : public testing::Test {
void SetUp() override;
void TearDown() override;
- void PageFlipCallback();
+ void PageFlipCallback(gfx::SwapResult);
protected:
scoped_ptr<ui::HardwareDisplayController> controller_;
@@ -82,7 +82,7 @@ void HardwareDisplayControllerTest::TearDown() {
drm_ = nullptr;
}
-void HardwareDisplayControllerTest::PageFlipCallback() {
+void HardwareDisplayControllerTest::PageFlipCallback(gfx::SwapResult) {
page_flips_++;
}
diff --git a/ui/ozone/platform/drm/gpu/page_flip_request.cc b/ui/ozone/platform/drm/gpu/page_flip_request.cc
index dfca208..4d1b60d 100644
--- a/ui/ozone/platform/drm/gpu/page_flip_request.cc
+++ b/ui/ozone/platform/drm/gpu/page_flip_request.cc
@@ -4,19 +4,28 @@
#include "ui/ozone/platform/drm/gpu/page_flip_request.h"
-#include "base/barrier_closure.h"
-
namespace ui {
-PageFlipRequest::PageFlipRequest(int crtc_count, const base::Closure& callback)
- : callback_(base::BarrierClosure(crtc_count, callback)) {
+PageFlipRequest::PageFlipRequest(int crtc_count,
+ const SwapCompletionCallback& callback)
+ : callback_(callback),
+ crtc_count_(crtc_count),
+ result_(gfx::SwapResult::SWAP_ACK) {
}
PageFlipRequest::~PageFlipRequest() {
}
-void PageFlipRequest::Signal() {
- callback_.Run();
+void PageFlipRequest::Signal(gfx::SwapResult result) {
+ if (result == gfx::SwapResult::SWAP_FAILED)
+ result_ = gfx::SwapResult::SWAP_FAILED;
+ else if (result != gfx::SwapResult::SWAP_ACK)
+ result_ = result;
+
+ if (!--crtc_count_) {
+ callback_.Run(result_);
+ callback_.Reset();
+ }
}
} // namespace ui
diff --git a/ui/ozone/platform/drm/gpu/page_flip_request.h b/ui/ozone/platform/drm/gpu/page_flip_request.h
index c1a63b2..6daa8a3 100644
--- a/ui/ozone/platform/drm/gpu/page_flip_request.h
+++ b/ui/ozone/platform/drm/gpu/page_flip_request.h
@@ -5,22 +5,27 @@
#ifndef UI_OZONE_PLATFORM_DRM_GPU_PAGE_FLIP_REQUEST_H_
#define UI_OZONE_PLATFORM_DRM_GPU_PAGE_FLIP_REQUEST_H_
+#include "base/atomic_ref_count.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/swap_result.h"
+#include "ui/ozone/public/surface_ozone_egl.h"
namespace ui {
class PageFlipRequest : public base::RefCounted<PageFlipRequest> {
public:
- PageFlipRequest(int crtc_count, const base::Closure& callback);
+ PageFlipRequest(int crtc_count, const SwapCompletionCallback& callback);
- void Signal();
+ void Signal(gfx::SwapResult result);
private:
friend class base::RefCounted<PageFlipRequest>;
~PageFlipRequest();
- base::Closure callback_;
+ SwapCompletionCallback callback_;
+ int crtc_count_;
+ gfx::SwapResult result_;
DISALLOW_COPY_AND_ASSIGN(PageFlipRequest);
};
diff --git a/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc b/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
index bd8671b..f8b59a6 100644
--- a/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
+++ b/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
@@ -14,6 +14,9 @@
namespace {
+void EmptySwapCallback(gfx::SwapResult) {
+}
+
// Create a basic mode for a 6x4 screen.
const drmModeModeInfo kDefaultMode =
{0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}};
@@ -459,7 +462,7 @@ TEST_F(ScreenManagerTest, EnableControllerWhenWindowHasBuffer) {
scoped_refptr<ui::ScanoutBuffer> buffer =
buffer_generator_->Create(drm_, GetPrimaryBounds().size());
window->QueueOverlayPlane(ui::OverlayPlane(buffer));
- window->SchedulePageFlip(false /* is_sync */, base::Bind(&base::DoNothing));
+ window->SchedulePageFlip(false /* is_sync */, base::Bind(&EmptySwapCallback));
screen_manager_->AddWindow(1, window.Pass());
screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector);
diff --git a/ui/ozone/platform/egltest/ozone_platform_egltest.cc b/ui/ozone/platform/egltest/ozone_platform_egltest.cc
index 73ff47b..31f35a6 100644
--- a/ui/ozone/platform/egltest/ozone_platform_egltest.cc
+++ b/ui/ozone/platform/egltest/ozone_platform_egltest.cc
@@ -216,7 +216,7 @@ class SurfaceOzoneEgltest : public SurfaceOzoneEGL {
bool OnSwapBuffers() override { return true; }
bool OnSwapBuffersAsync(const SwapCompletionCallback& callback) override {
- callback.Run();
+ callback.Run(gfx::SwapResult::SWAP_ACK);
return true;
}
diff --git a/ui/ozone/public/surface_ozone_egl.h b/ui/ozone/public/surface_ozone_egl.h
index 1714dd9..3056dec 100644
--- a/ui/ozone/public/surface_ozone_egl.h
+++ b/ui/ozone/public/surface_ozone_egl.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/overlay_transform.h"
+#include "ui/gfx/swap_result.h"
#include "ui/ozone/ozone_base_export.h"
namespace gfx {
@@ -19,6 +20,8 @@ class VSyncProvider;
namespace ui {
class NativePixmap;
+typedef base::Callback<void(gfx::SwapResult)> SwapCompletionCallback;
+
// The platform-specific part of an EGL surface.
//
// This class owns any bits that the ozone implementation needs freed when
@@ -39,7 +42,6 @@ class OZONE_BASE_EXPORT SurfaceOzoneEGL {
// be used to present the new front buffer if the platform requires this.
virtual bool OnSwapBuffers() = 0;
- typedef base::Closure SwapCompletionCallback;
// Called after we swap buffers. This is usually a no-op but can
// be used to present the new front buffer if the platform requires this.
// The callback should be run on the calling thread