#include "cc/layers/layer.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <unordered_set>
#include <utility>
#include <vector>
#include "base/atomic_sequence_num.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h"
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "cc/base/features.h"
#include "cc/base/simple_enclosed_region.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/picture_layer.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/draw_property_utils.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/mutator_host.h"
#include "cc/trees/property_tree_builder.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "components/viz/common/view_transition_element_resource_id.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
namespace cc {
struct SameSizeAsLayer : public base::RefCounted<SameSizeAsLayer>,
public ProtectedSequenceSynchronizer { … };
static_assert …;
base::AtomicSequenceNumber g_next_layer_id;
constexpr gfx::Transform Layer::kIdentityTransform;
constexpr gfx::RoundedCornersF Layer::kNoRoundedCornersF;
LayerDebugInfo::LayerDebugInfo() = default;
LayerDebugInfo::LayerDebugInfo(const LayerDebugInfo&) = default;
LayerDebugInfo::~LayerDebugInfo() = default;
Layer::RareInputs::RareInputs() = default;
Layer::RareInputs::~RareInputs() = default;
Layer::Inputs::Inputs() = default;
Layer::Inputs::~Inputs() = default;
Layer::LayerTreeInputs::LayerTreeInputs() = default;
Layer::LayerTreeInputs::~LayerTreeInputs() = default;
scoped_refptr<Layer> Layer::Create() { … }
Layer::Layer()
: … { … }
Layer::~Layer() { … }
Layer::LayerTreeInputs& Layer::EnsureLayerTreeInputs() { … }
#if DCHECK_IS_ON()
const Layer::LayerTreeInputs* Layer::layer_tree_inputs() const { … }
#endif
void Layer::SetLayerTreeHost(LayerTreeHost* host) { … }
void Layer::SetNeedsCommit() { … }
void Layer::SetDebugName(const std::string& name) { … }
viz::ViewTransitionElementResourceId Layer::ViewTransitionResourceId() const { … }
bool Layer::IsSolidColorLayerForTesting() const { … }
void Layer::SetNeedsFullTreeSync() { … }
void Layer::SetNeedsPushProperties() { … }
bool Layer::IsPropertyChangeAllowed() const { … }
void Layer::CaptureContent(const gfx::Rect& rect,
std::vector<NodeInfo>* content) const { … }
sk_sp<const SkPicture> Layer::GetPicture() const { … }
void Layer::SetParent(Layer* layer, RemovalReason reason) { … }
void Layer::AddChild(scoped_refptr<Layer> child) { … }
void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { … }
void Layer::RemoveFromParent() { … }
void Layer::RemoveFromParentForReadd() { … }
void Layer::RemoveChild(Layer* child, RemovalReason reason) { … }
bool Layer::GetBitFlag(uint8_t mask) const { … }
bool Layer::SetBitFlag(bool new_value,
uint8_t mask,
bool invalidate,
bool needs_push) { … }
void Layer::ReorderChildren(LayerList* new_children_order) { … }
void Layer::ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer) { … }
void Layer::SetBounds(const gfx::Size& size) { … }
Layer* Layer::RootLayer() { … }
void Layer::RemoveAllChildren() { … }
void Layer::SetChildLayerList(LayerList new_children) { … }
bool Layer::HasAncestor(const Layer* ancestor) const { … }
void Layer::RequestCopyOfOutput(
std::unique_ptr<viz::CopyOutputRequest> request) { … }
void Layer::SetBackgroundColor(SkColor4f background_color) { … }
void Layer::SetSafeOpaqueBackgroundColor(SkColor4f background_color) { … }
SkColor4f Layer::SafeOpaqueBackgroundColor() const { … }
void Layer::SetMasksToBounds(bool masks_to_bounds) { … }
void Layer::SetClipRect(const gfx::Rect& clip_rect) { … }
gfx::RectF Layer::EffectiveClipRect() const { … }
void Layer::SetMaskLayer(scoped_refptr<PictureLayer> mask_layer) { … }
void Layer::SetFilters(const FilterOperations& filters) { … }
void Layer::SetBackdropFilters(const FilterOperations& filters) { … }
void Layer::SetBackdropFilterBounds(const gfx::RRectF& backdrop_filter_bounds) { … }
void Layer::ClearBackdropFilterBounds() { … }
void Layer::SetBackdropFilterQuality(const float quality) { … }
void Layer::UpdateMaskFilterInfo(const gfx::RoundedCornersF* corner_radii,
const gfx::LinearGradient* gradient_mask) { … }
void Layer::SetRoundedCorner(const gfx::RoundedCornersF& corner_radii) { … }
void Layer::SetGradientMask(const gfx::LinearGradient& gradient_mask) { … }
void Layer::SetIsFastRoundedCorner(bool enable) { … }
void Layer::SetOpacity(float opacity) { … }
float Layer::EffectiveOpacity() const { … }
bool Layer::OpacityCanAnimateOnImplThread() const { … }
void Layer::SetBlendMode(SkBlendMode blend_mode) { … }
void Layer::SetHitTestOpaqueness(HitTestOpaqueness opaqueness) { … }
void Layer::SetHitTestable(bool hit_testable) { … }
void Layer::SetContentsOpaque(bool opaque) { … }
void Layer::SetContentsOpaqueForText(bool opaque) { … }
void Layer::SetPosition(const gfx::PointF& position) { … }
bool Are2dAxisAligned(const gfx::Transform& a, const gfx::Transform& b) { … }
void Layer::SetTransform(const gfx::Transform& transform) { … }
void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { … }
void Layer::SetScrollOffset(const gfx::PointF& scroll_offset) { … }
void Layer::SetScrollOffsetFromImplSide(const gfx::PointF& scroll_offset) { … }
void Layer::UpdatePropertyTreeScrollOffset() { … }
void Layer::SetDidScrollCallback(
base::RepeatingCallback<void(const gfx::PointF&, const ElementId&)>
callback) { … }
void Layer::SetSubtreeCaptureId(viz::SubtreeCaptureId subtree_id) { … }
void Layer::SetScrollable(const gfx::Size& bounds) { … }
bool Layer::IsScrollbarLayerForTesting() const { … }
void Layer::SetMainThreadScrollHitTestRegion(const Region& region) { … }
void Layer::SetNonCompositedScrollHitTestRects(
std::vector<ScrollHitTestRect> rects) { … }
void Layer::SetTouchActionRegion(TouchActionRegion touch_action_region) { … }
void Layer::SetCaptureBounds(viz::RegionCaptureBounds bounds) { … }
void Layer::SetWheelEventRegion(Region wheel_event_region) { … }
RenderSurfaceReason Layer::GetRenderSurfaceReason() const { … }
void Layer::SetTransformTreeIndex(int index) { … }
int Layer::transform_tree_index(const PropertyTrees& property_trees) const { … }
bool Layer::transform_tree_index_is_valid(
const PropertyTrees& property_trees) const { … }
int Layer::transform_tree_index() const { … }
void Layer::SetClipTreeIndex(int index) { … }
int Layer::clip_tree_index(const PropertyTrees& property_trees) const { … }
bool Layer::clip_tree_index_is_valid(
const PropertyTrees& property_trees) const { … }
int Layer::clip_tree_index() const { … }
void Layer::SetEffectTreeIndex(int index) { … }
int Layer::effect_tree_index(const PropertyTrees& property_trees) const { … }
bool Layer::effect_tree_index_is_valid(
const PropertyTrees& property_trees) const { … }
int Layer::effect_tree_index() const { … }
void Layer::SetScrollTreeIndex(int index) { … }
int Layer::scroll_tree_index(const PropertyTrees& property_trees) const { … }
bool Layer::scroll_tree_index_is_valid(
const PropertyTrees& property_trees) const { … }
int Layer::scroll_tree_index() const { … }
void Layer::SetOffsetToTransformParent(gfx::Vector2dF offset) { … }
void Layer::InvalidatePropertyTreesIndices() { … }
void Layer::SetPropertyTreesNeedRebuild() { … }
LayerDebugInfo& Layer::EnsureDebugInfo() { … }
void Layer::ClearDebugInfo() { … }
std::string Layer::DebugName() const { … }
std::string Layer::ToString() const { … }
void Layer::SetIsDrawable(bool is_drawable) { … }
void Layer::SetHideLayerAndSubtree(bool hide) { … }
void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { … }
bool Layer::RequiresSetNeedsDisplayOnHdrHeadroomChange() const { … }
bool Layer::IsSnappedToPixelGridInTarget() const { … }
void Layer::PushPropertiesTo(LayerImpl* layer,
const CommitState& commit_state,
const ThreadUnsafeCommitState& unsafe_state) { … }
void Layer::TakeCopyRequests(
std::vector<std::unique_ptr<viz::CopyOutputRequest>>* requests) { … }
std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(
LayerTreeImpl* tree_impl) const { … }
bool Layer::HasDrawableContent() const { … }
void Layer::UpdateDrawsContent() { … }
int Layer::NumDescendantsThatDrawContent() const { … }
bool Layer::Update() { … }
void Layer::SetSubtreePropertyChanged() { … }
bool Layer::IsOwnerThread() const { … }
bool Layer::IsMainThread() const { … }
bool Layer::InProtectedSequence() const { … }
void Layer::WaitForProtectedSequenceCompletion() const { … }
bool Layer::IsUsingLayerLists() const { … }
void Layer::OnFilterAnimated(const FilterOperations& filters) { … }
void Layer::OnBackdropFilterAnimated(const FilterOperations& backdrop_filters) { … }
void Layer::OnOpacityAnimated(float opacity) { … }
void Layer::OnTransformAnimated(const gfx::Transform& transform) { … }
void Layer::SetTrilinearFiltering(bool trilinear_filtering) { … }
void Layer::IncrementMirrorCount() { … }
void Layer::DecrementMirrorCount() { … }
void Layer::SetMirrorCount(int mirror_count) { … }
ElementListType Layer::GetElementTypeForAnimation() const { … }
void Layer::AddDrawableDescendants(int num) { … }
void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { … }
void Layer::SetElementId(ElementId id) { … }
gfx::Transform Layer::ScreenSpaceTransform() const { … }
}