Commit bb336397 authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

viz: Set up OverlayProcessor's API to Send Overlays to the Gpu Thread

Set up an API to send overlay to gpu thread. This makes use of the
newly create OverlayProcessorOnGpu class.

This is CL 3/? for sending the overlay candidate directly to gpu thread.

R=rjkroege

Bug: 979788
Change-Id: Ibf1b814c5bec02b8633e3af32698f08672b533a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985302
Commit-Queue: weiliangc <weiliangc@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732615}
parent d26a7d15
......@@ -32,6 +32,7 @@ OverlayProcessorAndroid::OverlayProcessorAndroid(
base::Unretained(this));
gpu_task_scheduler_->ScheduleGpuTask(std::move(callback), {});
}
// For Android, we do not have the ability to skip an overlay, since the
// texture is already in a SurfaceView. Ideally, we would honor a 'force
// overlay' flag that FromDrawQuad would also check.
......@@ -41,6 +42,8 @@ OverlayProcessorAndroid::OverlayProcessorAndroid(
// https://crbug.com/842931 .
strategies_.push_back(std::make_unique<OverlayStrategyUnderlay>(
this, OverlayStrategyUnderlay::OpaqueMode::AllowTransparentCandidates));
overlay_candidates_.clear();
}
OverlayProcessorAndroid::~OverlayProcessorAndroid() {
......@@ -76,6 +79,31 @@ bool OverlayProcessorAndroid::NeedsSurfaceOccludingDamageRect() const {
return false;
}
void OverlayProcessorAndroid::ScheduleOverlays(
DisplayResourceProvider* resource_provider) {
if (!gpu_task_scheduler_)
return;
std::vector<
std::unique_ptr<DisplayResourceProvider::ScopedReadLockSharedImage>>
locks;
for (auto& candidate : overlay_candidates_) {
locks.emplace_back(
std::make_unique<DisplayResourceProvider::ScopedReadLockSharedImage>(
resource_provider, candidate.resource_id));
}
std::vector<gpu::SyncToken> locks_sync_tokens;
for (auto& read_lock : locks)
locks_sync_tokens.push_back(read_lock->sync_token());
auto task = base::BindOnce(&OverlayProcessorOnGpu::ScheduleOverlays,
base::Unretained(processor_on_gpu_.get()),
std::move(overlay_candidates_));
gpu_task_scheduler_->ScheduleGpuTask(std::move(task), locks_sync_tokens);
overlay_candidates_.clear();
}
void OverlayProcessorAndroid::CheckOverlaySupport(
const OverlayProcessorInterface::OutputSurfaceOverlayPlane* primary_plane,
OverlayCandidateList* candidates) {
......
......@@ -36,6 +36,8 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
bool NeedsSurfaceOccludingDamageRect() const override;
void ScheduleOverlays(
DisplayResourceProvider* display_resource_provider) override;
// Override OverlayProcessorUsingStrategy.
void SetDisplayTransformHint(gfx::OverlayTransform transform) override {}
void SetViewportSize(const gfx::Size& size) override {}
......@@ -52,9 +54,10 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
// teardown the gpu side receiver.
void InitializeOverlayProcessorOnGpu();
void DestroyOverlayProcessorOnGpu(base::WaitableEvent* event);
void NotifyOverlayPromotion(DisplayResourceProvider* resource_provider,
const OverlayCandidateList& candidate_list,
const QuadList& quad_list) override;
void NotifyOverlayPromotion(
DisplayResourceProvider* display_resource_provider,
const OverlayCandidateList& candidate_list,
const QuadList& quad_list) override;
// [id] == candidate's |display_rect| for all promotable resources.
using PromotionHintInfoMap = std::map<ResourceId, gfx::RectF>;
......@@ -68,7 +71,7 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
ResourceIdSet promotion_hint_requestor_set_;
void NotifyOverlayPromotionUsingSkiaOutputSurface(
DisplayResourceProvider* resource_provider,
DisplayResourceProvider* display_resource_provider,
const OverlayCandidateList& candidate_list);
SkiaOutputSurface* const skia_output_surface_;
......@@ -76,6 +79,8 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
const bool overlay_enabled_;
// This class is created, accessed, and destroyed on the gpu thread.
std::unique_ptr<OverlayProcessorOnGpu> processor_on_gpu_;
OverlayCandidateList overlay_candidates_;
};
} // namespace viz
......
......@@ -152,4 +152,7 @@ OverlayProcessorInterface::ProcessOutputSurfaceAsOverlay(
return overlay_plane;
}
void OverlayProcessorInterface::ScheduleOverlays(
DisplayResourceProvider* display_resource_provider) {}
} // namespace viz
......@@ -129,6 +129,11 @@ class VIZ_SERVICE_EXPORT OverlayProcessorInterface {
virtual void AdjustOutputSurfaceOverlay(
base::Optional<OutputSurfaceOverlayPlane>* output_surface_plane) = 0;
// TODO(weiliangc): Make it pure virtual after it is implemented by every
// subclass.
virtual void ScheduleOverlays(
DisplayResourceProvider* display_resource_provider);
// These two functions are used by Android SurfaceControl.
virtual void SetDisplayTransformHint(gfx::OverlayTransform transform) {}
virtual void SetViewportSize(const gfx::Size& size) {}
......
......@@ -13,4 +13,10 @@ OverlayProcessorOnGpu::OverlayProcessorOnGpu() {
OverlayProcessorOnGpu::~OverlayProcessorOnGpu() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
void OverlayProcessorOnGpu::ScheduleOverlays(
CandidateList&& overlay_candidates) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// TODO(weiliangc): Use shared image to schedule overlays.
}
} // namespace viz
......@@ -6,8 +6,18 @@
#define COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_ON_GPU_H_
#include "base/threading/thread_checker.h"
#include "build/build_config.h"
#include "components/viz/service/display/overlay_candidate.h"
#include "components/viz/service/viz_service_export.h"
#if defined(OS_WIN)
#include "components/viz/service/display/dc_layer_overlay.h"
#endif
#if defined(OS_MACOSX)
#include "components/viz/service/display/ca_layer_overlay.h"
#endif
namespace viz {
// This class defines the gpu thread side functionalities of overlay processing.
// This class would receive a list of overlay candidates and schedule to present
......@@ -15,9 +25,22 @@ namespace viz {
// destroyed on the gpu thread.
class VIZ_SERVICE_EXPORT OverlayProcessorOnGpu {
public:
#if defined(OS_MACOSX)
using CandidateList = CALayerOverlayList;
#elif defined(OS_WIN)
using CandidateList = DCLayerOverlayList;
#else
// Default.
using CandidateList = OverlayCandidateList;
#endif
OverlayProcessorOnGpu();
~OverlayProcessorOnGpu();
// This function takes the overlay candidates, and schedule them for
// presentation later.
void ScheduleOverlays(CandidateList&& overlay_candidates);
private:
THREAD_CHECKER(thread_checker_);
......
......@@ -42,7 +42,7 @@ gfx::Rect OverlayProcessorUsingStrategy::GetAndResetOverlayDamage() {
}
void OverlayProcessorUsingStrategy::NotifyOverlayPromotion(
DisplayResourceProvider* resource_provider,
DisplayResourceProvider* display_resource_provider,
const CandidateList& candidates,
const QuadList& quad_list) {}
......
......@@ -144,7 +144,7 @@ class VIZ_SERVICE_EXPORT OverlayProcessorUsingStrategy
// Used by Android pre-SurfaceControl to notify promotion hints.
virtual void NotifyOverlayPromotion(
DisplayResourceProvider* resource_provider,
DisplayResourceProvider* display_resource_provider,
const OverlayCandidateList& candidate_list,
const QuadList& quad_list);
......
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