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

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

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

#include "base/containers/adapters.h"
#include "cc/layers/scrollbar_layer_base.h"
#include "cc/layers/solid_color_layer.h"
#include "third_party/blink/renderer/platform/geometry/geometry_as_json.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_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/scroll_paint_property_node.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"

namespace blink {

namespace {

// Snap |bounds| if within floating-point numeric limits of an integral rect.
void PreserveNearIntegralBounds(gfx::RectF& bounds) {}

}  // anonymous namespace

PendingLayer::PendingLayer(const PaintArtifact& artifact,
                           const PaintChunk& first_chunk,
                           CompositingType compositing_type)
    :{}

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

gfx::Vector2dF PendingLayer::LayerOffset() const {}

gfx::Size PendingLayer::LayerBounds() const {}

gfx::RectF PendingLayer::MapRectKnownToBeOpaque(
    const PropertyTreeState& new_state,
    const FloatClipRect& mapped_layer_bounds) const {}

std::unique_ptr<JSONObject> PendingLayer::ToJSON() const {}

String PendingLayer::DebugName() const {}

DOMNodeId PendingLayer::OwnerNodeId() const {}

std::ostream& operator<<(std::ostream& os, const PendingLayer& layer) {}

void PendingLayer::Upcast(const PropertyTreeState& new_state) {}

const PaintChunk& PendingLayer::FirstPaintChunk() const {}

const DisplayItem& PendingLayer::FirstDisplayItem() const {}

bool PendingLayer::Matches(const PendingLayer& old_pending_layer) const {}

// We will only allow merging if
// merged_area - (home_area + guest_area) <= kMergeSparsityAreaTolerance
static constexpr float kMergeSparsityAreaTolerance =;

bool PendingLayer::CanMerge(
    const PendingLayer& guest,
    LCDTextPreference lcd_text_preference,
    IsCompositedScrollFunction is_composited_scroll,
    gfx::RectF& merged_bounds,
    PropertyTreeState& merged_state,
    gfx::RectF& merged_rect_known_to_be_opaque,
    bool& merged_text_known_to_be_on_opaque_background,
    wtf_size_t& merged_solid_color_chunk_index,
    cc::HitTestOpaqueness& merged_hit_test_opaqueness) const {}

bool PendingLayer::Merge(const PendingLayer& guest,
                         LCDTextPreference lcd_text_preference,
                         IsCompositedScrollFunction is_composited_scroll) {}

std::optional<PropertyTreeState> PendingLayer::CanUpcastWith(
    const PendingLayer& guest,
    const PropertyTreeState& guest_state,
    IsCompositedScrollFunction is_composited_scroll) const {}

bool PendingLayer::CanMergeWithDecompositedBlendMode(
    const PendingLayer& guest,
    const PropertyTreeState& upcast_state,
    IsCompositedScrollFunction is_composited_scroll) const {}

const TransformPaintPropertyNode&
PendingLayer::ScrollTranslationForScrollHitTestLayer() const {}

bool PendingLayer::PropertyTreeStateChanged(
    const PendingLayer* old_pending_layer) const {}

bool PendingLayer::MightOverlap(const PendingLayer& other) const {}

// Walk the pending layer list and build up a table of transform nodes that
// can be de-composited (replaced with offset_to_transform_parent). A
// transform node can be de-composited if:
//  1. It is not the root transform node.
//  2. It is a 2d translation only.
//  3. The transform is not used for scrolling - its ScrollNode() is nullptr.
//  4. The transform is not a StickyTranslation node.
//  5. It has no direct compositing reasons, other than k3DTransform. Note
//     that if it has a k3DTransform reason, check #2 above ensures that it
//     isn't really 3D.
//  6. It has FlattensInheritedTransform matching that of its direct parent.
//  7. It has backface visibility matching its direct parent.
//  8. No clips have local_transform_space referring to this transform node.
//  9. No effects have local_transform_space referring to this transform node.
//  10. All child transform nodes are also able to be de-composited.
// This algorithm should be O(t+c+e) where t,c,e are the number of transform,
// clip, and effect nodes in the full tree.
void PendingLayer::DecompositeTransforms(PendingLayers& pending_layers) {}

void PendingLayer::UpdateForeignLayer() {}

void PendingLayer::UpdateScrollHitTestLayer(PendingLayer* old_pending_layer) {}

void PendingLayer::UpdateScrollbarLayer(PendingLayer* old_pending_layer) {}

void PendingLayer::UpdateContentLayer(PendingLayer* old_pending_layer,
                                      bool tracks_raster_invalidations) {}

void PendingLayer::UpdateSolidColorLayer(PendingLayer* old_pending_layer) {}

bool PendingLayer::UsesSolidColorLayer() const {}

SkColor4f PendingLayer::GetSolidColor() const {}

void PendingLayer::UpdateCompositedLayer(PendingLayer* old_pending_layer,
                                         cc::LayerSelection& layer_selection,
                                         bool tracks_raster_invalidations,
                                         cc::LayerTreeHost* layer_tree_host) {}

void PendingLayer::UpdateCcLayerHitTestOpaqueness() const {}

void PendingLayer::UpdateCompositedLayerForRepaint(
    const PaintArtifact& repainted_artifact,
    cc::LayerSelection& layer_selection) {}

void PendingLayer::UpdateLayerProperties(cc::LayerSelection& layer_selection,
                                         bool selection_only) {}

// The heuristic for picking a checkerboarding color works as follows:
// - During paint, PaintChunker will look for background color display items,
//   and record the blending of background colors if the background is larger
//   than a ratio of the chunk bounds.
// - After layer allocation, the paint chunks assigned to a layer are examined
//   for a background color annotation.
// - The blending of background colors of chunks having background larger than
//   a ratio of the layer is set as the layer's background color.
SkColor4f PendingLayer::ComputeBackgroundColor() const {}

}  // namespace blink