#include "cc/layers/layer_impl.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <utility>
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "cc/base/math_util.h"
#include "cc/base/simple_enclosed_region.h"
#include "cc/benchmarks/micro_benchmark_impl.h"
#include "cc/debug/debug_colors.h"
#include "cc/debug/layer_tree_debug_state.h"
#include "cc/input/scroll_state.h"
#include "cc/layers/layer.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/draw_property_utils.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/layer_tree_settings.h"
#include "cc/trees/mutator_host.h"
#include "cc/trees/proxy.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "components/viz/client/client_resource_provider.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/quads/compositor_render_pass.h"
#include "components/viz/common/quads/debug_border_draw_quad.h"
#include "components/viz/common/traced_value.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/transform_util.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
namespace cc {
namespace {
template <typename T>
std::unique_ptr<T> ClonePtr(const std::unique_ptr<T>& value) { … }
const char* LayerTypeAsString(mojom::LayerType type) { … }
}
LayerImpl::RareProperties::RareProperties() = default;
LayerImpl::RareProperties::RareProperties(const RareProperties&) = default;
LayerImpl::RareProperties::~RareProperties() = default;
LayerImpl::LayerImpl(LayerTreeImpl* tree_impl,
int id,
bool will_always_push_properties)
: … { … }
LayerImpl::~LayerImpl() { … }
mojom::LayerType LayerImpl::GetLayerType() const { … }
ElementListType LayerImpl::GetElementTypeForAnimation() const { … }
void LayerImpl::UpdateDebugInfo(LayerDebugInfo* debug_info) { … }
void LayerImpl::SetTransformTreeIndex(int index) { … }
void LayerImpl::SetClipTreeIndex(int index) { … }
void LayerImpl::SetEffectTreeIndex(int index) { … }
int LayerImpl::render_target_effect_tree_index() const { … }
void LayerImpl::SetScrollTreeIndex(int index) { … }
void LayerImpl::PopulateSharedQuadState(viz::SharedQuadState* state,
bool contents_opaque) const { … }
void LayerImpl::PopulateScaledSharedQuadState(viz::SharedQuadState* state,
float layer_to_content_scale,
bool contents_opaque) const { … }
void LayerImpl::PopulateScaledSharedQuadStateWithContentRects(
viz::SharedQuadState* state,
float layer_to_content_scale,
const gfx::Rect& content_rect,
const gfx::Rect& visible_content_rect,
bool contents_opaque) const { … }
bool LayerImpl::WillDraw(DrawMode draw_mode,
viz::ClientResourceProvider* resource_provider) { … }
void LayerImpl::DidDraw(viz::ClientResourceProvider* resource_provider) { … }
bool LayerImpl::ShowDebugBorders(DebugBorderType type) const { … }
void LayerImpl::GetDebugBorderProperties(SkColor4f* color, float* width) const { … }
void LayerImpl::AppendDebugBorderQuad(
viz::CompositorRenderPass* render_pass,
const gfx::Rect& quad_rect,
const viz::SharedQuadState* shared_quad_state,
AppendQuadsData* append_quads_data) const { … }
void LayerImpl::AppendDebugBorderQuad(
viz::CompositorRenderPass* render_pass,
const gfx::Rect& quad_rect,
const viz::SharedQuadState* shared_quad_state,
AppendQuadsData* append_quads_data,
SkColor4f color,
float width) const { … }
void LayerImpl::GetContentsResourceId(viz::ResourceId* resource_id,
gfx::Size* resource_size,
gfx::SizeF* resource_uv_size) const { … }
gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { … }
void LayerImpl::SetTouchActionRegion(TouchActionRegion region) { … }
const Region& LayerImpl::GetAllTouchActionRegions() const { … }
void LayerImpl::SetCaptureBounds(viz::RegionCaptureBounds bounds) { … }
std::unique_ptr<LayerImpl> LayerImpl::CreateLayerImpl(
LayerTreeImpl* tree_impl) const { … }
bool LayerImpl::IsSnappedToPixelGridInTarget() { … }
void LayerImpl::PushPropertiesTo(LayerImpl* layer) { … }
bool LayerImpl::IsAffectedByPageScale() const { … }
bool LayerImpl::LayerPropertyChanged() const { … }
bool LayerImpl::LayerPropertyChangedFromPropertyTrees() const { … }
bool LayerImpl::LayerPropertyChangedNotFromPropertyTrees() const { … }
void LayerImpl::NoteLayerPropertyChanged() { … }
void LayerImpl::NoteLayerPropertyChangedFromPropertyTrees() { … }
void LayerImpl::ValidateQuadResourcesInternal(viz::DrawQuad* quad) const { … }
gfx::Transform LayerImpl::GetScaledDrawTransform(
float layer_to_content_scale) const { … }
void LayerImpl::ResetChangeTracking() { … }
bool LayerImpl::IsActive() const { … }
gfx::Size LayerImpl::bounds() const { … }
void LayerImpl::SetBounds(const gfx::Size& bounds) { … }
bool LayerImpl::IsScrollbarLayer() const { … }
bool LayerImpl::IsScrollerOrScrollbar() const { … }
void LayerImpl::SetDrawsContent(bool draws_content) { … }
void LayerImpl::SetHitTestOpaqueness(HitTestOpaqueness opaqueness) { … }
bool LayerImpl::HitTestable() const { … }
bool LayerImpl::OpaqueToHitTest() const { … }
void LayerImpl::SetBackgroundColor(SkColor4f background_color) { … }
void LayerImpl::SetSafeOpaqueBackgroundColor(SkColor4f background_color) { … }
void LayerImpl::SetContentsOpaque(bool opaque) { … }
void LayerImpl::SetContentsOpaqueForText(bool opaque) { … }
float LayerImpl::Opacity() const { … }
void LayerImpl::SetElementId(ElementId element_id) { … }
void LayerImpl::UnionUpdateRect(const gfx::Rect& update_rect) { … }
gfx::Rect LayerImpl::GetDamageRect() const { … }
DamageReasonSet LayerImpl::GetDamageReasons() const { … }
void LayerImpl::SetCurrentScrollOffset(const gfx::PointF& scroll_offset) { … }
SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { … }
void LayerImpl::DidBeginTracing() { … }
void LayerImpl::ReleaseResources() { … }
void LayerImpl::OnPurgeMemory() { … }
void LayerImpl::ReleaseTileResources() { … }
void LayerImpl::RecreateTileResources() { … }
void LayerImpl::SetNeedsPushProperties() { … }
void LayerImpl::GetAllPrioritizedTilesForTracing(
std::vector<PrioritizedTile>* prioritized_tiles) const { … }
void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const { … }
std::string LayerImpl::ToString() const { … }
size_t LayerImpl::GPUMemoryUsageInBytes() const { … }
void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { … }
gfx::Transform LayerImpl::DrawTransform() const { … }
gfx::Transform LayerImpl::ScreenSpaceTransform() const { … }
int LayerImpl::GetSortingContextId() const { … }
Region LayerImpl::GetInvalidationRegionForDebugging() { … }
gfx::Rect LayerImpl::GetEnclosingVisibleRectInTargetSpace() const { … }
gfx::Rect LayerImpl::GetScaledEnclosingVisibleRectInTargetSpace(
float scale) const { … }
RenderSurfaceImpl* LayerImpl::render_target() { … }
const RenderSurfaceImpl* LayerImpl::render_target() const { … }
gfx::Vector2dF LayerImpl::GetIdealContentsScale() const { … }
float LayerImpl::GetIdealContentsScaleKey() const { … }
float LayerImpl::GetPreferredRasterScale(
gfx::Vector2dF raster_space_scale_factor) { … }
PropertyTrees* LayerImpl::GetPropertyTrees() const { … }
ClipTree& LayerImpl::GetClipTree() const { … }
EffectTree& LayerImpl::GetEffectTree() const { … }
ScrollTree& LayerImpl::GetScrollTree() const { … }
TransformTree& LayerImpl::GetTransformTree() const { … }
void LayerImpl::EnsureValidPropertyTreeIndices() const { … }
bool LayerImpl::is_surface_layer() const { … }
static float TranslationFromActiveTreeLayerScreenSpaceTransform(
LayerImpl* pending_tree_layer) { … }
int LayerImpl::CalculateJitter() { … }
std::string LayerImpl::DebugName() const { … }
gfx::ContentColorUsage LayerImpl::GetContentColorUsage() const { … }
viz::ViewTransitionElementResourceId LayerImpl::ViewTransitionResourceId()
const { … }
}