#include "cc/tiles/software_image_decode_cache_utils.h"
#include <algorithm>
#include <sstream>
#include <utility>
#include "base/atomic_sequence_num.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/hash.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/metrics/histogram_macros.h"
#include "base/process/memory.h"
#include "base/trace_event/trace_event.h"
#include "cc/paint/paint_flags.h"
#include "cc/tiles/mipmap_util.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/gfx/geometry/skia_conversions.h"
namespace cc {
namespace {
const size_t kMemoryThresholdToSubrect = …;
const int kMinDimensionToSubrect = …;
const float kMemoryRatioToSubrect = …;
base::AtomicSequenceNumber g_next_tracing_id_;
gfx::Rect GetSrcRect(const DrawImage& image) { … }
std::unique_ptr<base::DiscardableMemory> AllocateDiscardable(
const SkImageInfo& info,
base::OnceClosure on_no_memory) { … }
}
std::unique_ptr<SoftwareImageDecodeCacheUtils::CacheEntry>
SoftwareImageDecodeCacheUtils::DoDecodeImage(
const CacheKey& key,
const PaintImage& paint_image,
SkColorType color_type,
PaintImage::GeneratorClientId client_id,
base::OnceClosure on_no_memory) { … }
std::unique_ptr<SoftwareImageDecodeCacheUtils::CacheEntry>
SoftwareImageDecodeCacheUtils::GenerateCacheEntryFromCandidate(
const CacheKey& key,
const DecodedDrawImage& candidate_image,
bool needs_extract_subset,
SkColorType color_type) { … }
SoftwareImageDecodeCacheUtils::CacheKey
SoftwareImageDecodeCacheUtils::CacheKey::FromDrawImage(const DrawImage& image,
SkColorType color_type) { … }
SoftwareImageDecodeCacheUtils::CacheKey::CacheKey(
PaintImage::FrameKey frame_key,
PaintImage::Id stable_id,
ProcessingType type,
bool is_nearest_neighbor,
bool may_be_lcp_candidate,
const gfx::Rect& src_rect,
const gfx::Size& target_size,
const TargetColorParams& target_color_params)
: … { … }
SoftwareImageDecodeCacheUtils::CacheKey::CacheKey(const CacheKey& other) =
default;
SoftwareImageDecodeCacheUtils::CacheKey&
SoftwareImageDecodeCacheUtils::CacheKey::operator=(const CacheKey& other) =
default;
std::string SoftwareImageDecodeCacheUtils::CacheKey::ToString() const { … }
SoftwareImageDecodeCacheUtils::CacheEntry::CacheEntry()
: … { … }
SoftwareImageDecodeCacheUtils::CacheEntry::CacheEntry(
const SkImageInfo& info,
std::unique_ptr<base::DiscardableMemory> in_memory,
const SkSize& src_rect_offset)
: … { … }
SoftwareImageDecodeCacheUtils::CacheEntry::~CacheEntry() { … }
void SoftwareImageDecodeCacheUtils::CacheEntry::MoveImageMemoryTo(
CacheEntry* entry) { … }
bool SoftwareImageDecodeCacheUtils::CacheEntry::Lock() { … }
void SoftwareImageDecodeCacheUtils::CacheEntry::Unlock() { … }
}