chromium/cc/trees/property_tree.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <algorithm>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/check_op.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/traced_value.h"
#include "cc/base/features.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/compositor_commit_data.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/property_tree.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "cc/trees/viewport_property_ids.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "ui/gfx/geometry/outsets_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/transform_util.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/geometry/vector2d_f.h"

namespace cc {

void AnimationUpdateOnMissingPropertyNodeUMALog(bool missing_property_node) {}

AnchorPositionScrollData::AnchorPositionScrollData() = default;
AnchorPositionScrollData::~AnchorPositionScrollData() = default;
AnchorPositionScrollData::AnchorPositionScrollData(
    const AnchorPositionScrollData&) = default;

bool AnchorPositionScrollData::operator==(
    const AnchorPositionScrollData& other) const = default;

bool StickyPositionNodeData::operator==(
    const StickyPositionNodeData& other) const = default;

template <typename T>
PropertyTree<T>::PropertyTree(PropertyTrees* property_trees)
    :{}

// Equivalent to
// PropertyTree<T>::~PropertyTree() = default;
// but due to a gcc bug the generated destructor will have wrong symbol
// visibility in component build.
template <typename T>
PropertyTree<T>::~PropertyTree() = default;

template <typename T>
PropertyTree<T>& PropertyTree<T>::operator=(const PropertyTree<T>&) = default;

#define DCHECK_NODE_EXISTENCE(check_node_existence, state, property,           \
                              needs_rebuild)

TransformTree::TransformTree(PropertyTrees* property_trees)
    :{}

TransformTree::~TransformTree() = default;
TransformTree& TransformTree::operator=(const TransformTree&) = default;

template <typename T>
int PropertyTree<T>::Insert(const T& tree_node, int parent_id) {}

template <typename T>
void PropertyTree<T>::RemoveNodes(size_t n) {}

template <typename T>
void PropertyTree<T>::clear() {}

#if DCHECK_IS_ON()
template <typename T>
bool PropertyTree<T>::operator==(const PropertyTree<T>& other) const {}
#endif

template <typename T>
void PropertyTree<T>::AsValueInto(base::trace_event::TracedValue* value) const {}

template class PropertyTree<TransformNode>;
template class PropertyTree<ClipNode>;
template class PropertyTree<EffectNode>;
template class PropertyTree<ScrollNode>;

int TransformTree::Insert(const TransformNode& tree_node, int parent_id) {}

void TransformTree::RemoveNodes(size_t n) {}

void TransformTree::clear() {}

void TransformTree::set_needs_update(bool needs_update) {}

bool TransformTree::OnTransformAnimated(ElementId element_id,
                                        const gfx::Transform& transform) {}

void TransformTree::ResetChangeTracking() {}

void TransformTree::UpdateAllTransforms(
    const ViewportPropertyIds& viewport_property_ids) {}

TransformTree::UpdateTransformsData::UpdateTransformsData() = default;
TransformTree::UpdateTransformsData::~UpdateTransformsData() = default;

void TransformTree::UpdateTransforms(
    int id,
    const ViewportPropertyIds* viewport_property_ids,
    UpdateTransformsData* update_data) {}

bool TransformTree::IsDescendant(int desc_id, int source_id) const {}

void TransformTree::CombineTransformsBetween(int source_id,
                                             int dest_id,
                                             gfx::Transform* transform) const {}

bool TransformTree::CombineInversesBetween(int source_id,
                                           int dest_id,
                                           gfx::Transform* transform) const {}

// This function should match the offset we set for sticky position layer in
// blink::LayoutBoxModelObject::StickyPositionOffset.
gfx::Vector2dF TransformTree::StickyPositionOffset(TransformNode* node) {}

AnchorPositionScrollData& TransformTree::EnsureAnchorPositionScrollData(
    int node_id) {}

const AnchorPositionScrollData* TransformTree::GetAnchorPositionScrollData(
    int node_id) const {}

