Commit 2e7fdf11 authored by Xianda Sun's avatar Xianda Sun Committed by Commit Bot

Use layer tree to generate data when VizHitTestSurfaceLayer is enabled

We previously use other hit test data providers whenever there is one
created, regardless of whether we enable VizHitTestSurfaceLayer or not.

This makes the flag no longer effective in some conditions as we can
create a draw quad hit test data provider arbitrarily sometimes. It
accounts for the async hit testing of approximately 1% of all hit
testing requests when VizHitTestSurfaceLayer is enabled.

This patch makes us use layer tree hit test data when the flag is
enabled.

Bug: 901882
Change-Id: I833b693368721b09e1d2922274d21170a24125d7
Reviewed-on: https://chromium-review.googlesource.com/c/1348949
Commit-Queue: Xianda Sun <sunxd@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarRia Jiang <riajiang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611757}
parent 12b2a6e5
......@@ -16,6 +16,7 @@
#include "cc/trees/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/features.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/hit_test/hit_test_region_list.h"
#include "components/viz/common/quads/compositor_frame.h"
......@@ -97,6 +98,10 @@ AsyncLayerTreeFrameSink::AsyncLayerTreeFrameSink(
"GraphicsPipeline.%s.SubmitCompositorFrameAfterBeginFrame",
params->client_name)),
weak_factory_(this) {
// We should not create hit test data provider if we want to use cc layer tree
// to generated data.
if (features::IsVizHitTestingSurfaceLayerEnabled())
DCHECK(!params->hit_test_data_provider);
DETACH_FROM_THREAD(thread_checker_);
}
......
......@@ -173,9 +173,11 @@ WindowPortLocal::CreateLayerTreeFrameSink() {
ws::mojom::EventTargetingPolicy::TARGET_ONLY) ||
(window_->event_targeting_policy() ==
ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
true /* should_ask_for_child_region */, root_accepts_events);
if (features::IsVizHitTestingDrawQuadEnabled()) {
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
true /* should_ask_for_child_region */, root_accepts_events);
}
auto frame_sink =
std::make_unique<cc::mojo_embedder::AsyncLayerTreeFrameSink>(
nullptr /* context_provider */, nullptr /* worker_context_provider */,
......
......@@ -12,6 +12,7 @@
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "components/viz/client/hit_test_data_provider_draw_quad.h"
#include "components/viz/client/local_surface_id_provider.h"
#include "components/viz/common/features.h"
#include "components/viz/common/surfaces/local_surface_id_allocation.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "services/ws/public/mojom/window_tree_constants.mojom.h"
......@@ -196,9 +197,11 @@ WindowPortMus::RequestLayerTreeFrameSink(
ws::mojom::EventTargetingPolicy::TARGET_ONLY) ||
(window_->event_targeting_policy() ==
ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
/* should_ask_for_child_regions */ false, root_accepts_events);
if (features::IsVizHitTestingDrawQuadEnabled()) {
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
/* should_ask_for_child_regions */ false, root_accepts_events);
}
params.local_surface_id_provider =
std::make_unique<viz::DefaultLocalSurfaceIdProvider>();
params.enable_surface_synchronization = true;
......
......@@ -10,6 +10,7 @@
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "components/viz/client/hit_test_data_provider_draw_quad.h"
#include "components/viz/client/local_surface_id_provider.h"
#include "components/viz/common/features.h"
#include "components/viz/common/switches.h"
#include "components/viz/host/host_display_client.h"
#include "components/viz/host/host_frame_sink_manager.h"
......@@ -118,10 +119,12 @@ void HostContextFactoryPrivate::ConfigureCompositor(
params.local_surface_id_provider =
std::make_unique<viz::DefaultLocalSurfaceIdProvider>();
params.enable_surface_synchronization = true;
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
false /* should_ask_for_child_region */,
true /* root_accepts_events */);
if (features::IsVizHitTestingDrawQuadEnabled()) {
params.hit_test_data_provider =
std::make_unique<viz::HitTestDataProviderDrawQuad>(
false /* should_ask_for_child_region */,
true /* root_accepts_events */);
}
params.client_name = kBrowser;
compositor->SetLayerTreeFrameSink(
std::make_unique<cc::mojo_embedder::AsyncLayerTreeFrameSink>(
......
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