chromium/third_party/blink/renderer/platform/widget/compositing/layer_tree_view.cc

// Copyright 2013 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/widget/compositing/layer_tree_view.h"

#include <stddef.h>

#include <string>
#include <utility>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/time/time.h"
#include "base/values.h"
#include "cc/animation/animation_host.h"
#include "cc/animation/animation_timeline.h"
#include "cc/base/features.h"
#include "cc/base/region.h"
#include "cc/benchmarks/micro_benchmark.h"
#include "cc/debug/layer_tree_debug_state.h"
#include "cc/input/layer_selection_bound.h"
#include "cc/layers/layer.h"
#include "cc/metrics/ukm_manager.h"
#include "cc/metrics/web_vital_metrics.h"
#include "cc/tiles/raster_dark_mode_filter.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_mutator.h"
#include "cc/trees/paint_holding_reason.h"
#include "cc/trees/presentation_time_callback_buffer.h"
#include "cc/trees/render_frame_metadata_observer.h"
#include "cc/trees/swap_promise.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/quads/compositor_frame_metadata.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/strings/grit/blink_strings.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_filter.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_settings_builder.h"
#include "third_party/blink/renderer/platform/graphics/raster_dark_mode_filter_impl.h"
#include "third_party/blink/renderer/platform/scheduler/public/widget_scheduler.h"
#include "ui/gfx/presentation_feedback.h"

namespace cc {
class Layer;
}

namespace blink {

namespace {
// This factory is used to defer binding of the InterfacePtr to the compositor
// thread.
class UkmRecorderFactoryImpl : public cc::UkmRecorderFactory {};

}  // namespace

LayerTreeView::LayerTreeView(
    LayerTreeViewDelegate* delegate,
    scoped_refptr<scheduler::WidgetScheduler> scheduler)
    :{}

LayerTreeView::~LayerTreeView() = default;

void LayerTreeView::Initialize(
    const cc::LayerTreeSettings& settings,
    scoped_refptr<base::SingleThreadTaskRunner> main_thread,
    scoped_refptr<base::SingleThreadTaskRunner> compositor_thread,
    cc::TaskGraphRunner* task_graph_runner) {}

void LayerTreeView::Disconnect() {}

void LayerTreeView::ReattachTo(
    LayerTreeViewDelegate* delegate,
    scoped_refptr<scheduler::WidgetScheduler> scheduler) {}

void LayerTreeView::SetVisible(bool visible) {}

void LayerTreeView::SetShouldWarmUp() {}

void LayerTreeView::SetLayerTreeFrameSink(
    std::unique_ptr<cc::LayerTreeFrameSink> layer_tree_frame_sink,
    std::unique_ptr<cc::RenderFrameMetadataObserver>
        render_frame_metadata_observer) {}

void LayerTreeView::WillBeginMainFrame() {}

void LayerTreeView::DidBeginMainFrame() {}

void LayerTreeView::WillUpdateLayers() {}

void LayerTreeView::DidUpdateLayers() {}

void LayerTreeView::BeginMainFrame(const viz::BeginFrameArgs& args) {}

void LayerTreeView::OnDeferMainFrameUpdatesChanged(bool status) {}

void LayerTreeView::OnCommitRequested() {}

void LayerTreeView::OnDeferCommitsChanged(
    bool status,
    cc::PaintHoldingReason reason,
    std::optional<cc::PaintHoldingCommitTrigger> trigger) {}

void LayerTreeView::BeginMainFrameNotExpectedSoon() {}

void LayerTreeView::BeginMainFrameNotExpectedUntil(base::TimeTicks time) {}

void LayerTreeView::UpdateLayerTreeHost() {}

void LayerTreeView::ApplyViewportChanges(
    const cc::ApplyViewportChangesArgs& args) {}

void LayerTreeView::UpdateCompositorScrollState(
    const cc::CompositorCommitData& commit_data) {}

void LayerTreeView::RequestNewLayerTreeFrameSink() {}

void LayerTreeView::DidInitializeLayerTreeFrameSink() {}

void LayerTreeView::DidFailToInitializeLayerTreeFrameSink() {}

void LayerTreeView::WillCommit(const cc::CommitState&) {}

void LayerTreeView::DidCommit(int source_frame_number,
                              base::TimeTicks commit_start_time,
                              base::TimeTicks commit_finish_time) {}

void LayerTreeView::DidCommitAndDrawFrame(int source_frame_number) {}

void LayerTreeView::DidCompletePageScaleAnimation(int source_frame_number) {}

void LayerTreeView::DidPresentCompositorFrame(
    uint32_t frame_token,
    const viz::FrameTimingDetails& frame_timing_details) {}

void LayerTreeView::RecordStartOfFrameMetrics() {}

void LayerTreeView::RecordEndOfFrameMetrics(
    base::TimeTicks frame_begin_time,
    cc::ActiveFrameSequenceTrackers trackers) {}

std::unique_ptr<cc::BeginMainFrameMetrics>
LayerTreeView::GetBeginMainFrameMetrics() {}

std::unique_ptr<cc::WebVitalMetrics> LayerTreeView::GetWebVitalMetrics() {}

void LayerTreeView::NotifyThroughputTrackerResults(
    cc::CustomTrackerResults results) {}

void LayerTreeView::DidObserveFirstScrollDelay(
    int source_frame_number,
    base::TimeDelta first_scroll_delay,
    base::TimeTicks first_scroll_timestamp) {}

void LayerTreeView::RunPaintBenchmark(int repeat_count,
                                      cc::PaintBenchmarkResult& result) {}

std::string LayerTreeView::GetPausedDebuggerLocalizedMessage() {}

void LayerTreeView::DidRunBeginMainFrame() {}

void LayerTreeView::DidSubmitCompositorFrame() {}

void LayerTreeView::DidLoseLayerTreeFrameSink() {}

void LayerTreeView::ScheduleAnimationForWebTests() {}

void LayerTreeView::AddPresentationCallback(
    uint32_t frame_token,
    base::OnceCallback<void(const viz::FrameTimingDetails&)> callback) {}

#if BUILDFLAG(IS_APPLE)
void LayerTreeView::AddCoreAnimationErrorCodeCallback(
    uint32_t frame_token,
    base::OnceCallback<void(gfx::CALayerResult)> callback) {
  AddCallback(frame_token, std::move(callback),
              core_animation_error_code_callbacks_);
}
#endif

template <typename Callback>
void LayerTreeView::AddCallback(
    uint32_t frame_token,
    Callback callback,
    base::circular_deque<std::pair<uint32_t, std::vector<Callback>>>&
        callbacks) {}

}  // namespace blink