Commit 787f099c authored by weiliangc's avatar weiliangc Committed by Commit Bot

Revert "viz: OverlayProcessor Sends Candidate Directly for Android Pre-SC"

This reverts commit 064c1945.

Reason for revert: crbug.com/1044380

Original change's description:
> viz: OverlayProcessor Sends Candidate Directly for Android Pre-SC
> 
> For Andorid Pre-SurfaceControl, overlay processor can send the
> overlay candidates directly.
> 
> This is CL 6/? for sending the overlay candidates directly to gpu thread.
> 
> R=​rjkroege
> 
> Bug: 979788
> Change-Id: I76d97e8c8cfece078f6ea8d90bf8d3e7ae02dbfc
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985305
> Commit-Queue: weiliangc <weiliangc@chromium.org>
> Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#733619}

TBR=rjkroege@chromium.org,weiliangc@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 979788
Change-Id: I9cc2033bf6145b5d0b59e0680b7265403927b913
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013811Reviewed-by: default avatarweiliangc <weiliangc@chromium.org>
Commit-Queue: weiliangc <weiliangc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734076}
parent 7d2be654
......@@ -414,14 +414,8 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
current_frame()->output_surface_plane->gpu_fence_id =
output_surface_->UpdateGpuFence();
if (overlay_processor_)
overlay_processor_->TakeOverlayCandidates(&current_frame()->overlay_list);
FinishDrawingFrame();
if (overlay_processor_)
overlay_processor_->ScheduleOverlays(resource_provider_);
render_passes_in_draw_order->clear();
render_pass_filters_.clear();
render_pass_backdrop_filters_.clear();
......
......@@ -721,7 +721,6 @@ void Display::DidReceiveSwapBuffersAck(const gfx::SwapTimings& timings) {
if (no_pending_swaps_callback_ && pending_swaps_ == 0)
std::move(no_pending_swaps_callback_).Run();
overlay_processor_->OverlayPresentationComplete();
if (renderer_)
renderer_->SwapBuffersComplete();
......
......@@ -6,6 +6,7 @@
#include "base/synchronization/waitable_event.h"
#include "components/viz/common/quads/stream_video_draw_quad.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/overlay_processor_on_gpu.h"
#include "components/viz/service/display/overlay_strategy_underlay.h"
#include "components/viz/service/display/skia_output_surface.h"
......@@ -88,15 +89,18 @@ void OverlayProcessorAndroid::ScheduleOverlays(
if (!gpu_task_scheduler_)
return;
pending_overlay_locks_.emplace_back();
auto& locks = pending_overlay_locks_.back();
std::vector<
std::unique_ptr<DisplayResourceProvider::ScopedReadLockSharedImage>>
locks;
for (auto& candidate : overlay_candidates_) {
locks.emplace_back(resource_provider, candidate.resource_id);
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());
locks_sync_tokens.push_back(read_lock->sync_token());
auto task = base::BindOnce(&OverlayProcessorOnGpu::ScheduleOverlays,
base::Unretained(processor_on_gpu_.get()),
......@@ -105,14 +109,6 @@ void OverlayProcessorAndroid::ScheduleOverlays(
overlay_candidates_.clear();
}
void OverlayProcessorAndroid::OverlayPresentationComplete() {
// This is a signal from Display::DidReceiveSwapBuffersAck. We use this to
// help clear locks on resources from old frame.
committed_overlay_locks_.clear();
std::swap(committed_overlay_locks_, pending_overlay_locks_.front());
pending_overlay_locks_.pop_front();
}
void OverlayProcessorAndroid::CheckOverlaySupport(
const OverlayProcessorInterface::OutputSurfaceOverlayPlane* primary_plane,
OverlayCandidateList* candidates) {
......@@ -158,12 +154,6 @@ gfx::Rect OverlayProcessorAndroid::GetOverlayDamageRectForOutputSurface(
return ToEnclosedRect(overlay.display_rect);
}
void OverlayProcessorAndroid::TakeOverlayCandidates(
OverlayCandidateList* candidate_list) {
overlay_candidates_.swap(*candidate_list);
candidate_list->clear();
}
void OverlayProcessorAndroid::NotifyOverlayPromotion(
DisplayResourceProvider* resource_provider,
const CandidateList& candidates,
......
......@@ -5,8 +5,6 @@
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_ANDROID_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_ANDROID_H_
#include "base/containers/circular_deque.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/overlay_processor_using_strategy.h"
namespace base {
......@@ -40,8 +38,6 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
void ScheduleOverlays(
DisplayResourceProvider* display_resource_provider) override;
void OverlayPresentationComplete() override;
// Override OverlayProcessorUsingStrategy.
void SetDisplayTransformHint(gfx::OverlayTransform transform) override {}
void SetViewportSize(const gfx::Size& size) override {}
......@@ -59,7 +55,6 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
void InitializeOverlayProcessorOnGpu(
gpu::SharedImageManager* shared_image_manager);
void DestroyOverlayProcessorOnGpu(base::WaitableEvent* event);
void TakeOverlayCandidates(CandidateList* candidate_list) override;
void NotifyOverlayPromotion(
DisplayResourceProvider* display_resource_provider,
const OverlayCandidateList& candidate_list,
......@@ -83,15 +78,6 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
std::unique_ptr<OverlayProcessorOnGpu> processor_on_gpu_;
OverlayCandidateList overlay_candidates_;
using OverlayResourceLock =
DisplayResourceProvider::ScopedReadLockSharedImage;
// Locks for overlays are pending for OverlayPresentationComplete.
base::circular_deque<std::vector<OverlayResourceLock>> pending_overlay_locks_;
// Locks for overlays have been committed. |pending_overlay_locks_| will
// be moved to |committed_overlay_locks_| after OverlayPresentationComplete.
std::vector<OverlayResourceLock> committed_overlay_locks_;
};
} // namespace viz
......
......@@ -163,6 +163,4 @@ OverlayProcessorInterface::ProcessOutputSurfaceAsOverlay(
void OverlayProcessorInterface::ScheduleOverlays(
DisplayResourceProvider* display_resource_provider) {}
void OverlayProcessorInterface::OverlayPresentationComplete() {}
} // namespace viz
......@@ -129,21 +129,10 @@ class VIZ_SERVICE_EXPORT OverlayProcessorInterface {
virtual void AdjustOutputSurfaceOverlay(
base::Optional<OutputSurfaceOverlayPlane>* output_surface_plane) = 0;
// Before the overlay refactor to use OverlayProcessorOnGpu, overlay
// candidates are stored inside DirectRenderer. Those overlay candidates are
// later sent over to the GPU thread by GLRenderer or SkiaRenderer. This is a
// helper function to take these overlay candidates inside overlay processor
// to avoid sending over DirectRenderer implementation. This is overridden by
// each platform that is ready to send overlay candidates inside overlay
// processo. Must be called before ScheduleOverlays().
virtual void TakeOverlayCandidates(CandidateList* candidate_list) {}
// TODO(weiliangc): Make it pure virtual after it is implemented by every
// subclass.
virtual void ScheduleOverlays(
DisplayResourceProvider* display_resource_provider);
// This is a signal from Display::DidReceiveSwapBuffersAck.
virtual void OverlayPresentationComplete();
// These two functions are used by Android SurfaceControl.
virtual void SetDisplayTransformHint(gfx::OverlayTransform transform) {}
......
......@@ -5,7 +5,6 @@
#include "components/viz/service/display/overlay_processor_on_gpu.h"
#include "gpu/command_buffer/service/shared_image_factory.h"
#include "gpu/command_buffer/service/shared_image_manager.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace viz {
......@@ -25,28 +24,7 @@ OverlayProcessorOnGpu::~OverlayProcessorOnGpu() {
void OverlayProcessorOnGpu::ScheduleOverlays(
CandidateList&& overlay_candidates) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
#if defined(OS_ANDROID)
// TODO(weiliangc): Currently only implemented for Android Classic code path.
for (auto& overlay : overlay_candidates) {
auto shared_image_overlay =
shared_image_representation_factory_->ProduceOverlay(overlay.mailbox);
// When display is re-opened, the first few frames might not have video
// resource ready. Possible investigation crbug.com/1023971.
if (!shared_image_overlay)
continue;
// In current implementation, the BeginReadAccess will ends up calling
// CodecImage::RenderToOverlay. Currently this code path is only used for
// Android Classic video overlay, where update of the overlay plane is
// within media code. Since we are not actually passing an overlay plane to
// the display controller here, we are able to call EndReadAccess directly
// after BeginReadAccess.
shared_image_overlay->NotifyOverlayPromotion(
true, ToNearestRect(overlay.display_rect));
std::unique_ptr<gpu::SharedImageRepresentationOverlay::ScopedReadAccess>
scoped_access = shared_image_overlay->BeginScopedReadAccess(
false /* needs_gl_image */);
}
#endif
// TODO(weiliangc): Use shared image to schedule overlays.
}
#if defined(OS_ANDROID)
......
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