5#ifndef FLUTTER_COMMON_GRAPHICS_PERSISTENT_CACHE_H_
6#define FLUTTER_COMMON_GRAPHICS_PERSISTENT_CACHE_H_
12#include "flutter/assets/asset_manager.h"
13#include "flutter/fml/macros.h"
14#include "flutter/fml/task_runner.h"
15#include "flutter/fml/unique_fd.h"
123 return asset_manager_;
136 static std::string cache_base_path_;
138 static std::shared_ptr<AssetManager> asset_manager_;
140 static std::mutex instance_mutex_;
141 static std::unique_ptr<PersistentCache> gPersistentCache;
147 static std::atomic<bool> cache_sksl_;
151 static std::atomic<bool> strategy_set_;
153 const bool is_read_only_;
154 const std::shared_ptr<fml::UniqueFD> cache_directory_;
155 const std::shared_ptr<fml::UniqueFD> sksl_cache_directory_;
156 mutable std::mutex worker_task_runners_mutex_;
157 std::multiset<fml::RefPtr<fml::TaskRunner>> worker_task_runners_;
159 bool stored_new_shaders_ =
false;
160 bool is_dumping_skp_ =
false;
163 const std::string& file_name,
166 bool IsValid()
const;
PersistentCache()=default
static constexpr char kSkSLSubdirName[]
static void MarkStrategySet()
bool StoredNewShaders() const
static std::shared_ptr< AssetManager > asset_manager()
void ResetStoredNewShaders()
static void SetAssetManager(std::shared_ptr< AssetManager > value)
void RemoveWorkerTaskRunner(const fml::RefPtr< fml::TaskRunner > &task_runner)
std::vector< std::unique_ptr< fml::Mapping > > GetSkpsFromAssetManager() const
static void SetCacheDirectoryPath(std::string path)
sk_sp< SkData > load(const SkData &key) override
static PersistentCache * GetCacheForProcess()
void DumpSkp(const SkData &data)
static constexpr char kAssetFileName[]
static void SetCacheSkSL(bool value)
static void ResetCacheForProcess()
void SetIsDumpingSkp(bool value)
void AddWorkerTaskRunner(const fml::RefPtr< fml::TaskRunner > &task_runner)
std::vector< SkSLCache > LoadSkSLs() const
Load all the SkSL shader caches in the right directory.
void store(const SkData &key, const SkData &data) override
size_t PrecompileKnownSkSLs(GrDirectContext *context) const
Precompile SkSLs packaged with the application and gathered during previous runs in the given context...
~PersistentCache() override
static std::string SkKeyToFilePath(const SkData &key)
static std::unique_ptr< fml::MallocMapping > BuildCacheObject(const SkData &key, const SkData &data)
bool IsDumpingSkp() const
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir