43 uint32_t recorderID) {
47 : fMsg(
key, recorderUniqueID) {}
57 return sk_make_sp<Listener>(
key, recorderID);
70uint32_t ProxyCache::UniqueKeyHash::operator()(
const UniqueKey&
key)
const {
76 std::string_view label) {
82 [](
const void* context) {
return *
static_cast<const SkBitmap*
>(context); },
90 std::string_view label) {
91 this->processInvalidKeyMsgs();
110 const bool addListener = !
bitmap.pixelRef()->unique();
112 auto listener = make_unique_key_invalidation_listener(
key, recorder->
priv().
uniqueID());
113 bitmap.pixelRef()->addGenIDChangeListener(std::move(listener));
115 fCache.set(
key, view.refProxy());
117 return view.refProxy();
124void ProxyCache::processInvalidKeyMsgs() {
126 fInvalidUniqueKeyInbox.poll(&invalidKeyMsgs);
128 if (!invalidKeyMsgs.
empty()) {
129 for (
int i = 0;
i < invalidKeyMsgs.
size(); ++
i) {
133 if (fCache.find(invalidKeyMsgs[
i].key())) {
134 fCache.remove(invalidKeyMsgs[
i].
key());
140void ProxyCache::freeUniquelyHeld() {
141 this->processInvalidKeyMsgs();
143 std::vector<skgpu::UniqueKey> toRemove;
146 if ((*proxy)->unique()) {
147 toRemove.push_back(key);
156void ProxyCache::purgeProxiesNotUsedSince(
const skgpu::StdSteadyClock::time_point* purgeTime) {
157 this->processInvalidKeyMsgs();
159 std::vector<skgpu::UniqueKey> toRemove;
162 if (Resource*
resource = (*proxy)->texture();
164 (!purgeTime ||
resource->lastAccessTime() < *purgeTime)) {
165 resource->setDeleteASAP();
166 toRemove.push_back(key);
175#if defined(GRAPHITE_TEST_UTILS)
176int ProxyCache::numCached()
const {
177 return fCache.count();
193void ProxyCache::forceProcessInvalidKeyMsgs() {
194 this->processInvalidKeyMsgs();
197void ProxyCache::forceFreeUniquelyHeld() {
198 this->freeUniquelyHeld();
201void ProxyCache::forcePurgeProxiesNotUsedSince(skgpu::StdSteadyClock::time_point purgeTime) {
202 this->purgeProxiesNotUsedSince(&purgeTime);
DECLARE_SKMESSAGEBUS_MESSAGE(skgpu::UniqueKeyInvalidatedMsg_Graphite, uint32_t, true) namespace
static SkString resource(SkPDFResourceType type, int index)
static constexpr uint32_t SK_InvalidGenID
int find(T *array, int N, T item)
SkIPoint pixelRefOrigin() const
SkPixelRef * pixelRef() const
SkISize dimensions() const
static void Post(Message m)
uint32_t getGenerationID() const
static Domain GenerateDomain()
SkBitmap(*)(BitmapGeneratorContext) BitmapGeneratorFn
sk_sp< TextureProxy > findOrCreateCachedProxy(Recorder *, const SkBitmap &, std::string_view label)
ProxyCache(uint32_t recorderID)
const void * BitmapGeneratorContext
uint32_t uniqueID() const
std::tuple< TextureProxyView, SkColorType > MakeBitmapProxyView(Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted, std::string_view label)
int32_t fBottom
larger y-axis bounds
int32_t fTop
smaller y-axis bounds
int32_t fLeft
smaller x-axis bounds
static constexpr SkIRect MakePtSize(SkIPoint pt, SkISize size)
int32_t fRight
larger x-axis bounds