chromium/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"

#include <memory>
#include <utility>

#include "base/debug/dump_without_crashing.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "cc/base/features.h"
#include "cc/layers/solid_color_scrollbar_layer.h"
#include "cc/paint/display_item_list.h"
#include "cc/paint/paint_flags.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/mutator_host.h"
#include "cc/view_transition/view_transition_request.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/geometry/geometry_as_json.h"
#include "third_party/blink/renderer/platform/graphics/compositing/adjust_mask_layer_geometry.h"
#include "third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_chunk_subset.h"
#include "third_party/blink/renderer/platform/graphics/paint/property_tree_state.h"
#include "third_party/blink/renderer/platform/graphics/paint/raster_invalidation_tracking.h"
#include "third_party/blink/renderer/platform/graphics/paint/scroll_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/scrollbar_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "ui/gfx/geometry/rect.h"

namespace blink {

// cc property trees make use of a sequence number to identify when tree
// topology changes. For now we naively increment the sequence number each time
// we update the property trees. We should explore optimizing our management of
// the sequence number through the use of a dirty bit or similar. See
// http://crbug.com/692842#c4.
static int g_s_property_tree_sequence_number =;

class PaintArtifactCompositor::OldPendingLayerMatcher {};

PaintArtifactCompositor::PaintArtifactCompositor(
    base::WeakPtr<CompositorScrollCallbacks> scroll_callbacks)
    :{}

PaintArtifactCompositor::~PaintArtifactCompositor() {}

void PaintArtifactCompositor::Trace(Visitor* visitor) const {}

void PaintArtifactCompositor::SetTracksRasterInvalidations(bool should_track) {}

void PaintArtifactCompositor::WillBeRemovedFromFrame() {}

void PaintArtifactCompositor::SetLCDTextPreference(
    LCDTextPreference preference) {}

std::unique_ptr<JSONArray> PaintArtifactCompositor::GetPendingLayersAsJSON()
    const {}

// Get a JSON representation of what layers exist for this PAC.
std::unique_ptr<JSONObject> PaintArtifactCompositor::GetLayersAsJSON(
    LayerTreeFlags flags) const {}

const TransformPaintPropertyNode&
PaintArtifactCompositor::ScrollTranslationStateForLayer(
    const PendingLayer& pending_layer) {}

bool PaintArtifactCompositor::NeedsCompositedScrolling(
    const TransformPaintPropertyNode& scroll_translation) const {}

bool PaintArtifactCompositor::ShouldForceMainThreadRepaint(
    const TransformPaintPropertyNode& scroll_translation) const {}

bool PaintArtifactCompositor::ComputeNeedsCompositedScrolling(
    const PaintArtifact& artifact,
    PaintChunks::const_iterator chunk_cursor) const {}

void PaintArtifactCompositor::UpdatePaintedScrollTranslationsBeforeLayerization(
    const PaintArtifact& artifact,
    PaintChunks::const_iterator chunk_cursor) {}

PendingLayer::CompositingType PaintArtifactCompositor::ChunkCompositingType(
    const PaintArtifact& artifact,
    const PaintChunk& chunk) const {}

namespace {

cc::Layer* ForeignLayer(const PaintChunk& chunk,
                        const PaintArtifact& artifact) {}

// True if the paint chunk change affects the result of |Update|, such as the
// compositing decisions in |CollectPendingLayers|. This will return false for
// repaint updates that can be handled by |UpdateRepaintedLayers|, such as
// background color changes.
bool NeedsFullUpdateAfterPaintingChunk(
    const PaintChunk& previous,
    const PaintArtifact& previous_artifact,
    const PaintChunk& repainted,
    const PaintArtifact& repainted_artifact) {}

}  // namespace

void PaintArtifactCompositor::SetNeedsFullUpdateAfterPaintIfNeeded(
    const PaintArtifact& previous,
    const PaintArtifact& repainted) {}

bool PaintArtifactCompositor::HasComposited(
    CompositorElementId element_id) const {}

class PaintArtifactCompositor::Layerizer {};

// Returns nullptr if 'ancestor' is not a strict ancestor of 'node'.
// Otherwise, return the child of 'ancestor' that is an ancestor of 'node' or
// 'node' itself.
static const EffectPaintPropertyNode* StrictUnaliasedChildOfAlongPath(
    const EffectPaintPropertyNode& ancestor,
    const EffectPaintPropertyNode& node) {}

bool PaintArtifactCompositor::Layerizer::DecompositeEffect(
    const EffectPaintPropertyNode& parent_effect,
    wtf_size_t first_layer_in_parent_group_index,
    const EffectPaintPropertyNode& effect,
    wtf_size_t layer_index) {}

void PaintArtifactCompositor::Layerizer::LayerizeGroup(
    const EffectPaintPropertyNode& current_group,
    bool force_draws_content) {}

PendingLayers PaintArtifactCompositor::Layerizer::Layerize() {}

void SynthesizedClip::UpdateLayer(const ClipPaintPropertyNode& clip,
                                  const TransformPaintPropertyNode& transform) {}

scoped_refptr<cc::DisplayItemList>
SynthesizedClip::PaintContentsToDisplayList() {}

SynthesizedClip& PaintArtifactCompositor::CreateOrReuseSynthesizedClipLayer(
    const ClipPaintPropertyNode& clip,
    const TransformPaintPropertyNode& transform,
    bool needs_layer,
    CompositorElementId& mask_isolation_id,
    CompositorElementId& mask_effect_id) {}

void PaintArtifactCompositor::UpdateCompositorViewportProperties(
    const ViewportProperties& properties,
    PropertyTreeManager& property_tree_manager,
    cc::LayerTreeHost* layer_tree_host) {}

void PaintArtifactCompositor::Update(
    const PaintArtifact& artifact,
    const ViewportProperties& viewport_properties,
    const StackScrollTranslationVector& scroll_translation_nodes,
    Vector<std::unique_ptr<cc::ViewTransitionRequest>> transition_requests) {}

void PaintArtifactCompositor::UpdateRepaintedLayers(
    const PaintArtifact& repainted_artifact) {}

bool PaintArtifactCompositor::CanDirectlyUpdateProperties() const {}

bool PaintArtifactCompositor::DirectlyUpdateCompositedOpacityValue(
    const EffectPaintPropertyNode& effect) {}

bool PaintArtifactCompositor::DirectlyUpdateScrollOffsetTransform(
    const TransformPaintPropertyNode& transform) {}

bool PaintArtifactCompositor::DirectlyUpdateTransform(
    const TransformPaintPropertyNode& transform) {}

bool PaintArtifactCompositor::DirectlyUpdatePageScaleTransform(
    const TransformPaintPropertyNode& transform) {}

bool PaintArtifactCompositor::DirectlySetScrollOffset(
    CompositorElementId element_id,
    const gfx::PointF& scroll_offset) {}

void PaintArtifactCompositor::DropCompositorScrollDeltaNextCommit(
    CompositorElementId element_id) {}

uint32_t PaintArtifactCompositor::GetMainThreadScrollingReasons(
    const ScrollPaintPropertyNode& scroll) const {}

bool PaintArtifactCompositor::UsesCompositedScrolling(
    const ScrollPaintPropertyNode& scroll) const {}

void PaintArtifactCompositor::SetLayerDebugInfoEnabled(bool enabled) {}

void PaintArtifactCompositor::UpdateDebugInfo() const {}

// The returned compositing reasons are informative for tracing/debugging.
// Some are based on heuristics so are not fully accurate.
CompositingReasons PaintArtifactCompositor::GetCompositingReasons(
    const PendingLayer& layer,
    const PropertyTreeState& previous_layer_state) const {}

Vector<cc::Layer*> PaintArtifactCompositor::SynthesizedClipLayersForTesting()
    const {}

size_t PaintArtifactCompositor::ApproximateUnsharedMemoryUsage() const {}

bool PaintArtifactCompositor::SetScrollbarNeedsDisplay(
    CompositorElementId element_id) {}

bool PaintArtifactCompositor::SetScrollbarSolidColor(
    CompositorElementId element_id,
    SkColor4f color) {}

void LayerListBuilder::Add(scoped_refptr<cc::Layer> layer) {}

cc::LayerList LayerListBuilder::Finalize() {}

#if DCHECK_IS_ON()
void PaintArtifactCompositor::ShowDebugData() {}
#endif

ContentLayerClientImpl* PaintArtifactCompositor::ContentLayerClientForTesting(
    wtf_size_t i) const {}

}  // namespace blink