Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
skgpu::graphite::ProxyCache Class Reference

#include <ProxyCache.h>

Public Member Functions

 ProxyCache (uint32_t recorderID)
 
 ~ProxyCache ()
 
sk_sp< TextureProxyfindOrCreateCachedProxy (Recorder *, const SkBitmap &, Mipmapped)
 
void purgeAll ()
 

Friends

class ResourceCache
 

Detailed Description

Definition at line 34 of file ProxyCache.h.

Constructor & Destructor Documentation

◆ ProxyCache()

skgpu::graphite::ProxyCache::ProxyCache ( uint32_t  recorderID)

Definition at line 65 of file ProxyCache.cpp.

65 : fInvalidUniqueKeyInbox(recorderID) {
66 SkASSERT(recorderID != SK_InvalidGenID);
67}
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr uint32_t SK_InvalidGenID
Definition SkTypes.h:192

◆ ~ProxyCache()

skgpu::graphite::ProxyCache::~ProxyCache ( )

Definition at line 69 of file ProxyCache.cpp.

69{}

Member Function Documentation

◆ findOrCreateCachedProxy()

sk_sp< TextureProxy > skgpu::graphite::ProxyCache::findOrCreateCachedProxy ( Recorder recorder,
const SkBitmap bitmap,
Mipmapped  mipmapped 
)

Definition at line 75 of file ProxyCache.cpp.

77 {
78 this->processInvalidKeyMsgs();
79
80 if (bitmap.dimensions().area() <= 1) {
81 mipmapped = skgpu::Mipmapped::kNo;
82 }
83
85
86 if (mipmapped == Mipmapped::kNo) {
87 make_bitmap_key(&key, bitmap, Mipmapped::kYes);
88
89 if (sk_sp<TextureProxy>* cached = fCache.find(key)) {
90 if (Resource* resource = (*cached)->texture(); resource) {
91 resource->updateAccessTime();
92 }
93 return *cached;
94 }
95 }
96
97 make_bitmap_key(&key, bitmap, mipmapped);
98
99 if (sk_sp<TextureProxy>* cached = fCache.find(key)) {
100 if (Resource* resource = (*cached)->texture(); resource) {
101 resource->updateAccessTime();
102 }
103 return *cached;
104 }
105
106 auto [ view, ct ] = MakeBitmapProxyView(recorder, bitmap, nullptr,
107 mipmapped, skgpu::Budgeted::kYes);
108 if (view) {
109 auto listener = make_unique_key_invalidation_listener(key, recorder->priv().uniqueID());
110 bitmap.pixelRef()->addGenIDChangeListener(std::move(listener));
111
112 fCache.set(key, view.refProxy());
113 }
114 return view.refProxy();
115}
V * find(const K &key) const
Definition SkTHash.h:479
V * set(K key, V val)
Definition SkTHash.h:472
std::tuple< TextureProxyView, SkColorType > MakeBitmapProxyView(Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted)

◆ purgeAll()

void skgpu::graphite::ProxyCache::purgeAll ( )

Definition at line 117 of file ProxyCache.cpp.

117 {
118 fCache.reset();
119}

Friends And Related Symbol Documentation

◆ ResourceCache

friend class ResourceCache
friend

Definition at line 52 of file ProxyCache.h.


The documentation for this class was generated from the following files: