[InputVizard] Make is_mobile_optimized
part of CompositorFrameMetadata
As per current implementation Viz is notififed about whether a page `is_mobile_optimized` when Renderer sends the frame metadata to Browser, and then Browser forwards it to Viz. This currently doesn't work well when Viz crashes and is setting up the data structures again as part of startup after crash. To resolve this we are making `is_mobile_optimized` a part of CompositorFrameMetadata which helps us avoid the above mentioned problem and no extra IPC need to be made from Browser to Viz for notifying about change in `is_mobile_optimized`. Bug: 402048251 Change-Id: Ib9f48dd5fd8a385ee749654651c87d8b93c6d7cf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6519777 Reviewed-by: Jonathan Ross <jonross@chromium.org> Reviewed-by: Antonio Sartori <antoniosartori@chromium.org> Commit-Queue: Kartar Singh <kartarsingh@google.com> Cr-Commit-Position: refs/heads/main@{#1459328}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
bc0a76fc70
commit
ccc23c7c16
cc/trees
components
input
viz
content/browser/renderer_host
services/viz/public
cpp
mojom
compositing
@@ -2639,6 +2639,8 @@ viz::CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() {
|
|||||||
|
|
||||||
metadata.display_transform_hint = active_tree_->display_transform_hint();
|
metadata.display_transform_hint = active_tree_->display_transform_hint();
|
||||||
|
|
||||||
|
metadata.is_mobile_optimized = IsMobileOptimized(active_tree_.get());
|
||||||
|
|
||||||
if (const gfx::DelegatedInkMetadata* delegated_ink_metadata_ptr =
|
if (const gfx::DelegatedInkMetadata* delegated_ink_metadata_ptr =
|
||||||
active_tree_->delegated_ink_metadata()) {
|
active_tree_->delegated_ink_metadata()) {
|
||||||
std::unique_ptr<gfx::DelegatedInkMetadata> delegated_ink_metadata =
|
std::unique_ptr<gfx::DelegatedInkMetadata> delegated_ink_metadata =
|
||||||
|
@@ -62,11 +62,6 @@ interface RenderInputRouterDelegate {
|
|||||||
// Viz needs this to do input handling on it's side.
|
// Viz needs this to do input handling on it's side.
|
||||||
StateOnTouchTransfer(TouchTransferState state);
|
StateOnTouchTransfer(TouchTransferState state);
|
||||||
|
|
||||||
// Notifies RenderInputRouter on the VizCompositor thread (corresponding to
|
|
||||||
// |frame_sink_id|), of changes to a page being mobile site optimized.
|
|
||||||
NotifySiteIsMobileOptimized(bool is_mobile_optimized,
|
|
||||||
viz.mojom.FrameSinkId frame_sink_id);
|
|
||||||
|
|
||||||
// Notifies RenderInputRouters corresponding to |frame_sink_ids| on the
|
// Notifies RenderInputRouters corresponding to |frame_sink_ids| on the
|
||||||
// VizCompositor thread of changes to |force_enable_zoom| state for
|
// VizCompositor thread of changes to |force_enable_zoom| state for
|
||||||
// Accessibility.
|
// Accessibility.
|
||||||
|
@@ -44,6 +44,7 @@ CompositorFrameMetadata::CompositorFrameMetadata(
|
|||||||
top_controls_visible_height(other.top_controls_visible_height),
|
top_controls_visible_height(other.top_controls_visible_height),
|
||||||
preferred_frame_interval(other.preferred_frame_interval),
|
preferred_frame_interval(other.preferred_frame_interval),
|
||||||
display_transform_hint(other.display_transform_hint),
|
display_transform_hint(other.display_transform_hint),
|
||||||
|
is_mobile_optimized(other.is_mobile_optimized),
|
||||||
transition_directives(other.transition_directives),
|
transition_directives(other.transition_directives),
|
||||||
has_shared_element_resources(other.has_shared_element_resources),
|
has_shared_element_resources(other.has_shared_element_resources),
|
||||||
screenshot_destination(other.screenshot_destination),
|
screenshot_destination(other.screenshot_destination),
|
||||||
|
@@ -184,6 +184,9 @@ class VIZ_COMMON_EXPORT CompositorFrameMetadata {
|
|||||||
// applicable to frames of the root surface.
|
// applicable to frames of the root surface.
|
||||||
gfx::OverlayTransform display_transform_hint = gfx::OVERLAY_TRANSFORM_NONE;
|
gfx::OverlayTransform display_transform_hint = gfx::OVERLAY_TRANSFORM_NONE;
|
||||||
|
|
||||||
|
// Please refer RenderFrameMetadata::is_mobile_optimized for detailed comment.
|
||||||
|
bool is_mobile_optimized = false;
|
||||||
|
|
||||||
// Contains the metadata required for drawing a delegated ink trail onto the
|
// Contains the metadata required for drawing a delegated ink trail onto the
|
||||||
// end of a rendered ink stroke. This should only be present when two
|
// end of a rendered ink stroke. This should only be present when two
|
||||||
// conditions are met:
|
// conditions are met:
|
||||||
|
@@ -298,8 +298,9 @@ void CompositorFrameSinkSupport::OnSurfaceActivated(Surface* surface) {
|
|||||||
if (pending_surfaces_.empty())
|
if (pending_surfaces_.empty())
|
||||||
UpdateNeedsBeginFramesInternal();
|
UpdateNeedsBeginFramesInternal();
|
||||||
|
|
||||||
for (const auto& directive :
|
const CompositorFrameMetadata& active_frame_metadata =
|
||||||
surface->GetActiveFrameMetadata().transition_directives) {
|
surface->GetActiveFrameMetadata();
|
||||||
|
for (const auto& directive : active_frame_metadata.transition_directives) {
|
||||||
ProcessCompositorFrameTransitionDirective(directive, surface);
|
ProcessCompositorFrameTransitionDirective(directive, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,13 +344,18 @@ void CompositorFrameSinkSupport::OnSurfaceActivated(Surface* surface) {
|
|||||||
MaybeEvictSurfaces();
|
MaybeEvictSurfaces();
|
||||||
|
|
||||||
// Update |device_scale_factor_| if it changes with latest activated surface.
|
// Update |device_scale_factor_| if it changes with latest activated surface.
|
||||||
float new_device_scale_factor =
|
float new_device_scale_factor = active_frame_metadata.device_scale_factor;
|
||||||
surface->GetActiveFrameMetadata().device_scale_factor;
|
|
||||||
if (device_scale_factor_ != new_device_scale_factor) {
|
if (device_scale_factor_ != new_device_scale_factor) {
|
||||||
frame_sink_manager_->OnFrameSinkDeviceScaleFactorChanged(
|
frame_sink_manager_->OnFrameSinkDeviceScaleFactorChanged(
|
||||||
surface->surface_id().frame_sink_id(), new_device_scale_factor);
|
surface->surface_id().frame_sink_id(), new_device_scale_factor);
|
||||||
device_scale_factor_ = new_device_scale_factor;
|
device_scale_factor_ = new_device_scale_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_mobile_optimized_ != active_frame_metadata.is_mobile_optimized) {
|
||||||
|
is_mobile_optimized_ = active_frame_metadata.is_mobile_optimized;
|
||||||
|
frame_sink_manager_->OnFrameSinkMobileOptimizedChanged(
|
||||||
|
frame_sink_id_, is_mobile_optimized_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositorFrameSinkSupport::OnSurfaceWillDraw(Surface* surface) {
|
void CompositorFrameSinkSupport::OnSurfaceWillDraw(Surface* surface) {
|
||||||
|
@@ -419,6 +419,8 @@ class VIZ_SERVICE_EXPORT CompositorFrameSinkSupport
|
|||||||
// Default value is 1.0.
|
// Default value is 1.0.
|
||||||
float device_scale_factor_ = 1.0;
|
float device_scale_factor_ = 1.0;
|
||||||
|
|
||||||
|
bool is_mobile_optimized_ = false;
|
||||||
|
|
||||||
// By default, this is equivalent to |is_root_|, but may be overridden for
|
// By default, this is equivalent to |is_root_|, but may be overridden for
|
||||||
// testing. Generally, for non-roots, there must not be any CopyOutputRequests
|
// testing. Generally, for non-roots, there must not be any CopyOutputRequests
|
||||||
// contained within submitted CompositorFrames. Otherwise, unprivileged
|
// contained within submitted CompositorFrames. Otherwise, unprivileged
|
||||||
|
@@ -854,6 +854,15 @@ void FrameSinkManagerImpl::OnFrameSinkDeviceScaleFactorChanged(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameSinkManagerImpl::OnFrameSinkMobileOptimizedChanged(
|
||||||
|
const FrameSinkId& frame_sink_id,
|
||||||
|
bool is_mobile_optimized) {
|
||||||
|
for (auto& observer : observer_list_) {
|
||||||
|
observer.OnFrameSinkMobileOptimizedChanged(frame_sink_id,
|
||||||
|
is_mobile_optimized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FrameSinkManagerImpl::AddObserver(FrameSinkObserver* obs) {
|
void FrameSinkManagerImpl::AddObserver(FrameSinkObserver* obs) {
|
||||||
observer_list_.AddObserver(obs);
|
observer_list_.AddObserver(obs);
|
||||||
}
|
}
|
||||||
|
@@ -298,6 +298,9 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
|
|||||||
void OnFrameSinkDeviceScaleFactorChanged(const FrameSinkId& frame_sink_id,
|
void OnFrameSinkDeviceScaleFactorChanged(const FrameSinkId& frame_sink_id,
|
||||||
float device_scale_factor);
|
float device_scale_factor);
|
||||||
|
|
||||||
|
void OnFrameSinkMobileOptimizedChanged(const FrameSinkId& frame_sink_id,
|
||||||
|
bool is_mobile_optimized);
|
||||||
|
|
||||||
void AddObserver(FrameSinkObserver* obs);
|
void AddObserver(FrameSinkObserver* obs);
|
||||||
void RemoveObserver(FrameSinkObserver* obs);
|
void RemoveObserver(FrameSinkObserver* obs);
|
||||||
|
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
#ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_FRAME_SINK_OBSERVER_H_
|
#ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_FRAME_SINK_OBSERVER_H_
|
||||||
#define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_FRAME_SINK_OBSERVER_H_
|
#define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_FRAME_SINK_OBSERVER_H_
|
||||||
|
|
||||||
|
#include "components/viz/common/quads/compositor_frame_metadata.h"
|
||||||
|
|
||||||
namespace viz {
|
namespace viz {
|
||||||
|
|
||||||
class FrameSinkId;
|
class FrameSinkId;
|
||||||
@@ -54,6 +56,12 @@ class FrameSinkObserver {
|
|||||||
const FrameSinkId& frame_sink_id,
|
const FrameSinkId& frame_sink_id,
|
||||||
float device_scale_factor) {}
|
float device_scale_factor) {}
|
||||||
|
|
||||||
|
// Called when the |is_mobile_optimized| related to |frame_sink_id| changes
|
||||||
|
// with latest activated frame.
|
||||||
|
virtual void OnFrameSinkMobileOptimizedChanged(
|
||||||
|
const FrameSinkId& frame_sink_id,
|
||||||
|
bool is_mobile_optimized) {}
|
||||||
|
|
||||||
// Called when capturing is started for `frame_sink_id`.
|
// Called when capturing is started for `frame_sink_id`.
|
||||||
virtual void OnCaptureStarted(const FrameSinkId& frame_sink_id) {}
|
virtual void OnCaptureStarted(const FrameSinkId& frame_sink_id) {}
|
||||||
};
|
};
|
||||||
|
@@ -339,6 +339,25 @@ void InputManager::OnFrameSinkDeviceScaleFactorChanged(
|
|||||||
rir_iter->second->SetDeviceScaleFactor(device_scale_factor);
|
rir_iter->second->SetDeviceScaleFactor(device_scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputManager::OnFrameSinkMobileOptimizedChanged(
|
||||||
|
const FrameSinkId& frame_sink_id,
|
||||||
|
bool is_mobile_optimized) {
|
||||||
|
auto rir_itr = rir_map_.find(frame_sink_id);
|
||||||
|
if (rir_itr == rir_map_.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rir_itr->second->input_router()->NotifySiteIsMobileOptimized(
|
||||||
|
is_mobile_optimized);
|
||||||
|
|
||||||
|
auto metadata_itr = frame_sink_metadata_map_.find(frame_sink_id);
|
||||||
|
CHECK(metadata_itr != frame_sink_metadata_map_.end());
|
||||||
|
FrameSinkMetadata& frame_sink_metadata = metadata_itr->second;
|
||||||
|
CHECK(frame_sink_metadata.is_mobile_optimized != is_mobile_optimized);
|
||||||
|
frame_sink_metadata.is_mobile_optimized = is_mobile_optimized;
|
||||||
|
frame_sink_metadata.rir_support->NotifySiteIsMobileOptimized(
|
||||||
|
is_mobile_optimized);
|
||||||
|
}
|
||||||
|
|
||||||
input::TouchEmulator* InputManager::GetTouchEmulator(bool create_if_necessary) {
|
input::TouchEmulator* InputManager::GetTouchEmulator(bool create_if_necessary) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -533,22 +552,6 @@ void InputManager::StateOnTouchTransfer(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::NotifySiteIsMobileOptimized(
|
|
||||||
bool is_mobile_optimized,
|
|
||||||
const FrameSinkId& frame_sink_id) {
|
|
||||||
auto itr = rir_map_.find(frame_sink_id);
|
|
||||||
if (itr == rir_map_.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
itr->second->input_router()->NotifySiteIsMobileOptimized(is_mobile_optimized);
|
|
||||||
|
|
||||||
auto metadata_itr = frame_sink_metadata_map_.find(frame_sink_id);
|
|
||||||
CHECK(metadata_itr != frame_sink_metadata_map_.end());
|
|
||||||
metadata_itr->second.is_mobile_optimized = is_mobile_optimized;
|
|
||||||
metadata_itr->second.rir_support->NotifySiteIsMobileOptimized(
|
|
||||||
is_mobile_optimized);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputManager::ForceEnableZoomStateChanged(
|
void InputManager::ForceEnableZoomStateChanged(
|
||||||
bool force_enable_zoom,
|
bool force_enable_zoom,
|
||||||
const std::vector<FrameSinkId>& frame_sink_ids) {
|
const std::vector<FrameSinkId>& frame_sink_ids) {
|
||||||
|
@@ -89,6 +89,8 @@ class VIZ_SERVICE_EXPORT InputManager
|
|||||||
const FrameSinkId& child_frame_sink_id) override;
|
const FrameSinkId& child_frame_sink_id) override;
|
||||||
void OnFrameSinkDeviceScaleFactorChanged(const FrameSinkId& frame_sink_id,
|
void OnFrameSinkDeviceScaleFactorChanged(const FrameSinkId& frame_sink_id,
|
||||||
float device_scale_factor) override;
|
float device_scale_factor) override;
|
||||||
|
void OnFrameSinkMobileOptimizedChanged(const FrameSinkId& frame_sink_id,
|
||||||
|
bool is_mobile_optimized) override;
|
||||||
|
|
||||||
// RenderWidgetHostInputEventRouter::Delegate implementation.
|
// RenderWidgetHostInputEventRouter::Delegate implementation.
|
||||||
input::TouchEmulator* GetTouchEmulator(bool create_if_necessary) override;
|
input::TouchEmulator* GetTouchEmulator(bool create_if_necessary) override;
|
||||||
@@ -141,8 +143,6 @@ class VIZ_SERVICE_EXPORT InputManager
|
|||||||
|
|
||||||
// input::mojom::RenderInputRouterDelegate implementation.
|
// input::mojom::RenderInputRouterDelegate implementation.
|
||||||
void StateOnTouchTransfer(input::mojom::TouchTransferStatePtr state) override;
|
void StateOnTouchTransfer(input::mojom::TouchTransferStatePtr state) override;
|
||||||
void NotifySiteIsMobileOptimized(bool is_mobile_optimized,
|
|
||||||
const FrameSinkId& frame_sink_id) override;
|
|
||||||
void ForceEnableZoomStateChanged(
|
void ForceEnableZoomStateChanged(
|
||||||
bool force_enable_zoom,
|
bool force_enable_zoom,
|
||||||
const std::vector<FrameSinkId>& frame_sink_ids) override;
|
const std::vector<FrameSinkId>& frame_sink_ids) override;
|
||||||
|
@@ -3812,14 +3812,6 @@ void RenderWidgetHostImpl::OnRenderFrameMetadataChangedAfterActivation(
|
|||||||
|
|
||||||
if (mobile_optimized_state_changed) {
|
if (mobile_optimized_state_changed) {
|
||||||
input_router()->NotifySiteIsMobileOptimized(is_mobile_optimized_);
|
input_router()->NotifySiteIsMobileOptimized(is_mobile_optimized_);
|
||||||
// Notifies Viz only if the page's mobile optimized state has changed, since
|
|
||||||
// this is only used to set touch ack timeout delay for mobile sites in
|
|
||||||
// PassthroughTouchEventQueue.
|
|
||||||
if (auto* delegate_remote =
|
|
||||||
delegate()->GetRenderInputRouterDelegateRemote()) {
|
|
||||||
delegate_remote->NotifySiteIsMobileOptimized(is_mobile_optimized_,
|
|
||||||
frame_sink_id_);
|
|
||||||
}
|
|
||||||
if (auto* touch_emulator =
|
if (auto* touch_emulator =
|
||||||
GetTouchEmulator(/*create_if_necessary=*/false)) {
|
GetTouchEmulator(/*create_if_necessary=*/false)) {
|
||||||
touch_emulator->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized_);
|
touch_emulator->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized_);
|
||||||
|
@@ -58,6 +58,7 @@ bool StructTraits<viz::mojom::CompositorFrameMetadataDataView,
|
|||||||
out->is_handling_animation = data.is_handling_animation();
|
out->is_handling_animation = data.is_handling_animation();
|
||||||
out->send_frame_token_to_embedder = data.send_frame_token_to_embedder();
|
out->send_frame_token_to_embedder = data.send_frame_token_to_embedder();
|
||||||
out->min_page_scale_factor = data.min_page_scale_factor();
|
out->min_page_scale_factor = data.min_page_scale_factor();
|
||||||
|
out->is_mobile_optimized = data.is_mobile_optimized();
|
||||||
out->is_software = data.is_software();
|
out->is_software = data.is_software();
|
||||||
if (data.top_controls_visible_height_set()) {
|
if (data.top_controls_visible_height_set()) {
|
||||||
out->top_controls_visible_height.emplace(
|
out->top_controls_visible_height.emplace(
|
||||||
|
@@ -151,6 +151,11 @@ struct StructTraits<viz::mojom::CompositorFrameMetadataDataView,
|
|||||||
return metadata.display_transform_hint;
|
return metadata.display_transform_hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_mobile_optimized(
|
||||||
|
const viz::CompositorFrameMetadata& metadata) {
|
||||||
|
return metadata.is_mobile_optimized;
|
||||||
|
}
|
||||||
|
|
||||||
static const std::unique_ptr<gfx::DelegatedInkMetadata>&
|
static const std::unique_ptr<gfx::DelegatedInkMetadata>&
|
||||||
delegated_ink_metadata(const viz::CompositorFrameMetadata& metadata) {
|
delegated_ink_metadata(const viz::CompositorFrameMetadata& metadata) {
|
||||||
return metadata.delegated_ink_metadata;
|
return metadata.delegated_ink_metadata;
|
||||||
|
@@ -58,6 +58,8 @@ struct CompositorFrameMetadata {
|
|||||||
|
|
||||||
gfx.mojom.OverlayTransform display_transform_hint;
|
gfx.mojom.OverlayTransform display_transform_hint;
|
||||||
|
|
||||||
|
bool is_mobile_optimized;
|
||||||
|
|
||||||
// Contains the metadata required for drawing a delegated ink trail onto the
|
// Contains the metadata required for drawing a delegated ink trail onto the
|
||||||
// end of a rendered ink stroke. This should only be present when two
|
// end of a rendered ink stroke. This should only be present when two
|
||||||
// conditions are met:
|
// conditions are met:
|
||||||
|
Reference in New Issue
Block a user