gfx::Vector2dF TransformTree::AnchorPositionOffset(
    TransformNode* node,
    int max_updated_node_id,
    UpdateTransformsData* update_data) {}

void TransformTree::UndoOverscroll(
    const TransformNode* node,
    gfx::Vector2dF& position_adjustment,
    const ViewportPropertyIds* viewport_property_ids) {}

void TransformTree::UpdateLocalTransform(
    TransformNode* node,
    const ViewportPropertyIds* viewport_property_ids,
    UpdateTransformsData* update_data) {}

void TransformTree::UpdateScreenSpaceTransform(TransformNode* node,
                                               TransformNode* parent_node) {}

void TransformTree::UpdateAnimationProperties(TransformNode* node,
                                              TransformNode* parent_node) {}

void TransformTree::UndoSnapping(TransformNode* node) {}

void TransformTree::UpdateSnapping(TransformNode* node) {}

void TransformTree::UpdateTransformChanged(TransformNode* node,
                                           TransformNode* parent_node) {}

void TransformTree::UpdateNodeAndAncestorsAreAnimatedOrInvertible(
    TransformNode* node,
    TransformNode* parent_node) {}

void TransformTree::UpdateNodeOrAncestorsWillChangeTransform(
    TransformNode* node,
    TransformNode* parent_node) {}

void TransformTree::SetRootScaleAndTransform(
    float device_scale_factor,
    const gfx::Transform& device_transform) {}

void TransformTree::UpdateOuterViewportContainerBoundsDelta() {}

void TransformTree::AddNodeAffectedByOuterViewportBoundsDelta(int node_id) {}

bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const {}

const gfx::Transform& TransformTree::FromScreen(int node_id) const {}

void TransformTree::SetFromScreen(int node_id,
                                  const gfx::Transform& transform) {}

const gfx::Transform& TransformTree::ToScreen(int node_id) const {}

void TransformTree::SetToScreen(int node_id, const gfx::Transform& transform) {}

#if DCHECK_IS_ON()
bool TransformTree::operator==(const TransformTree& other) const {}
#endif

StickyPositionNodeData* TransformTree::MutableStickyPositionData(int node_id) {}

StickyPositionNodeData& TransformTree::EnsureStickyPositionData(int node_id) {}

EffectTree::EffectTree(PropertyTrees* property_trees)
    :{}

EffectTree::~EffectTree() = default;

int EffectTree::Insert(const EffectNode& tree_node, int parent_id) {}

void EffectTree::RemoveNodes(size_t n) {}

void EffectTree::clear() {}

float EffectTree::EffectiveOpacity(const EffectNode* node) const {}

void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) {}

void EffectTree::UpdateSubtreeHidden(EffectNode* node,
                                     EffectNode* parent_node) {}

void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) {}

void EffectTree::UpdateEffectChanged(EffectNode* node,
                                     EffectNode* parent_node) {}

void EffectTree::UpdateHasFilters(EffectNode* node, EffectNode* parent_node) {}

void EffectTree::UpdateHasFastRoundedCorner(EffectNode* node,
                                            EffectNode* parent_node) {}

void EffectTree::UpdateBackfaceVisibility(EffectNode* node,
                                          EffectNode* parent_node) {}

void EffectTree::UpdateHasMaskingChild(EffectNode* node,
                                       EffectNode* parent_node) {}

void EffectTree::UpdateOnlyDrawsVisibleContent(EffectNode* node,
                                               EffectNode* parent_node) {}

void EffectTree::UpdateSurfaceContentsScale(EffectNode* effect_node) {}

bool EffectTree::OnOpacityAnimated(ElementId id, float opacity) {}

bool EffectTree::OnFilterAnimated(ElementId id,
                                  const FilterOperations& filters) {}

bool EffectTree::OnBackdropFilterAnimated(
    ElementId id,
    const FilterOperations& backdrop_filters) {}

