Commit 76dc0b19 authored by Alexander Shah's avatar Alexander Shah Committed by Commit Bot

viz: Separate CompositorFrameSinks in FrameSinkManagerImpl.

Splits |sink_map_| into two maps to differentiate between
RootCompositorFrameSinkImpl and CompositorFrameSinkImpl. |sink_map_| is only
used for lifetime management.

The purpose of the change is to allow greater access to the
CompositorFrameSinks than is given through mojom::CompositorFrameSink.

R=sadrul@chromium.org

Change-Id: I86da2c6094afa9a7d14ca1347c9e636e7c7f08fe
Reviewed-on: https://chromium-review.googlesource.com/c/1340789Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarRia Jiang <riajiang@chromium.org>
Commit-Queue: Alexander Shah <zandershah@google.com>
Cr-Commit-Position: refs/heads/master@{#608964}
parent d8854b56
...@@ -11,10 +11,8 @@ ...@@ -11,10 +11,8 @@
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "components/viz/service/display/shared_bitmap_manager.h" #include "components/viz/service/display/shared_bitmap_manager.h"
#include "components/viz/service/display_embedder/display_provider.h" #include "components/viz/service/display_embedder/display_provider.h"
#include "components/viz/service/frame_sinks/compositor_frame_sink_impl.h"
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h" #include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
#include "components/viz/service/frame_sinks/primary_begin_frame_source.h" #include "components/viz/service/frame_sinks/primary_begin_frame_source.h"
#include "components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h"
#include "components/viz/service/frame_sinks/video_capture/capturable_frame_sink.h" #include "components/viz/service/frame_sinks/video_capture/capturable_frame_sink.h"
#include "components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_impl.h" #include "components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_impl.h"
...@@ -61,7 +59,7 @@ FrameSinkManagerImpl::~FrameSinkManagerImpl() { ...@@ -61,7 +59,7 @@ FrameSinkManagerImpl::~FrameSinkManagerImpl() {
// All mojom::CompositorFrameSinks and BeginFrameSources should be deleted by // All mojom::CompositorFrameSinks and BeginFrameSources should be deleted by
// this point. // this point.
DCHECK(sink_map_.empty()); DCHECK(sink_map_.empty() && root_sink_map_.empty());
DCHECK(registered_sources_.empty()); DCHECK(registered_sources_.empty());
surface_manager_.RemoveObserver(this); surface_manager_.RemoveObserver(this);
...@@ -93,6 +91,7 @@ void FrameSinkManagerImpl::ForceShutdown() { ...@@ -93,6 +91,7 @@ void FrameSinkManagerImpl::ForceShutdown() {
binding_.Close(); binding_.Close();
sink_map_.clear(); sink_map_.clear();
root_sink_map_.clear();
} }
void FrameSinkManagerImpl::RegisterFrameSinkId(const FrameSinkId& frame_sink_id, void FrameSinkManagerImpl::RegisterFrameSinkId(const FrameSinkId& frame_sink_id,
...@@ -122,6 +121,7 @@ void FrameSinkManagerImpl::InvalidateFrameSinkId( ...@@ -122,6 +121,7 @@ void FrameSinkManagerImpl::InvalidateFrameSinkId(
// Destroy the [Root]CompositorFrameSinkImpl if there is one. // Destroy the [Root]CompositorFrameSinkImpl if there is one.
sink_map_.erase(frame_sink_id); sink_map_.erase(frame_sink_id);
root_sink_map_.erase(frame_sink_id);
frame_sink_data_.erase(frame_sink_id); frame_sink_data_.erase(frame_sink_id);
} }
...@@ -146,7 +146,7 @@ void FrameSinkManagerImpl::SetFrameSinkDebugLabel( ...@@ -146,7 +146,7 @@ void FrameSinkManagerImpl::SetFrameSinkDebugLabel(
void FrameSinkManagerImpl::CreateRootCompositorFrameSink( void FrameSinkManagerImpl::CreateRootCompositorFrameSink(
mojom::RootCompositorFrameSinkParamsPtr params) { mojom::RootCompositorFrameSinkParamsPtr params) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!base::ContainsKey(sink_map_, params->frame_sink_id)); DCHECK(!base::ContainsKey(root_sink_map_, params->frame_sink_id));
DCHECK(display_provider_); DCHECK(display_provider_);
// We are transfering ownership of |params| so remember FrameSinkId here. // We are transfering ownership of |params| so remember FrameSinkId here.
...@@ -156,7 +156,7 @@ void FrameSinkManagerImpl::CreateRootCompositorFrameSink( ...@@ -156,7 +156,7 @@ void FrameSinkManagerImpl::CreateRootCompositorFrameSink(
auto root_compositor_frame_sink = RootCompositorFrameSinkImpl::Create( auto root_compositor_frame_sink = RootCompositorFrameSinkImpl::Create(
std::move(params), this, display_provider_); std::move(params), this, display_provider_);
if (root_compositor_frame_sink) if (root_compositor_frame_sink)
sink_map_[frame_sink_id] = std::move(root_compositor_frame_sink); root_sink_map_[frame_sink_id] = std::move(root_compositor_frame_sink);
} }
void FrameSinkManagerImpl::CreateCompositorFrameSink( void FrameSinkManagerImpl::CreateCompositorFrameSink(
...@@ -174,6 +174,7 @@ void FrameSinkManagerImpl::DestroyCompositorFrameSink( ...@@ -174,6 +174,7 @@ void FrameSinkManagerImpl::DestroyCompositorFrameSink(
const FrameSinkId& frame_sink_id, const FrameSinkId& frame_sink_id,
DestroyCompositorFrameSinkCallback callback) { DestroyCompositorFrameSinkCallback callback) {
sink_map_.erase(frame_sink_id); sink_map_.erase(frame_sink_id);
root_sink_map_.erase(frame_sink_id);
std::move(callback).Run(); std::move(callback).Run();
} }
......
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "components/viz/common/constants.h" #include "components/viz/common/constants.h"
#include "components/viz/common/surfaces/frame_sink_id.h" #include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/service/frame_sinks/compositor_frame_sink_impl.h"
#include "components/viz/service/frame_sinks/frame_sink_observer.h" #include "components/viz/service/frame_sinks/frame_sink_observer.h"
#include "components/viz/service/frame_sinks/primary_begin_frame_source.h" #include "components/viz/service/frame_sinks/primary_begin_frame_source.h"
#include "components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h"
#include "components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_manager.h" #include "components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_manager.h"
#include "components/viz/service/frame_sinks/video_detector.h" #include "components/viz/service/frame_sinks/video_detector.h"
#include "components/viz/service/hit_test/hit_test_aggregator_delegate.h" #include "components/viz/service/hit_test/hit_test_aggregator_delegate.h"
...@@ -280,8 +282,10 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl ...@@ -280,8 +282,10 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
// on destruction. // on destruction.
base::flat_map<FrameSinkId, CompositorFrameSinkSupport*> support_map_; base::flat_map<FrameSinkId, CompositorFrameSinkSupport*> support_map_;
// [Root]CompositorFrameSinkImpls are owned in this map. // [Root]CompositorFrameSinkImpls are owned in these maps.
base::flat_map<FrameSinkId, std::unique_ptr<mojom::CompositorFrameSink>> base::flat_map<FrameSinkId, std::unique_ptr<RootCompositorFrameSinkImpl>>
root_sink_map_;
base::flat_map<FrameSinkId, std::unique_ptr<CompositorFrameSinkImpl>>
sink_map_; sink_map_;
base::flat_set<std::unique_ptr<FrameSinkVideoCapturerImpl>, base::flat_set<std::unique_ptr<FrameSinkVideoCapturerImpl>,
......
...@@ -80,7 +80,8 @@ class FrameSinkManagerTest : public testing::Test { ...@@ -80,7 +80,8 @@ class FrameSinkManagerTest : public testing::Test {
// Checks if a [Root]CompositorFrameSinkImpl exists for |frame_sink_id|. // Checks if a [Root]CompositorFrameSinkImpl exists for |frame_sink_id|.
bool CompositorFrameSinkExists(const FrameSinkId& frame_sink_id) { bool CompositorFrameSinkExists(const FrameSinkId& frame_sink_id) {
return base::ContainsKey(manager_.sink_map_, frame_sink_id); return base::ContainsKey(manager_.sink_map_, frame_sink_id) ||
base::ContainsKey(manager_.root_sink_map_, frame_sink_id);
} }
// testing::Test implementation. // testing::Test implementation.
......
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