chromium/cc/tiles/tile_manager.cc

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

#include "cc/tiles/tile_manager.h"

#include <stddef.h>
#include <stdint.h>

#include <limits>
#include <optional>
#include <string>

#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_runner.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/traced_value.h"
#include "cc/base/devtools_instrumentation.h"
#include "cc/base/features.h"
#include "cc/base/histograms.h"
#include "cc/layers/picture_layer_impl.h"
#include "cc/paint/display_item_list.h"
#include "cc/raster/paint_worklet_image_provider.h"
#include "cc/raster/playback_image_provider.h"
#include "cc/raster/raster_buffer.h"
#include "cc/raster/task_category.h"
#include "cc/tiles/frame_viewer_instrumentation.h"
#include "cc/tiles/tile.h"
#include "cc/tiles/tile_priority.h"
#include "cc/tiles/tiles_with_resource_iterator.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "ui/gfx/geometry/axis_transform2d.h"
#include "ui/gfx/geometry/rect_conversions.h"

namespace cc {
namespace {

// Flag to indicate whether we should try and detect that
// a tile is of solid color.
const bool kUseColorEstimator =;

// This class is wrapper for both ImageProvider and PaintWorkletImageProvider,
// which is used in RasterSource::PlaybackSettings. It looks at the draw image
// and decides which one of the two providers to dispatch the request to.
class DispatchingImageProvider : public ImageProvider {};

class RasterTaskImpl : public TileTask {};

TaskCategory TaskCategoryForTileTask(TileTask* task,
                                     bool use_foreground_category) {}

bool IsForegroundCategory(uint16_t category) {}

// Task priorities that make sure that the task set done tasks run before any
// other remaining tasks.
const size_t kRequiredForActivationDoneTaskPriority =;
const size_t kRequiredForDrawDoneTaskPriority =;
const size_t kAllDoneTaskPriority =;

// For correctness, |kTileTaskPriorityBase| must be greater than
// all task set done task priorities.
size_t kTileTaskPriorityBase =;

void InsertNodeForTask(TaskGraph* graph,
                       TileTask* task,
                       uint16_t category,
                       uint16_t priority,
                       size_t dependencies) {}

void InsertNodeForDecodeTask(TaskGraph* graph,
                             TileTask* task,
                             bool use_foreground_category,
                             uint16_t priority) {}

void InsertNodesForRasterTask(TaskGraph* graph,
                              TileTask* raster_task,
                              const TileTask::Vector& decode_tasks,
                              size_t priority,
                              bool use_foreground_category) {}

class TaskSetFinishedTaskImpl : public TileTask {};

class DidFinishRunningAllTilesTask : public TileTask {};

gfx::ContentColorUsage GetContentColorUsageForPrioritizedTile(
    const PrioritizedTile& prioritized_tile) {}

}  // namespace

RasterTaskCompletionStats::RasterTaskCompletionStats()
    :{}

std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) {}

TileManager::TileManager(
    TileManagerClient* client,
    base::SequencedTaskRunner* origin_task_runner,
    scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner,
    size_t scheduled_raster_task_limit,
    bool running_on_renderer_process,
    const TileManagerSettings& tile_manager_settings)
    :{}

TileManager::~TileManager() {}

void TileManager::FinishTasksAndCleanUp() {}

void TileManager::ScheduleReduceTileMemoryWhenIdle(
    base::TimeDelta time_since_last_active) {}

// static
base::TimeDelta TileManager::GetTrimPrepaintTilesDelay() {}

void TileManager::ScheduleTrimPrepaintTiles() {}

void TileManager::ReduceTileMemoryWhenIdle() {}

void TileManager::TrimPrepaintTiles() {}

void TileManager::SetResources(ResourcePool* resource_pool,
                               ImageDecodeCache* image_decode_cache,
                               TaskGraphRunner* task_graph_runner,
                               RasterBufferProvider* raster_buffer_provider,
                               bool use_gpu_rasterization,
                               RasterQueryQueue* pending_raster_queries) {}

void TileManager::Release(Tile* tile) {}

void TileManager::DidFinishRunningTileTasksRequiredForActivation() {}

void TileManager::DidFinishRunningTileTasksRequiredForDraw() {}

void TileManager::DidFinishRunningAllTileTasks(bool has_pending_queries) {}

bool TileManager::PrepareTiles(
    const GlobalStateThatImpactsTilePriority& state) {}

void TileManager::PrepareToDraw() {}

void TileManager::DidModifyTilePriorities() {}

std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
TileManager::BasicStateAsValue() const {}

void TileManager::BasicStateAsValueInto(
    base::trace_event::TracedValue* state) const {}

std::unique_ptr<EvictionTilePriorityQueue>
TileManager::FreeTileResourcesUntilUsageIsWithinLimit(
    std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue,
    const MemoryUsage& limit,
    MemoryUsage* usage) {}