void EffectTree::UpdateEffects(int id) {}

void EffectTree::UpdateClosestAncestorSharedElement(EffectNode* node,
                                                    EffectNode* parent_node) {}

void EffectTree::AddCopyRequest(
    int node_id,
    std::unique_ptr<viz::CopyOutputRequest> request) {}

void EffectTree::PullCopyRequestsFrom(CopyRequestMap& new_copy_requests) {}

void EffectTree::TakeCopyRequestsAndTransformToSurface(
    int node_id,
    std::vector<std::unique_ptr<viz::CopyOutputRequest>>* requests) {}

bool EffectTree::HasCopyRequests() const {}

void EffectTree::ClearCopyRequests() {}

void EffectTree::GetRenderSurfaceChangedFlags(
    std::vector<RenderSurfacePropertyChangedFlags>& flags) const {}

void EffectTree::ApplyRenderSurfaceChangedFlags(
    const std::vector<RenderSurfacePropertyChangedFlags>& flags) {}

int EffectTree::LowestCommonAncestorWithRenderSurface(int id_1,
                                                      int id_2) const {}

bool EffectTree::ContributesToDrawnSurface(int id) const {}

void EffectTree::ResetChangeTracking() {}

void EffectTree::TakeRenderSurfaces(
    std::vector<std::unique_ptr<RenderSurfaceImpl>>* render_surfaces) {}

bool EffectTree::CreateOrReuseRenderSurfaces(
    std::vector<std::unique_ptr<RenderSurfaceImpl>>* old_render_surfaces,
    LayerTreeImpl* layer_tree_impl) {}

bool EffectTree::ClippedHitTestRegionIsRectangle(int effect_id) const {}

bool EffectTree::HitTestMayBeAffectedByMask(int effect_id) const {}

EffectTree::CopyRequestMap EffectTree::TakeCopyRequests() {}

ClipTree::ClipTree(PropertyTrees* property_trees)
    :{}

void ClipTree::SetViewportClip(gfx::RectF viewport_rect) {}

gfx::RectF ClipTree::ViewportClip() const {}

#if DCHECK_IS_ON()
bool ClipTree::operator==(const ClipTree& other) const {}
#endif

EffectTree& EffectTree::operator=(const EffectTree& from) {}

#if DCHECK_IS_ON()
bool EffectTree::operator==(const EffectTree& other) const {}
#endif

ScrollTree::ScrollTree(PropertyTrees* property_trees)
    :{}

ScrollTree::~ScrollTree() = default;

ScrollTree& ScrollTree::operator=(const ScrollTree& from) {}

#if DCHECK_IS_ON()
bool ScrollTree::operator==(const ScrollTree& other) const {}

void ScrollTree::CopyCompleteTreeState(const ScrollTree& other) {}
#endif  // DCHECK_IS_ON()

bool ScrollTree::CanRealizeScrollsOnActiveTree(const ScrollNode& node) const {}

bool ScrollTree::CanRealizeScrollsOnPendingTree(const ScrollNode& node) const {}

bool ScrollTree::ShouldRealizeScrollsOnMain(const ScrollNode& node) const {}

uint32_t ScrollTree::GetMainThreadRepaintReasons(const ScrollNode& node) const {}

void ScrollTree::clear() {}

gfx::PointF ScrollTree::MaxScrollOffset(int scroll_node_id) const {}

gfx::SizeF ScrollTree::scroll_bounds(int scroll_node_id) const {}

void ScrollTree::OnScrollOffsetAnimated(ElementId id,
                                        int scroll_tree_index,
                                        const gfx::PointF& scroll_offset,
                                        LayerTreeImpl* layer_tree_impl) {}

gfx::Size ScrollTree::container_bounds(int scroll_node_id) const {}

ScrollNode* ScrollTree::CurrentlyScrollingNode() {}

