diff options
Diffstat (limited to 'chromium/components/viz/client')
8 files changed, 113 insertions, 58 deletions
diff --git a/chromium/components/viz/client/BUILD.gn b/chromium/components/viz/client/BUILD.gn index 1c97eed5def..96eb83e8b72 100644 --- a/chromium/components/viz/client/BUILD.gn +++ b/chromium/components/viz/client/BUILD.gn @@ -10,6 +10,7 @@ viz_source_set("client") { "client_layer_tree_frame_sink.h", "client_shared_bitmap_manager.cc", "client_shared_bitmap_manager.h", + "hit_test_data_provider.h", "local_surface_id_provider.cc", "local_surface_id_provider.h", ] @@ -18,8 +19,8 @@ viz_source_set("client") { "//base", "//cc", "//cc/ipc:interfaces", - "//cc/surfaces", "//components/viz/common", "//mojo/public/cpp/bindings", + "//services/viz/public/interfaces", ] } diff --git a/chromium/components/viz/client/DEPS b/chromium/components/viz/client/DEPS index 78b21a84333..5ef5a56fc11 100644 --- a/chromium/components/viz/client/DEPS +++ b/chromium/components/viz/client/DEPS @@ -2,9 +2,9 @@ include_rules = [ "+cc", "-cc/blink", "-cc/test", - + "-components/viz/common/switches.h", "+components/viz/client", "+mojo/public/cpp/bindings", "+mojo/public/cpp/system", - "+ui/gfx/geometry", + "+services/viz/public/interfaces", ] diff --git a/chromium/components/viz/client/client_layer_tree_frame_sink.cc b/chromium/components/viz/client/client_layer_tree_frame_sink.cc index 4425d5f5758..524b86f520c 100644 --- a/chromium/components/viz/client/client_layer_tree_frame_sink.cc +++ b/chromium/components/viz/client/client_layer_tree_frame_sink.cc @@ -6,10 +6,12 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" -#include "cc/output/begin_frame_args.h" +#include "base/trace_event/trace_event.h" #include "cc/output/compositor_frame.h" #include "cc/output/layer_tree_frame_sink_client.h" +#include "components/viz/client/hit_test_data_provider.h" #include "components/viz/client/local_surface_id_provider.h" +#include "components/viz/common/frame_sinks/begin_frame_args.h" #include "components/viz/common/resources/shared_bitmap_manager.h" namespace viz { @@ -19,15 +21,17 @@ ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( scoped_refptr<ContextProvider> worker_context_provider, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, SharedBitmapManager* shared_bitmap_manager, - std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, - cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, - cc::mojom::CompositorFrameSinkClientRequest client_request, + std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source, + mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, + mojom::CompositorFrameSinkClientRequest client_request, + std::unique_ptr<HitTestDataProvider> hit_test_data_provider, std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, bool enable_surface_synchronization) : cc::LayerTreeFrameSink(std::move(context_provider), std::move(worker_context_provider), gpu_memory_buffer_manager, shared_bitmap_manager), + hit_test_data_provider_(std::move(hit_test_data_provider)), local_surface_id_provider_(std::move(local_surface_id_provider)), synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), @@ -39,13 +43,15 @@ ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( } ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( - scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, - std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, - cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, - cc::mojom::CompositorFrameSinkClientRequest client_request, + scoped_refptr<VulkanContextProvider> vulkan_context_provider, + std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source, + mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, + mojom::CompositorFrameSinkClientRequest client_request, + std::unique_ptr<HitTestDataProvider> hit_test_data_provider, std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, bool enable_surface_synchronization) : cc::LayerTreeFrameSink(std::move(vulkan_context_provider)), + hit_test_data_provider_(std::move(hit_test_data_provider)), local_surface_id_provider_(std::move(local_surface_id_provider)), synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), @@ -78,7 +84,7 @@ bool ClientLayerTreeFrameSink::BindToClient( if (synthetic_begin_frame_source_) { client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); } else { - begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this); + begin_frame_source_ = base::MakeUnique<ExternalBeginFrameSource>(this); begin_frame_source_->OnSetBeginFrameSourcePaused(begin_frames_paused_); client->SetBeginFrameSource(begin_frame_source_.get()); } @@ -108,7 +114,7 @@ void ClientLayerTreeFrameSink::SubmitCompositorFrame( cc::CompositorFrame frame) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(frame.metadata.begin_frame_ack.has_damage); - DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, + DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, frame.metadata.begin_frame_ack.sequence_number); if (!enable_surface_synchronization_) { @@ -116,26 +122,38 @@ void ClientLayerTreeFrameSink::SubmitCompositorFrame( local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame); } - compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, - std::move(frame)); + TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.ipc"), + "SubmitCompositorFrame", + local_surface_id_.local_id()); + bool tracing_enabled; + TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("cc.debug.ipc"), + &tracing_enabled); + + mojom::HitTestRegionListPtr hit_test_region_list; + if (hit_test_data_provider_) + hit_test_region_list = hit_test_data_provider_->GetHitTestData(); + + compositor_frame_sink_->SubmitCompositorFrame( + local_surface_id_, std::move(frame), std::move(hit_test_region_list), + tracing_enabled ? base::TimeTicks::Now().since_origin().InMicroseconds() + : 0); } -void ClientLayerTreeFrameSink::DidNotProduceFrame( - const cc::BeginFrameAck& ack) { +void ClientLayerTreeFrameSink::DidNotProduceFrame(const BeginFrameAck& ack) { DCHECK(!ack.has_damage); - DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); + DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); compositor_frame_sink_->DidNotProduceFrame(ack); } void ClientLayerTreeFrameSink::DidReceiveCompositorFrameAck( - const std::vector<cc::ReturnedResource>& resources) { + const std::vector<ReturnedResource>& resources) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); client_->ReclaimResources(resources); client_->DidReceiveCompositorFrameAck(); } void ClientLayerTreeFrameSink::OnBeginFrame( - const cc::BeginFrameArgs& begin_frame_args) { + const BeginFrameArgs& begin_frame_args) { if (begin_frame_source_) begin_frame_source_->OnBeginFrame(begin_frame_args); } @@ -147,7 +165,7 @@ void ClientLayerTreeFrameSink::OnBeginFramePausedChanged(bool paused) { } void ClientLayerTreeFrameSink::ReclaimResources( - const std::vector<cc::ReturnedResource>& resources) { + const std::vector<ReturnedResource>& resources) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); client_->ReclaimResources(resources); } diff --git a/chromium/components/viz/client/client_layer_tree_frame_sink.h b/chromium/components/viz/client/client_layer_tree_frame_sink.h index b2893ccf828..22edb9e0353 100644 --- a/chromium/components/viz/client/client_layer_tree_frame_sink.h +++ b/chromium/components/viz/client/client_layer_tree_frame_sink.h @@ -7,65 +7,69 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "cc/ipc/compositor_frame_sink.mojom.h" #include "cc/output/layer_tree_frame_sink.h" -#include "cc/scheduler/begin_frame_source.h" +#include "components/viz/common/frame_sinks/begin_frame_source.h" #include "components/viz/common/gpu/context_provider.h" #include "components/viz/common/surfaces/local_surface_id_allocator.h" #include "components/viz/common/surfaces/surface_id.h" #include "mojo/public/cpp/bindings/binding.h" +#include "services/viz/public/interfaces/compositing/compositor_frame_sink.mojom.h" namespace viz { +class HitTestDataProvider; class LocalSurfaceIdProvider; class SharedBitmapManager; class ClientLayerTreeFrameSink : public cc::LayerTreeFrameSink, - public cc::mojom::CompositorFrameSinkClient, - public cc::ExternalBeginFrameSourceClient { + public mojom::CompositorFrameSinkClient, + public ExternalBeginFrameSourceClient { public: ClientLayerTreeFrameSink( scoped_refptr<ContextProvider> context_provider, scoped_refptr<ContextProvider> worker_context_provider, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, SharedBitmapManager* shared_bitmap_manager, - std::unique_ptr<cc::SyntheticBeginFrameSource> - synthetic_begin_frame_source, - cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, - cc::mojom::CompositorFrameSinkClientRequest client_request, + std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source, + mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, + mojom::CompositorFrameSinkClientRequest client_request, + std::unique_ptr<HitTestDataProvider> hit_test_data_provider, std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, bool enable_surface_synchronization); ClientLayerTreeFrameSink( - scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, - std::unique_ptr<cc::SyntheticBeginFrameSource> - synthetic_begin_frame_source, - cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, - cc::mojom::CompositorFrameSinkClientRequest client_request, + scoped_refptr<VulkanContextProvider> vulkan_context_provider, + std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source, + mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, + mojom::CompositorFrameSinkClientRequest client_request, + std::unique_ptr<HitTestDataProvider> hit_test_data_provider, std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, bool enable_surface_synchronization); ~ClientLayerTreeFrameSink() override; base::WeakPtr<ClientLayerTreeFrameSink> GetWeakPtr(); + const HitTestDataProvider* hit_test_data_provider() const { + return hit_test_data_provider_.get(); + } // cc::LayerTreeFrameSink implementation. bool BindToClient(cc::LayerTreeFrameSinkClient* client) override; void DetachFromClient() override; void SetLocalSurfaceId(const LocalSurfaceId& local_surface_id) override; void SubmitCompositorFrame(cc::CompositorFrame frame) override; - void DidNotProduceFrame(const cc::BeginFrameAck& ack) override; + void DidNotProduceFrame(const BeginFrameAck& ack) override; private: - // cc::mojom::CompositorFrameSinkClient implementation: + // mojom::CompositorFrameSinkClient implementation: void DidReceiveCompositorFrameAck( - const std::vector<cc::ReturnedResource>& resources) override; - void OnBeginFrame(const cc::BeginFrameArgs& begin_frame_args) override; + const std::vector<ReturnedResource>& resources) override; + void OnBeginFrame(const BeginFrameArgs& begin_frame_args) override; void OnBeginFramePausedChanged(bool paused) override; void ReclaimResources( - const std::vector<cc::ReturnedResource>& resources) override; + const std::vector<ReturnedResource>& resources) override; - // cc::ExternalBeginFrameSourceClient implementation. + // ExternalBeginFrameSourceClient implementation. void OnNeedsBeginFrames(bool needs_begin_frames) override; static void OnMojoConnectionError(uint32_t custom_reason, @@ -73,13 +77,14 @@ class ClientLayerTreeFrameSink : public cc::LayerTreeFrameSink, bool begin_frames_paused_ = false; LocalSurfaceId local_surface_id_; + std::unique_ptr<HitTestDataProvider> hit_test_data_provider_; std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider_; - std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_; - std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; - cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info_; - cc::mojom::CompositorFrameSinkClientRequest client_request_; - cc::mojom::CompositorFrameSinkPtr compositor_frame_sink_; - mojo::Binding<cc::mojom::CompositorFrameSinkClient> client_binding_; + std::unique_ptr<ExternalBeginFrameSource> begin_frame_source_; + std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source_; + mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info_; + mojom::CompositorFrameSinkClientRequest client_request_; + mojom::CompositorFrameSinkPtr compositor_frame_sink_; + mojo::Binding<mojom::CompositorFrameSinkClient> client_binding_; THREAD_CHECKER(thread_checker_); const bool enable_surface_synchronization_; diff --git a/chromium/components/viz/client/client_shared_bitmap_manager.cc b/chromium/components/viz/client/client_shared_bitmap_manager.cc index 8c1d51a6819..63b30e74bbe 100644 --- a/chromium/components/viz/client/client_shared_bitmap_manager.cc +++ b/chromium/components/viz/client/client_shared_bitmap_manager.cc @@ -24,7 +24,7 @@ namespace { class ClientSharedBitmap : public SharedBitmap { public: ClientSharedBitmap( - scoped_refptr<cc::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> + scoped_refptr<mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> shared_bitmap_allocation_notifier, base::SharedMemory* shared_memory, const SharedBitmapId& id, @@ -36,7 +36,7 @@ class ClientSharedBitmap : public SharedBitmap { std::move(shared_bitmap_allocation_notifier)) {} ClientSharedBitmap( - scoped_refptr<cc::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> + scoped_refptr<mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> shared_bitmap_allocation_notifier, std::unique_ptr<base::SharedMemory> shared_memory_holder, const SharedBitmapId& id, @@ -60,7 +60,7 @@ class ClientSharedBitmap : public SharedBitmap { } private: - scoped_refptr<cc::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> + scoped_refptr<mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> shared_bitmap_allocation_notifier_; std::unique_ptr<base::SharedMemory> shared_memory_holder_; }; @@ -112,7 +112,7 @@ std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size) { } // namespace ClientSharedBitmapManager::ClientSharedBitmapManager( - scoped_refptr<cc::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> + scoped_refptr<mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> shared_bitmap_allocation_notifier) : shared_bitmap_allocation_notifier_( std::move(shared_bitmap_allocation_notifier)) {} diff --git a/chromium/components/viz/client/client_shared_bitmap_manager.h b/chromium/components/viz/client/client_shared_bitmap_manager.h index 8bb479cbed1..553bb5702ea 100644 --- a/chromium/components/viz/client/client_shared_bitmap_manager.h +++ b/chromium/components/viz/client/client_shared_bitmap_manager.h @@ -13,9 +13,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/shared_memory.h" #include "base/synchronization/lock.h" -#include "cc/ipc/shared_bitmap_allocation_notifier.mojom.h" #include "components/viz/common/resources/shared_bitmap_manager.h" #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" +#include "services/viz/public/interfaces/compositing/shared_bitmap_allocation_notifier.mojom.h" namespace viz { @@ -25,7 +25,7 @@ namespace viz { class ClientSharedBitmapManager : public SharedBitmapManager { public: explicit ClientSharedBitmapManager( - scoped_refptr<cc::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> + scoped_refptr<mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> shared_bitmap_allocation_notifier); ~ClientSharedBitmapManager() override; @@ -43,7 +43,7 @@ class ClientSharedBitmapManager : public SharedBitmapManager { uint32_t NotifyAllocatedSharedBitmap(base::SharedMemory* memory, const SharedBitmapId& id); - scoped_refptr<cc::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> + scoped_refptr<mojom::ThreadSafeSharedBitmapAllocationNotifierPtr> shared_bitmap_allocation_notifier_; base::Lock lock_; diff --git a/chromium/components/viz/client/hit_test_data_provider.h b/chromium/components/viz/client/hit_test_data_provider.h new file mode 100644 index 00000000000..73012424ebb --- /dev/null +++ b/chromium/components/viz/client/hit_test_data_provider.h @@ -0,0 +1,31 @@ +// Copyright 2017 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_CLIENT_HIT_TEST_DATA_PROVIDER_H_ +#define COMPONENTS_VIZ_CLIENT_HIT_TEST_DATA_PROVIDER_H_ + +#include <memory> +#include <vector> + +#include "base/macros.h" +#include "services/viz/public/interfaces/hit_test/hit_test_region_list.mojom.h" + +namespace viz { + +class HitTestDataProvider { + public: + HitTestDataProvider() = default; + virtual ~HitTestDataProvider() = default; + + // Returns an array of hit-test regions. May return nullptr to disable + // hit-testing. + virtual mojom::HitTestRegionListPtr GetHitTestData() const = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(HitTestDataProvider); +}; + +} // namespace viz + +#endif // COMPONENTS_VIZ_CLIENT_HIT_TEST_DATA_PROVIDER_H_ diff --git a/chromium/components/viz/client/local_surface_id_provider.cc b/chromium/components/viz/client/local_surface_id_provider.cc index 90773f302ff..e556b194f6f 100644 --- a/chromium/components/viz/client/local_surface_id_provider.cc +++ b/chromium/components/viz/client/local_surface_id_provider.cc @@ -15,13 +15,13 @@ DefaultLocalSurfaceIdProvider::DefaultLocalSurfaceIdProvider() = default; const LocalSurfaceId& DefaultLocalSurfaceIdProvider::GetLocalSurfaceIdForFrame( const cc::CompositorFrame& frame) { - gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); - if (!local_surface_id_.is_valid() || surface_size_ != frame_size || - frame.metadata.device_scale_factor != device_scale_factor_) { + if (!local_surface_id_.is_valid() || + surface_size_ != frame.size_in_pixels() || + frame.device_scale_factor() != device_scale_factor_) { local_surface_id_ = local_surface_id_allocator_.GenerateId(); } - surface_size_ = frame_size; - device_scale_factor_ = frame.metadata.device_scale_factor; + surface_size_ = frame.size_in_pixels(); + device_scale_factor_ = frame.device_scale_factor(); return local_surface_id_; } |