#include "cc/tiles/software_image_decode_cache.h"
#include <stdint.h>
#include <algorithm>
#include <string>
#include <utility>
#include "base/debug/stack_trace.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/numerics/ostream_operators.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_manager.h"
#include "cc/base/devtools_instrumentation.h"
#include "cc/base/features.h"
#include "cc/base/histograms.h"
#include "cc/raster/tile_task.h"
#include "cc/tiles/mipmap_util.h"
#include "components/miracle_parameter/common/public/miracle_parameter.h"
#include "ui/gfx/geometry/skia_conversions.h"
MemoryAllocatorDump;
MemoryDumpLevelOfDetail;
namespace cc {
namespace {
BASE_FEATURE(…);
MIRACLE_PARAMETER_FOR_INT(GetNormalMaxItemsInCacheForSoftware,
kNormalMaxItemsInCacheForSoftwareFeature,
"NormalMaxItemsInCacheForSoftware",
1000)
class AutoRemoveKeyFromTaskMap { … };
class SoftwareImageDecodeTaskImpl : public TileTask { … };
SkSize GetScaleAdjustment(const SoftwareImageDecodeCache::CacheKey& key) { … }
PaintFlags::FilterQuality GetDecodedFilterQuality(
const SoftwareImageDecodeCache::CacheKey& key) { … }
}
SoftwareImageDecodeCache::SoftwareImageDecodeCache(
SkColorType color_type,
size_t locked_memory_limit_bytes)
: … { … }
SoftwareImageDecodeCache::~SoftwareImageDecodeCache() { … }
ImageDecodeCache::TaskResult SoftwareImageDecodeCache::GetTaskForImageAndRef(
ClientId client_id,
const DrawImage& image,
const TracingInfo& tracing_info) { … }
ImageDecodeCache::TaskResult
SoftwareImageDecodeCache::GetOutOfRasterDecodeTaskForImageAndRef(
ClientId client_id,
const DrawImage& image) { … }
ImageDecodeCache::TaskResult
SoftwareImageDecodeCache::GetTaskForImageAndRefInternal(
const DrawImage& image,
const TracingInfo& tracing_info,
DecodeTaskType task_type) { … }
void SoftwareImageDecodeCache::AddBudgetForImage(const CacheKey& key,
CacheEntry* entry) { … }
void SoftwareImageDecodeCache::RemoveBudgetForImage(const CacheKey& key,
CacheEntry* entry) { … }
void SoftwareImageDecodeCache::UnrefImage(const DrawImage& image) { … }
void SoftwareImageDecodeCache::UnrefImage(const CacheKey& key) { … }
SoftwareImageDecodeCache::TaskProcessingResult
SoftwareImageDecodeCache::DecodeImageInTask(const CacheKey& key,
const PaintImage& paint_image,
DecodeTaskType task_type) { … }
SoftwareImageDecodeCache::TaskProcessingResult
SoftwareImageDecodeCache::DecodeImageIfNecessary(const CacheKey& key,
const PaintImage& paint_image,
CacheEntry* entry) { … }
std::optional<SoftwareImageDecodeCache::CacheKey>
SoftwareImageDecodeCache::FindCachedCandidate(const CacheKey& key) { … }
bool SoftwareImageDecodeCache::UseCacheForDrawImage(
const DrawImage& draw_image) const { … }
ImageDecodeCache::ClientId SoftwareImageDecodeCache::GenerateClientId() { … }
DecodedDrawImage SoftwareImageDecodeCache::GetDecodedImageForDraw(
const DrawImage& draw_image) { … }
DecodedDrawImage SoftwareImageDecodeCache::GetDecodedImageForDrawInternal(
const CacheKey& key,
const PaintImage& paint_image) { … }
void SoftwareImageDecodeCache::DrawWithImageFinished(
const DrawImage& image,
const DecodedDrawImage& decoded_image) { … }
void SoftwareImageDecodeCache::ReduceCacheUsageUntilWithinLimit(size_t limit) { … }
void SoftwareImageDecodeCache::ReduceCacheUsage() { … }
void SoftwareImageDecodeCache::ClearCache() { … }
size_t SoftwareImageDecodeCache::GetMaximumMemoryLimitBytes() const { … }
void SoftwareImageDecodeCache::OnImageDecodeTaskCompleted(
const CacheKey& key,
DecodeTaskType task_type) { … }
bool SoftwareImageDecodeCache::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { … }
SoftwareImageDecodeCache::CacheEntry* SoftwareImageDecodeCache::AddCacheEntry(
const CacheKey& key) { … }
size_t SoftwareImageDecodeCache::GetNumCacheEntriesForTesting() { … }
size_t SoftwareImageDecodeCache::GetMaxNumCacheEntriesForTesting() { … }
SkColorType SoftwareImageDecodeCache::GetColorTypeForPaintImage(
const TargetColorParams& target_color_params,
const PaintImage& paint_image) { … }
SoftwareImageDecodeCache::MemoryBudget::MemoryBudget(size_t limit_bytes)
: … { … }
size_t SoftwareImageDecodeCache::MemoryBudget::AvailableMemoryBytes() const { … }
void SoftwareImageDecodeCache::MemoryBudget::AddUsage(size_t usage) { … }
void SoftwareImageDecodeCache::MemoryBudget::SubtractUsage(size_t usage) { … }
void SoftwareImageDecodeCache::MemoryBudget::ResetUsage() { … }
size_t SoftwareImageDecodeCache::MemoryBudget::GetCurrentUsageSafe() const { … }
}