Commit 4cc26d55 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

PresentationCallback: trun on it for Mac

Bug: 776877
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I0c1e2c3be1569cc89385e210d9fabfa1ecda6a84
Reviewed-on: https://chromium-review.googlesource.com/1054336Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558756}
parent 0c5ac919
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "gpu/ipc/service/image_transport_surface.h" #include "gpu/ipc/service/image_transport_surface.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gpu/ipc/service/image_transport_surface_overlay_mac.h" #include "gpu/ipc/service/image_transport_surface_overlay_mac.h"
#include "gpu/ipc/service/pass_through_image_transport_surface.h" #include "gpu/ipc/service/pass_through_image_transport_surface.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
...@@ -27,6 +28,7 @@ class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa { ...@@ -27,6 +28,7 @@ class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa {
// Implement a subset of GLSurface. // Implement a subset of GLSurface.
gfx::SwapResult SwapBuffers(const PresentationCallback& callback) override; gfx::SwapResult SwapBuffers(const PresentationCallback& callback) override;
bool SupportsPresentationCallback() override;
private: private:
~DRTSurfaceOSMesa() override {} ~DRTSurfaceOSMesa() override {}
...@@ -35,9 +37,17 @@ class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa { ...@@ -35,9 +37,17 @@ class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa {
gfx::SwapResult DRTSurfaceOSMesa::SwapBuffers( gfx::SwapResult DRTSurfaceOSMesa::SwapBuffers(
const PresentationCallback& callback) { const PresentationCallback& callback) {
gfx::PresentationFeedback feedback(base::TimeTicks::Now(), base::TimeDelta(),
0 /* flags */);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(callback, std::move(feedback)));
return gfx::SwapResult::SWAP_ACK; return gfx::SwapResult::SWAP_ACK;
} }
bool DRTSurfaceOSMesa::SupportsPresentationCallback() {
return true;
}
bool g_allow_os_mesa = false; bool g_allow_os_mesa = false;
} // namespace } // namespace
......
...@@ -64,6 +64,7 @@ class ImageTransportSurfaceOverlayMac : public gl::GLSurface, ...@@ -64,6 +64,7 @@ class ImageTransportSurfaceOverlayMac : public gl::GLSurface,
void ScheduleCALayerInUseQuery( void ScheduleCALayerInUseQuery(
std::vector<CALayerInUseQuery> queries) override; std::vector<CALayerInUseQuery> queries) override;
bool IsSurfaceless() const override; bool IsSurfaceless() const override;
bool SupportsPresentationCallback() override;
// ui::GpuSwitchingObserver implementation. // ui::GpuSwitchingObserver implementation.
void OnGpuSwitched() override; void OnGpuSwitched() override;
...@@ -74,7 +75,8 @@ class ImageTransportSurfaceOverlayMac : public gl::GLSurface, ...@@ -74,7 +75,8 @@ class ImageTransportSurfaceOverlayMac : public gl::GLSurface,
void SetSnapshotRequested(); void SetSnapshotRequested();
bool GetAndResetSnapshotRequested(); bool GetAndResetSnapshotRequested();
gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect,
const PresentationCallback& callback);
void ApplyBackpressure(base::TimeTicks* before_flush_time, void ApplyBackpressure(base::TimeTicks* before_flush_time,
base::TimeTicks* after_flush_before_commit_time); base::TimeTicks* after_flush_before_commit_time);
......
...@@ -183,7 +183,8 @@ void ImageTransportSurfaceOverlayMac::ApplyBackpressure( ...@@ -183,7 +183,8 @@ void ImageTransportSurfaceOverlayMac::ApplyBackpressure(
} }
gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
const gfx::Rect& pixel_damage_rect) { const gfx::Rect& pixel_damage_rect,
const PresentationCallback& callback) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
// Do a GL fence for flush to apply back-pressure before drawing. // Do a GL fence for flush to apply back-pressure before drawing.
...@@ -242,16 +243,21 @@ gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( ...@@ -242,16 +243,21 @@ gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
// Send the swap parameters to the browser. // Send the swap parameters to the browser.
delegate_->DidSwapBuffersComplete(std::move(params)); delegate_->DidSwapBuffersComplete(std::move(params));
constexpr int64_t kRefreshIntervalInMicroseconds =
base::Time::kMicrosecondsPerSecond / 60;
gfx::PresentationFeedback feedback(
base::TimeTicks::Now(),
base::TimeDelta::FromMicroseconds(kRefreshIntervalInMicroseconds),
0 /* flags */);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(callback, std::move(feedback)));
return gfx::SwapResult::SWAP_ACK; return gfx::SwapResult::SWAP_ACK;
} }
gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffers( gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffers(
const PresentationCallback& callback) { const PresentationCallback& callback) {
// TODO(penghuang): Provide useful presentation feedback.
// https://crbug.com/776877
return SwapBuffersInternal( return SwapBuffersInternal(
gfx::Rect(0, 0, pixel_size_.width(), pixel_size_.height())); gfx::Rect(0, 0, pixel_size_.width(), pixel_size_.height()), callback);
} }
gfx::SwapResult ImageTransportSurfaceOverlayMac::PostSubBuffer( gfx::SwapResult ImageTransportSurfaceOverlayMac::PostSubBuffer(
...@@ -260,9 +266,7 @@ gfx::SwapResult ImageTransportSurfaceOverlayMac::PostSubBuffer( ...@@ -260,9 +266,7 @@ gfx::SwapResult ImageTransportSurfaceOverlayMac::PostSubBuffer(
int width, int width,
int height, int height,
const PresentationCallback& callback) { const PresentationCallback& callback) {
// TODO(penghuang): Provide useful presentation feedback. return SwapBuffersInternal(gfx::Rect(x, y, width, height), callback);
// https://crbug.com/776877
return SwapBuffersInternal(gfx::Rect(x, y, width, height));
} }
bool ImageTransportSurfaceOverlayMac::SupportsPostSubBuffer() { bool ImageTransportSurfaceOverlayMac::SupportsPostSubBuffer() {
...@@ -348,6 +352,10 @@ bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { ...@@ -348,6 +352,10 @@ bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const {
return true; return true;
} }
bool ImageTransportSurfaceOverlayMac::SupportsPresentationCallback() {
return true;
}
bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size,
float scale_factor, float scale_factor,
ColorSpace color_space, ColorSpace color_space,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/gl/gl_surface_stub.h" #include "ui/gl/gl_surface_stub.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
namespace gl { namespace gl {
...@@ -24,8 +25,10 @@ bool GLSurfaceStub::IsOffscreen() { ...@@ -24,8 +25,10 @@ bool GLSurfaceStub::IsOffscreen() {
gfx::SwapResult GLSurfaceStub::SwapBuffers( gfx::SwapResult GLSurfaceStub::SwapBuffers(
const PresentationCallback& callback) { const PresentationCallback& callback) {
callback.Run(gfx::PresentationFeedback(base::TimeTicks::Now(), gfx::PresentationFeedback feedback(base::TimeTicks::Now(), base::TimeDelta(),
base::TimeDelta(), 0 /* flags */)); 0 /* flags */);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(callback, std::move(feedback)));
return gfx::SwapResult::SWAP_ACK; return gfx::SwapResult::SWAP_ACK;
} }
......
...@@ -14,7 +14,7 @@ namespace gl { ...@@ -14,7 +14,7 @@ namespace gl {
bool IsPresentationCallbackEnabled() { bool IsPresentationCallbackEnabled() {
// TODO(peng): always enable once 776877 is fixed. // TODO(peng): always enable once 776877 is fixed.
#if defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_LINUX) || \ #if defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_LINUX) || \
defined(OS_WIN) defined(OS_WIN) || defined(OS_MACOSX)
return true; return true;
#else #else
return base::CommandLine::ForCurrentProcess()->HasSwitch( return base::CommandLine::ForCurrentProcess()->HasSwitch(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment