Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ProxyCache.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_graphite_ProxyCache_DEFINED
9#define skgpu_graphite_ProxyCache_DEFINED
10
13#include "src/core/SkTHash.h"
15#include "src/gpu/ResourceKey.h"
16
17class SkBitmap;
18
19namespace skgpu {
20 enum class Mipmapped : bool;
21 class UniqueKey;
22}
23
24namespace skgpu::graphite {
25
26class Recorder;
27class TextureProxy;
28
29// This class encapsulates the _internal_ Recorder-local caching of utility proxies.
30// TODO:
31// Add purgeProxiesNotUsedSince method
32// Link into Context purging system
33// Add unit tests
35public:
36 ProxyCache(uint32_t recorderID);
38
40
41 void purgeAll();
42
43#if defined(GRAPHITE_TEST_UTILS)
44 int numCached() const;
46 void forceProcessInvalidKeyMsgs();
47 void forceFreeUniquelyHeld();
48 void forcePurgeProxiesNotUsedSince(skgpu::StdSteadyClock::time_point purgeTime);
49#endif
50
51private:
52 friend class ResourceCache; // for freeUniquelyHeld
53
54 void processInvalidKeyMsgs();
55 void freeUniquelyHeld();
56 void purgeProxiesNotUsedSince(const skgpu::StdSteadyClock::time_point* purgeTime);
57
59
60 InvalidKeyInbox fInvalidUniqueKeyInbox;
61
62 struct UniqueKeyHash {
63 uint32_t operator()(const skgpu::UniqueKey& key) const;
64 };
66 UniqueKeyProxyHash;
67
68 UniqueKeyProxyHash fCache;
69};
70
71} // namespace skgpu::graphite
72
73#endif // skgpu_graphite_ProxyCache_DEFINED
int find(T *array, int N, T item)
sk_sp< TextureProxy > findOrCreateCachedProxy(Recorder *, const SkBitmap &, Mipmapped)
Mipmapped
Definition GpuTypes.h:53