std::unique_ptr<EvictionTilePriorityQueue>
TileManager::FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit(
    std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue,
    const MemoryUsage& limit,
    const TilePriority& other_priority,
    MemoryUsage* usage) {}

bool TileManager::TilePriorityViolatesMemoryPolicy(
    const TilePriority& priority) {}

TileManager::PrioritizedWorkToSchedule TileManager::AssignGpuMemoryToTiles() {}

void TileManager::FreeResourcesForOccludedTiles() {}

void TileManager::FreeResourcesForTile(Tile* tile) {}

void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(
    Tile* tile) {}

void TileManager::PartitionImagesForCheckering(
    const PrioritizedTile& prioritized_tile,
    const TargetColorParams& target_color_params,
    std::vector<DrawImage>* sync_decoded_images,
    std::vector<PaintImage>* checkered_images,
    const gfx::Rect* invalidated_rect,
    base::flat_map<PaintImage::Id, size_t>* image_to_frame_index) {}

void TileManager::AddCheckeredImagesToDecodeQueue(
    const PrioritizedTile& prioritized_tile,
    const TargetColorParams& target_color_params,
    CheckerImageTracker::DecodeType decode_type,
    CheckerImageTracker::ImageDecodeQueue* image_decode_queue) {}

void TileManager::ScheduleTasks(PrioritizedWorkToSchedule work_to_schedule) {}

scoped_refptr<TileTask> TileManager::CreateRasterTask(
    const PrioritizedTile& prioritized_tile,
    const TargetColorParams& target_color_params,
    PrioritizedWorkToSchedule* work_to_schedule) {}

void TileManager::ResetSignalsForTesting() {}

void TileManager::OnRasterTaskCompleted(
    Tile::Id tile_id,
    ResourcePool::InUsePoolResource resource,
    bool was_canceled) {}

std::unique_ptr<Tile> TileManager::CreateTile(const Tile::CreateInfo& info,
                                              int layer_id,
                                              int source_frame_number,
                                              int flags) {}

bool TileManager::AreRequiredTilesReadyToDraw(
    RasterTilePriorityQueue::Type type) const {}

bool TileManager::IsReadyToActivate() const {}

bool TileManager::IsReadyToDraw() const {}

void TileManager::ScheduleCheckRasterFinishedQueries() {}

void TileManager::CheckRasterFinishedQueries() {}

void TileManager::CheckForCompletedTasksAndIssueSignals() {}

void TileManager::IssueSignals() {}

void TileManager::CheckIfMoreTilesNeedToBePrepared() {}

void TileManager::MarkTilesOutOfMemory(
    std::unique_ptr<RasterTilePriorityQueue> queue) const {}

const PaintImageIdFlatSet& TileManager::TakeImagesToInvalidateOnSyncTree() {}

void TileManager::DidActivateSyncTree() {}

void TileManager::ClearCheckerImageTracking(
    bool can_clear_decode_policy_tracking) {}

void TileManager::SetCheckerImagingForceDisabled(bool force_disable) {}

void TileManager::NeedsInvalidationForCheckerImagedTiles() {}

viz::SharedImageFormat TileManager::DetermineFormat(const Tile* tile) const {}

std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
TileManager::ScheduledTasksStateAsValue() const {}

bool TileManager::UsePartialRaster(int msaa_sample_count) const {}

void TileManager::CheckPendingGpuWorkAndIssueSignals() {}

// Utility function that can be used to create a "Task set finished" task that
// posts |callback| to |task_runner| when run.
scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask(
    void (TileManager::*callback)()) {}

std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
TileManager::ActivationStateAsValue() {}

void TileManager::ActivationStateAsValueInto(
    base::trace_event::TracedValue* state) const {}

void TileManager::SetOverridesForTesting(
    scoped_refptr<base::TaskRunner> task_runner_for_testing,
    const base::TickClock* clock) {}

bool TileManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
                               base::trace_event::ProcessMemoryDump* pmd) {}

bool TileManager::ShouldRasterOccludedTiles() const {}

base::TimeTicks TileManager::NowWithOverride() const {}

base::TaskRunner* TileManager::TaskRunnerWithOverride() const {}

TileManager::MemoryUsage::MemoryUsage()
    :{}

TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes,
                                      size_t resource_count)
    :{}

// static
TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig(
    const gfx::Size& size,
    viz::SharedImageFormat format) {}

// static
TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) {}

TileManager::MemoryUsage& TileManager::MemoryUsage::operator+=(
    const MemoryUsage& other) {}

TileManager::MemoryUsage& TileManager::MemoryUsage::operator-=(
    const MemoryUsage& other) {}

TileManager::MemoryUsage TileManager::MemoryUsage::operator-(
    const MemoryUsage& other) {}

bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {}

TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default;
TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule(
    PrioritizedWorkToSchedule&& other) = default;
TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default;

}  // namespace cc