Commit 7a2a92a8 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

SkiaOutputDeviceGL: support CommitOverlayPlanes.

For non surface control case. SkiaOutputDeviceGL is used. Without
CommitOverlayPlanes support, we will always redraw the whole frame even
if chrome is playing video fullscreen. This CL add CommitOverlayPlanes
for SkiaOutputDeviceGL. It should save power for fullscreen video
playback case.

Bug: 1043667
Change-Id: I4924f039b935ed61ff20535c6652993582bffdd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010173Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733401}
parent 35b7e3a2
......@@ -40,7 +40,8 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
std::move(did_swap_buffer_complete_callback)),
mailbox_manager_(mailbox_manager),
context_state_(context_state),
gl_surface_(std::move(gl_surface)) {
gl_surface_(std::move(gl_surface)),
supports_async_swap_(gl_surface_->SupportsAsyncSwap()) {
capabilities_.flipped_output_surface = gl_surface_->FlipsVertically();
capabilities_.supports_post_sub_buffer = gl_surface_->SupportsPostSubBuffer();
if (feature_info->workarounds()
......@@ -48,6 +49,8 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
capabilities_.supports_post_sub_buffer = false;
}
capabilities_.max_frames_pending = gl_surface_->GetBufferCount() - 1;
capabilities_.supports_commit_overlay_planes =
gl_surface_->SupportsCommitOverlayPlanes();
capabilities_.supports_gpu_vsync = gl_surface_->SupportsGpuVSync();
capabilities_.supports_dc_layers = gl_surface_->SupportsDCLayers();
capabilities_.supports_dc_video_overlays = gl_surface_->UseOverlaysForVideo();
......@@ -147,7 +150,7 @@ void SkiaOutputDeviceGL::SwapBuffers(
gfx::Size surface_size =
gfx::Size(sk_surface_->width(), sk_surface_->height());
if (gl_surface_->SupportsAsyncSwap()) {
if (supports_async_swap_) {
auto callback = base::BindOnce(&SkiaOutputDeviceGL::DoFinishSwapBuffers,
weak_ptr_factory_.GetWeakPtr(), surface_size,
std::move(latency_info));
......@@ -167,7 +170,7 @@ void SkiaOutputDeviceGL::PostSubBuffer(
gfx::Size surface_size =
gfx::Size(sk_surface_->width(), sk_surface_->height());
if (gl_surface_->SupportsAsyncSwap()) {
if (supports_async_swap_) {
auto callback = base::BindOnce(&SkiaOutputDeviceGL::DoFinishSwapBuffers,
weak_ptr_factory_.GetWeakPtr(), surface_size,
std::move(latency_info));
......@@ -183,6 +186,26 @@ void SkiaOutputDeviceGL::PostSubBuffer(
}
}
void SkiaOutputDeviceGL::CommitOverlayPlanes(
BufferPresentedCallback feedback,
std::vector<ui::LatencyInfo> latency_info) {
StartSwapBuffers({});
gfx::Size surface_size =
gfx::Size(sk_surface_->width(), sk_surface_->height());
if (supports_async_swap_) {
auto callback = base::BindOnce(&SkiaOutputDeviceGL::DoFinishSwapBuffers,
weak_ptr_factory_.GetWeakPtr(), surface_size,
std::move(latency_info));
gl_surface_->CommitOverlayPlanesAsync(std::move(callback),
std::move(feedback));
} else {
FinishSwapBuffers(gl_surface_->CommitOverlayPlanes(std::move(feedback)),
surface_size, std::move(latency_info));
}
}
void SkiaOutputDeviceGL::DoFinishSwapBuffers(
const gfx::Size& size,
std::vector<ui::LatencyInfo> latency_info,
......
......@@ -61,6 +61,8 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
void PostSubBuffer(const gfx::Rect& rect,
BufferPresentedCallback feedback,
std::vector<ui::LatencyInfo> latency_info) override;
void CommitOverlayPlanes(BufferPresentedCallback feedback,
std::vector<ui::LatencyInfo> latency_info) override;
void SetDrawRectangle(const gfx::Rect& draw_rectangle) override;
void SetGpuVSyncEnabled(bool enabled) override;
#if defined(OS_WIN)
......@@ -86,6 +88,7 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
gpu::SharedContextState* const context_state_;
scoped_refptr<gl::GLSurface> gl_surface_;
const bool supports_async_swap_;
sk_sp<SkSurface> sk_surface_;
......
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