const ScrollNode* ScrollTree::CurrentlyScrollingNode() const {}

#if DCHECK_IS_ON()
int ScrollTree::CurrentlyScrollingNodeId() const {}
#endif

void ScrollTree::set_currently_scrolling_node(int scroll_node_id) {}

gfx::Transform ScrollTree::ScreenSpaceTransform(int scroll_node_id) const {}

SyncedScrollOffset* ScrollTree::GetSyncedScrollOffset(ElementId id) {}

const SyncedScrollOffset* ScrollTree::GetSyncedScrollOffset(
    ElementId id) const {}

gfx::Vector2dF ScrollTree::ClampScrollToMaxScrollOffset(
    const ScrollNode& node,
    LayerTreeImpl* layer_tree_impl) {}

const gfx::PointF ScrollTree::current_scroll_offset(ElementId id) const {}

gfx::PointF ScrollTree::GetScrollOffsetForScrollTimeline(
    const ScrollNode& scroll_node) const {}

gfx::Vector2dF ScrollTree::PullDeltaForMainThread(
    SyncedScrollOffset* scroll_offset,
    bool use_fractional_deltas,
    bool next_bmf) {}

void ScrollTree::CollectScrollDeltas(
    CompositorCommitData* commit_data,
    ElementId inner_viewport_scroll_element_id,
    bool use_fractional_deltas,
    const base::flat_map<ElementId, TargetSnapAreaElementIds>& snapped_elements,
    const MutatorHost* main_thread_mutator_host) {}

void ScrollTree::CollectScrollDeltasForTesting(bool use_fractional_deltas) {}

void ScrollTree::PushScrollUpdatesFromMainThread(
    const PropertyTrees& main_property_trees,
    LayerTreeImpl* sync_tree,
    bool use_fractional_deltas) {}

void ScrollTree::PushScrollUpdatesFromPendingTree(
    PropertyTrees* pending_property_trees,
    LayerTreeImpl* active_tree) {}

void ScrollTree::ApplySentScrollDeltasFromAbortedCommit(
    bool next_bmf,
    bool main_frame_applied_deltas) {}

void ScrollTree::SetBaseScrollOffset(ElementId id,
                                     const gfx::PointF& scroll_offset) {}

bool ScrollTree::SetScrollOffset(ElementId id,
                                 const gfx::PointF& scroll_offset) {}

void ScrollTree::SetScrollingContentsCullRect(ElementId id,
                                              const gfx::Rect& cull_rect) {}

const gfx::Rect* ScrollTree::ScrollingContentsCullRect(ElementId id) const {}

SyncedScrollOffset* ScrollTree::GetOrCreateSyncedScrollOffsetForTesting(
    ElementId id) {}

bool ScrollTree::UpdateScrollOffsetBaseForTesting(ElementId id,
                                                  const gfx::PointF& offset) {}

bool ScrollTree::SetScrollOffsetDeltaForTesting(ElementId id,
                                                const gfx::Vector2dF& delta) {}

const gfx::PointF ScrollTree::GetScrollOffsetBaseForTesting(
    ElementId id) const {}

const gfx::Vector2dF ScrollTree::GetScrollOffsetDeltaForTesting(
    ElementId id) const {}

gfx::Vector2dF ScrollTree::ScrollBy(const ScrollNode& scroll_node,
                                    const gfx::Vector2dF& scroll,
                                    LayerTreeImpl* layer_tree_impl) {}

gfx::PointF ScrollTree::ClampScrollOffsetToLimits(
    gfx::PointF offset,
    const ScrollNode& scroll_node) const {}

void ScrollTree::SetScrollCallbacks(base::WeakPtr<ScrollCallbacks> callbacks) {}

void ScrollTree::NotifyDidCompositorScroll(
    ElementId scroll_element_id,
    const gfx::PointF& scroll_offset,
    const std::optional<TargetSnapAreaElementIds>& snap_target_ids) {}

