Commit bf52c846 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Support presentation feedback for several GLSurface impls on Windows.

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: Ic3263a6a8701cb9f99bcae657f041e624dc8ca01
Reviewed-on: https://chromium-review.googlesource.com/1011674
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553298}
parent 9befa4c9
......@@ -1409,6 +1409,10 @@ bool DirectCompositionSurfaceWin::FlipsVertically() const {
return true;
}
bool DirectCompositionSurfaceWin::SupportsPresentationCallback() {
return true;
}
bool DirectCompositionSurfaceWin::SupportsPostSubBuffer() {
return true;
}
......
......@@ -66,6 +66,7 @@ class GPU_IPC_SERVICE_EXPORT DirectCompositionSurfaceWin
gfx::VSyncProvider* GetVSyncProvider() override;
bool SetEnableDCLayers(bool enable) override;
bool FlipsVertically() const override;
bool SupportsPresentationCallback() override;
bool SupportsPostSubBuffer() override;
bool OnMakeCurrent(gl::GLContext* context) override;
bool SupportsDCLayers() const override;
......
......@@ -69,6 +69,10 @@ gfx::SwapResult GLSurfaceOSMesaWin::SwapBuffers(
return PostSubBuffer(0, 0, size.width(), size.height(), callback);
}
bool GLSurfaceOSMesaWin::SupportsPresentationCallback() {
return true;
}
bool GLSurfaceOSMesaWin::SupportsPostSubBuffer() {
return true;
}
......@@ -79,8 +83,6 @@ gfx::SwapResult GLSurfaceOSMesaWin::PostSubBuffer(
int width,
int height,
const PresentationCallback& callback) {
// TODO(penghuang): Provide useful presentation feedback.
// https://crbug.com/776877
DCHECK(device_context_);
gfx::Size size = GetSize();
......@@ -109,6 +111,12 @@ gfx::SwapResult GLSurfaceOSMesaWin::PostSubBuffer(
x, y, width, height, GetHandle(),
reinterpret_cast<BITMAPINFO*>(&info), DIB_RGB_COLORS, SRCCOPY);
constexpr int64_t kRefreshIntervalInMicroseconds =
base::Time::kMicrosecondsPerSecond / 60;
callback.Run(gfx::PresentationFeedback(
base::TimeTicks::Now(),
base::TimeDelta::FromMicroseconds(kRefreshIntervalInMicroseconds),
0 /* flags */));
return gfx::SwapResult::SWAP_ACK;
}
......
......@@ -26,6 +26,7 @@ class GL_EXPORT GLSurfaceOSMesaWin : public GLSurfaceOSMesa {
void Destroy() override;
bool IsOffscreen() override;
gfx::SwapResult SwapBuffers(const PresentationCallback& callback) override;
bool SupportsPresentationCallback() override;
bool SupportsPostSubBuffer() override;
gfx::SwapResult PostSubBuffer(int x,
int y,
......
......@@ -310,8 +310,19 @@ gfx::SwapResult NativeViewGLSurfaceWGL::SwapBuffers(
}
DCHECK(device_context_);
return ::SwapBuffers(device_context_) == TRUE ? gfx::SwapResult::SWAP_ACK
: gfx::SwapResult::SWAP_FAILED;
if (::SwapBuffers(device_context_) == TRUE) {
// TODO(penghuang): Provide more accurate values for presentation feedback.
constexpr int64_t kRefreshIntervalInMicroseconds =
base::Time::kMicrosecondsPerSecond / 60;
callback.Run(gfx::PresentationFeedback(
base::TimeTicks::Now(),
base::TimeDelta::FromMicroseconds(kRefreshIntervalInMicroseconds),
0 /* flags */));
return gfx::SwapResult::SWAP_ACK;
} else {
callback.Run(gfx::PresentationFeedback());
return gfx::SwapResult::SWAP_FAILED;
}
}
gfx::Size NativeViewGLSurfaceWGL::GetSize() {
......@@ -329,6 +340,10 @@ GLSurfaceFormat NativeViewGLSurfaceWGL::GetFormat() {
return GLSurfaceFormat();
}
bool NativeViewGLSurfaceWGL::SupportsPresentationCallback() {
return true;
}
PbufferGLSurfaceWGL::PbufferGLSurfaceWGL(const gfx::Size& size)
: size_(size),
device_context_(NULL),
......
......@@ -51,6 +51,7 @@ class GL_EXPORT NativeViewGLSurfaceWGL : public GLSurfaceWGL {
gfx::Size GetSize() override;
void* GetHandle() override;
GLSurfaceFormat GetFormat() override;
bool SupportsPresentationCallback() override;
private:
~NativeViewGLSurfaceWGL() override;
......
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