Commit ff8129e2 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Android/viz: Properly handle empty swaps

Android does not support partial swaps. Instead, when an empty swap
is requested we're supposed to commit overlay planes.

Bug: 850546
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: If77156732b4f43872855a8ad676c42a5e9842678
Reviewed-on: https://chromium-review.googlesource.com/1099266Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Saman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567042}
parent 3d99ccce
......@@ -274,6 +274,13 @@ viz_component("service") {
]
}
if (is_android) {
sources += [
"display_embedder/gl_output_surface_android.cc",
"display_embedder/gl_output_surface_android.h",
]
}
if (enable_vulkan) {
deps += [ "//gpu/vulkan" ]
}
......
......@@ -106,9 +106,8 @@ void GLOutputSurface::SwapBuffers(OutputSurfaceFrame frame) {
set_draw_rectangle_for_frame_ = false;
if (frame.sub_buffer_rect) {
context_provider_->ContextSupport()->PartialSwapBuffers(
*frame.sub_buffer_rect, flags, std::move(swap_callback),
std::move(presentation_callback));
HandlePartialSwap(*frame.sub_buffer_rect, flags, std::move(swap_callback),
std::move(presentation_callback));
} else {
context_provider_->ContextSupport()->Swap(flags, std::move(swap_callback),
std::move(presentation_callback));
......@@ -149,6 +148,16 @@ void GLOutputSurface::DidReceiveSwapBuffersAck(gfx::SwapResult result) {
client_->DidReceiveSwapBuffersAck();
}
void GLOutputSurface::HandlePartialSwap(
const gfx::Rect& sub_buffer_rect,
uint32_t flags,
gpu::ContextSupport::SwapCompletedCallback swap_callback,
gpu::ContextSupport::PresentationCallback presentation_callback) {
context_provider_->ContextSupport()->PartialSwapBuffers(
sub_buffer_rect, flags, std::move(swap_callback),
std::move(presentation_callback));
}
void GLOutputSurface::OnGpuSwapBuffersCompleted(
std::vector<ui::LatencyInfo> latency_info,
const gfx::Size& pixel_size,
......
......@@ -9,6 +9,7 @@
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display_embedder/viz_process_context_provider.h"
#include "gpu/command_buffer/client/context_support.h"
#include "ui/latency/latency_tracker.h"
namespace viz {
......@@ -55,6 +56,15 @@ class GLOutputSurface : public OutputSurface {
// Called when a swap completion is signaled from ImageTransportSurface.
virtual void DidReceiveSwapBuffersAck(gfx::SwapResult result);
// Called in SwapBuffers() when a swap is determined to be partial. Subclasses
// might override this method because different platforms handle partial swaps
// differently.
virtual void HandlePartialSwap(
const gfx::Rect& sub_buffer_rect,
uint32_t flags,
gpu::ContextSupport::SwapCompletedCallback swap_callback,
gpu::ContextSupport::PresentationCallback presentation_callback);
private:
// Called when a swap completion is signaled from ImageTransportSurface.
void OnGpuSwapBuffersCompleted(std::vector<ui::LatencyInfo> latency_info,
......
// Copyright 2018 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.
#include "components/viz/service/display_embedder/gl_output_surface_android.h"
namespace viz {
GLOutputSurfaceAndroid::GLOutputSurfaceAndroid(
scoped_refptr<VizProcessContextProvider> context_provider,
SyntheticBeginFrameSource* synthetic_begin_frame_source)
: GLOutputSurface(context_provider, synthetic_begin_frame_source) {}
GLOutputSurfaceAndroid::~GLOutputSurfaceAndroid() = default;
void GLOutputSurfaceAndroid::HandlePartialSwap(
const gfx::Rect& sub_buffer_rect,
uint32_t flags,
gpu::ContextSupport::SwapCompletedCallback swap_callback,
gpu::ContextSupport::PresentationCallback presentation_callback) {
DCHECK(sub_buffer_rect.IsEmpty());
context_provider_->ContextSupport()->CommitOverlayPlanes(
flags, std::move(swap_callback), std::move(presentation_callback));
}
} // namespace viz
// Copyright 2018 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 COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_GL_OUTPUT_SURFACE_ANDROID_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_GL_OUTPUT_SURFACE_ANDROID_H_
#include <memory>
#include "components/viz/service/display_embedder/gl_output_surface.h"
namespace viz {
class GLOutputSurfaceAndroid : public GLOutputSurface {
public:
GLOutputSurfaceAndroid(
scoped_refptr<VizProcessContextProvider> context_provider,
SyntheticBeginFrameSource* synthetic_begin_frame_source);
~GLOutputSurfaceAndroid() override;
// GLOutputSurface implementation:
void HandlePartialSwap(
const gfx::Rect& sub_buffer_rect,
uint32_t flags,
gpu::ContextSupport::SwapCompletedCallback swap_callback,
gpu::ContextSupport::PresentationCallback presentation_callback) override;
private:
DISALLOW_COPY_AND_ASSIGN(GLOutputSurfaceAndroid);
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_GL_OUTPUT_SURFACE_ANDROID_H_
......@@ -35,6 +35,10 @@
#include "components/viz/service/display_embedder/software_output_device_win.h"
#endif
#if defined(OS_ANDROID)
#include "components/viz/service/display_embedder/gl_output_surface_android.h"
#endif
#if defined(OS_MACOSX)
#include "components/viz/service/display_embedder/gl_output_surface_mac.h"
#include "components/viz/service/display_embedder/software_output_device_mac.h"
......@@ -171,6 +175,9 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
output_surface = std::make_unique<GLOutputSurfaceWin>(
std::move(context_provider), synthetic_begin_frame_source.get(),
use_overlays);
#elif defined(OS_ANDROID)
output_surface = std::make_unique<GLOutputSurfaceAndroid>(
std::move(context_provider), synthetic_begin_frame_source.get());
#else
output_surface = std::make_unique<GLOutputSurface>(
std::move(context_provider), synthetic_begin_frame_source.get());
......
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