void ScrollTree::NotifyDidChangeScrollbarsHidden(ElementId scroll_element_id,
                                                 bool hidden) const {}

PropertyTreesCachedData::PropertyTreesCachedData()
    :{}

PropertyTreesCachedData::~PropertyTreesCachedData() = default;

PropertyTreesChangeState::PropertyTreesChangeState() = default;
PropertyTreesChangeState::~PropertyTreesChangeState() = default;
PropertyTreesChangeState::PropertyTreesChangeState(PropertyTreesChangeState&&) =
    default;
PropertyTreesChangeState& PropertyTreesChangeState::operator=(
    PropertyTreesChangeState&&) = default;

PropertyTrees::PropertyTrees(const ProtectedSequenceSynchronizer& synchronizer)
    :{}

PropertyTrees::~PropertyTrees() = default;

#if DCHECK_IS_ON()
bool PropertyTrees::operator==(const PropertyTrees& other) const {}
#endif

PropertyTrees& PropertyTrees::operator=(const PropertyTrees& from) {}

void PropertyTrees::clear() {}

void PropertyTrees::SetInnerViewportContainerBoundsDelta(
    gfx::Vector2dF bounds_delta) {}

void PropertyTrees::SetOuterViewportContainerBoundsDelta(
    gfx::Vector2dF bounds_delta) {}

bool PropertyTrees::ElementIsAnimatingChanged(
    const PropertyToElementIdMap& element_id_map,
    const PropertyAnimationState& mask,
    const PropertyAnimationState& state,
    bool check_node_existence) {}

void PropertyTrees::MaximumAnimationScaleChanged(ElementId element_id,
                                                 float maximum_scale) {}

void PropertyTrees::UpdateChangeTracking() {}

void PropertyTrees::GetChangedNodes(std::vector<int>& effect_nodes,
                                    std::vector<int>& transform_nodes) const {}

void PropertyTrees::ApplyChangedNodes(
    const std::vector<int>& changed_effect_nodes,
    const std::vector<int>& changed_transform_nodes) {}

void PropertyTrees::GetChangeState(PropertyTreesChangeState& change_state) {}

void PropertyTrees::ResetAllChangeTracking() {}

std::unique_ptr<base::trace_event::TracedValue> PropertyTrees::AsTracedValue()
    const {}

void PropertyTrees::AsValueInto(base::trace_event::TracedValue* value) const {}

std::string PropertyTrees::ToString() const {}

bool PropertyTrees::AnimationScaleCacheIsInvalid(int transform_id) const {}

float PropertyTrees::MaximumAnimationToScreenScale(int transform_id) {}

bool PropertyTrees::AnimationAffectedByInvalidScale(int transform_id) {}

const AnimationScaleData& PropertyTrees::GetAnimationScaleData(
    int transform_id) {}

void PropertyTrees::SetMaximumAnimationToScreenScaleForTesting(
    int transform_id,
    float maximum_scale,
    bool affected_by_invalid_scale) {}

bool PropertyTrees::GetToTarget(int transform_id,
                                int effect_id,
                                gfx::Transform* to_target) const {}

bool PropertyTrees::GetFromTarget(int transform_id,
                                  int effect_id,
                                  gfx::Transform* from_target) const {}

DrawTransformData& PropertyTrees::FetchDrawTransformsDataFromCache(
    int transform_id,
    int dest_id) const {}

ClipRectData* PropertyTrees::FetchClipRectFromCache(int clip_id,
                                                    int target_id) {}

bool PropertyTrees::HasElement(ElementId element_id) const {}

DrawTransforms& PropertyTrees::GetDrawTransforms(int transform_id,
                                                 int effect_id) const {}

void PropertyTrees::ResetCachedData() {}

void PropertyTrees::UpdateTransformTreeUpdateNumber() {}

gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale(
    int transform_id,
    int effect_id) const {}

}  // namespace cc