Commit 55bf5b20 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

SkiaRenderer/macOS: Update ImageTransportSurfaceOverlayMac

Add async swap methods. At present, these just post the passed-in
callbacks, but may be made to be more async in the future.

Add an origin value that does not cause SkiaRenderer to DCHECK (and is
also accurate).

Bug: 894929
Change-Id: I97b484da4de6ed98b5b568135fb2c07bed46a690
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219561Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773226}
parent 92909c3d
......@@ -58,13 +58,25 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass,
bool IsOffscreen() override;
gfx::SwapResult SwapBuffers(
gl::GLSurface::PresentationCallback callback) override;
void SwapBuffersAsync(
gl::GLSurface::SwapCompletionCallback completion_callback,
gl::GLSurface::PresentationCallback presentation_callback) override;
gfx::SwapResult PostSubBuffer(
int x,
int y,
int width,
int height,
gl::GLSurface::PresentationCallback callback) override;
void PostSubBufferAsync(
int x,
int y,
int width,
int height,
gl::GLSurface::SwapCompletionCallback completion_callback,
gl::GLSurface::PresentationCallback presentation_callback) override;
bool SupportsPostSubBuffer() override;
bool SupportsAsyncSwap() override;
gfx::Size GetSize() override;
void* GetHandle() override;
gl::GLSurfaceFormat GetFormat() override;
......@@ -80,6 +92,7 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass,
void ScheduleCALayerInUseQuery(
std::vector<gl::GLSurface::CALayerInUseQuery> queries) override;
bool IsSurfaceless() const override;
gfx::SurfaceOrigin GetOrigin() const override;
// ui::GpuSwitchingObserver implementation.
void OnGpuSwitched(gl::GpuPreference active_gpu_heuristic) override;
......@@ -89,7 +102,8 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass,
gfx::SwapResult SwapBuffersInternal(
const gfx::Rect& pixel_damage_rect,
gl::GLSurface::PresentationCallback callback);
gl::GLSurface::SwapCompletionCallback completion_callback,
gl::GLSurface::PresentationCallback presentation_callback);
void ApplyBackpressure();
void BufferPresented(gl::GLSurface::PresentationCallback callback,
const gfx::PresentationFeedback& feedback);
......
......@@ -113,7 +113,8 @@ template <typename BaseClass>
gfx::SwapResult
ImageTransportSurfaceOverlayMacBase<BaseClass>::SwapBuffersInternal(
const gfx::Rect& pixel_damage_rect,
gl::GLSurface::PresentationCallback callback) {
gl::GLSurface::SwapCompletionCallback completion_callback,
gl::GLSurface::PresentationCallback presentation_callback) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
// Do a GL fence for flush to apply back-pressure before drawing.
......@@ -173,6 +174,12 @@ ImageTransportSurfaceOverlayMacBase<BaseClass>::SwapBuffersInternal(
}
// Send the swap parameters to the browser.
if (completion_callback) {
std::unique_ptr<gfx::GpuFence> fence;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(completion_callback),
gfx::SwapResult::SWAP_ACK, std::move(fence)));
}
delegate_->DidSwapBuffersComplete(std::move(params));
constexpr int64_t kRefreshIntervalInMicroseconds =
base::Time::kMicrosecondsPerSecond / 60;
......@@ -184,7 +191,8 @@ ImageTransportSurfaceOverlayMacBase<BaseClass>::SwapBuffersInternal(
FROM_HERE,
base::BindOnce(
&ImageTransportSurfaceOverlayMacBase<BaseClass>::BufferPresented,
weak_ptr_factory_.GetWeakPtr(), std::move(callback), feedback));
weak_ptr_factory_.GetWeakPtr(), std::move(presentation_callback),
feedback));
return gfx::SwapResult::SWAP_ACK;
}
......@@ -193,7 +201,16 @@ gfx::SwapResult ImageTransportSurfaceOverlayMacBase<BaseClass>::SwapBuffers(
gl::GLSurface::PresentationCallback callback) {
return SwapBuffersInternal(
gfx::Rect(0, 0, pixel_size_.width(), pixel_size_.height()),
std::move(callback));
base::DoNothing(), std::move(callback));
}
template <typename BaseClass>
void ImageTransportSurfaceOverlayMacBase<BaseClass>::SwapBuffersAsync(
gl::GLSurface::SwapCompletionCallback completion_callback,
gl::GLSurface::PresentationCallback presentation_callback) {
SwapBuffersInternal(
gfx::Rect(0, 0, pixel_size_.width(), pixel_size_.height()),
std::move(completion_callback), std::move(presentation_callback));
}
template <typename BaseClass>
......@@ -203,15 +220,33 @@ gfx::SwapResult ImageTransportSurfaceOverlayMacBase<BaseClass>::PostSubBuffer(
int width,
int height,
gl::GLSurface::PresentationCallback callback) {
return SwapBuffersInternal(gfx::Rect(x, y, width, height),
return SwapBuffersInternal(gfx::Rect(x, y, width, height), base::DoNothing(),
std::move(callback));
}
template <typename BaseClass>
void ImageTransportSurfaceOverlayMacBase<BaseClass>::PostSubBufferAsync(
int x,
int y,
int width,
int height,
gl::GLSurface::SwapCompletionCallback completion_callback,
gl::GLSurface::PresentationCallback presentation_callback) {
SwapBuffersInternal(gfx::Rect(x, y, width, height),
std::move(completion_callback),
std::move(presentation_callback));
}
template <typename BaseClass>
bool ImageTransportSurfaceOverlayMacBase<BaseClass>::SupportsPostSubBuffer() {
return true;
}
template <typename BaseClass>
bool ImageTransportSurfaceOverlayMacBase<BaseClass>::SupportsAsyncSwap() {
return true;
}
template <typename BaseClass>
gfx::Size ImageTransportSurfaceOverlayMacBase<BaseClass>::GetSize() {
return gfx::Size();
......@@ -303,6 +338,12 @@ bool ImageTransportSurfaceOverlayMacBase<BaseClass>::IsSurfaceless() const {
return true;
}
template <typename BaseClass>
gfx::SurfaceOrigin ImageTransportSurfaceOverlayMacBase<BaseClass>::GetOrigin()
const {
return gfx::SurfaceOrigin::kTopLeft;
}
template <typename BaseClass>
bool ImageTransportSurfaceOverlayMacBase<BaseClass>::Resize(
const gfx::Size& pixel_size,
......
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