36 builder[1] = subset.
fLeft;
37 builder[2] = subset.
fTop;
38 builder[3] = subset.
fRight;
44 uint32_t recorderID) {
48 : fMsg(
key, recorderUniqueID) {}
58 return sk_make_sp<Listener>(
key, recorderID);
78 this->processInvalidKeyMsgs();
80 if (
bitmap.dimensions().area() <= 1) {
81 mipmapped = skgpu::Mipmapped::kNo;
86 if (mipmapped == Mipmapped::kNo) {
87 make_bitmap_key(&
key,
bitmap, Mipmapped::kYes);
90 if (
Resource* resource = (*cached)->texture(); resource) {
91 resource->updateAccessTime();
100 if (
Resource* resource = (*cached)->texture(); resource) {
101 resource->updateAccessTime();
109 auto listener = make_unique_key_invalidation_listener(
key, recorder->
priv().
uniqueID());
110 bitmap.pixelRef()->addGenIDChangeListener(std::move(listener));
112 fCache.
set(
key, view.refProxy());
114 return view.refProxy();
121void ProxyCache::processInvalidKeyMsgs() {
123 fInvalidUniqueKeyInbox.poll(&invalidKeyMsgs);
125 if (!invalidKeyMsgs.
empty()) {
126 for (
int i = 0; i < invalidKeyMsgs.
size(); ++i) {
130 if (fCache.
find(invalidKeyMsgs[i].key())) {
137void ProxyCache::freeUniquelyHeld() {
138 this->processInvalidKeyMsgs();
140 std::vector<skgpu::UniqueKey> toRemove;
143 if ((*proxy)->unique()) {
144 toRemove.push_back(key);
153void ProxyCache::purgeProxiesNotUsedSince(
const skgpu::StdSteadyClock::time_point* purgeTime) {
154 this->processInvalidKeyMsgs();
156 std::vector<skgpu::UniqueKey> toRemove;
159 if (Resource* resource = (*proxy)->texture();
161 (!purgeTime || resource->lastAccessTime() < *purgeTime)) {
162 resource->setDeleteASAP();
163 toRemove.push_back(
key);
172#if defined(GRAPHITE_TEST_UTILS)
173int ProxyCache::numCached()
const {
174 return fCache.
count();
181 make_bitmap_key(&
key,
bitmap, mipmapped);
190void ProxyCache::forceProcessInvalidKeyMsgs() {
191 this->processInvalidKeyMsgs();
194void ProxyCache::forceFreeUniquelyHeld() {
195 this->freeUniquelyHeld();
198void ProxyCache::forcePurgeProxiesNotUsedSince(skgpu::StdSteadyClock::time_point purgeTime) {
199 this->purgeProxiesNotUsedSince(&purgeTime);
#define DECLARE_SKMESSAGEBUS_MESSAGE(Message, IDType, AllowCopyableMessage)
static constexpr bool SkToBool(const T &x)
static constexpr uint32_t SK_InvalidGenID
SkIPoint pixelRefOrigin() const
SkPixelRef * pixelRef() const
SkISize dimensions() const
static void Post(Message m)
uint32_t getGenerationID() const
static Domain GenerateDomain()
ProxyCache(uint32_t recorderID)
sk_sp< TextureProxy > findOrCreateCachedProxy(Recorder *, const SkBitmap &, Mipmapped)
uint32_t uniqueID() const
V * find(const K &key) const
void remove(const K &key)
std::tuple< TextureProxyView, SkColorType > MakeBitmapProxyView(Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted)
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