#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/command_buffer/service/gr_shader_cache.h"
#include <inttypes.h>
#include "base/auto_reset.h"
#include "base/base64.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "gpu/config/gpu_finch_features.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
namespace gpu {
namespace raster {
namespace {
std::string MakeString(const SkData* data) { … }
sk_sp<SkData> MakeData(const std::string& str) { … }
}
GrShaderCache::GrShaderCache(size_t max_cache_size_bytes, Client* client)
: … { … }
GrShaderCache::~GrShaderCache() { … }
sk_sp<SkData> GrShaderCache::load(const SkData& key) { … }
void GrShaderCache::store(const SkData& key, const SkData& data) { … }
void GrShaderCache::PopulateCache(const std::string& key,
const std::string& data) { … }
GrShaderCache::Store::iterator GrShaderCache::AddToCache(CacheKey key,
CacheData data) { … }
template <typename Iterator>
void GrShaderCache::EraseFromCache(Iterator it) { … }
void GrShaderCache::CacheClientIdOnDisk(int32_t client_id) { … }
void GrShaderCache::PurgeMemory(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { … }
bool GrShaderCache::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { … }
size_t GrShaderCache::num_cache_entries() const { … }
size_t GrShaderCache::curr_size_bytes_for_testing() const { … }
void GrShaderCache::WriteToDisk(const CacheKey& key, CacheData* data) { … }
void GrShaderCache::EnforceLimits(size_t size_needed) { … }
void GrShaderCache::StoreVkPipelineCacheIfNeeded(GrDirectContext* gr_context) { … }
int32_t GrShaderCache::current_client_id() const { … }
GrShaderCache::ScopedCacheUse::ScopedCacheUse(GrShaderCache* cache,
int32_t client_id)
: … { … }
GrShaderCache::ScopedCacheUse::~ScopedCacheUse() { … }
GrShaderCache::CacheKey::CacheKey(sk_sp<SkData> data) : … { … }
GrShaderCache::CacheKey::CacheKey(const CacheKey& other) = default;
GrShaderCache::CacheKey::CacheKey(CacheKey&& other) = default;
GrShaderCache::CacheKey& GrShaderCache::CacheKey::operator=(
const CacheKey& other) = default;
GrShaderCache::CacheKey& GrShaderCache::CacheKey::operator=(CacheKey&& other) =
default;
GrShaderCache::CacheKey::~CacheKey() = default;
bool GrShaderCache::CacheKey::operator==(const CacheKey& other) const { … }
GrShaderCache::CacheData::CacheData(sk_sp<SkData> data)
: … { … }
GrShaderCache::CacheData::CacheData(CacheData&& other) = default;
GrShaderCache::CacheData& GrShaderCache::CacheData::operator=(
CacheData&& other) = default;
GrShaderCache::CacheData::~CacheData() = default;
bool GrShaderCache::CacheData::operator==(const CacheData& other) const { … }
}
}