Flutter Engine
The Flutter Engine
SmallPathAtlasMgr.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
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 SmallPathAtlasMgr_DEFINED
9#define SmallPathAtlasMgr_DEFINED
10
11#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
12
17
18class GrStyledShape;
19
20namespace skgpu::ganesh {
21
22class SmallPathShapeData;
23class SmallPathShapeDataKey;
24
25/**
26 * This class manages the small path renderer's atlas. It solely operates at flush time. Thus
27 * the small path renderer will generate ops at record time but the location of the ops' source
28 * data and even the number of proxies to be used will not be determined until the recorded
29 * DAGs/DDLs are (re)played.
30 *
31 * TODO: investigate fusing this class and the GrAtlasManager.
32 */
36public:
38 ~SmallPathAtlasMgr() override;
39
40 void reset();
41
42 bool initAtlas(GrProxyProvider*, const GrCaps*);
43
44 SmallPathShapeData* findOrCreate(const GrStyledShape&, int desiredDimension);
46
49 int width, int height, const void* image,
51
53
54 // GrOnFlushCallbackObject overrides
55 bool preFlush(GrOnFlushResourceProvider* onFlushRP) override {
56#if defined(GR_TEST_UTILS)
57 if (onFlushRP->failFlushTimeCallbacks()) {
58 return false;
59 }
60#endif
61
62 if (fAtlas) {
63 fAtlas->instantiate(onFlushRP);
64 }
65 return true;
66 }
67
68 void postFlush(skgpu::AtlasToken startTokenForNextFlush) override {
69 if (fAtlas) {
70 fAtlas->compact(startTokenForNextFlush);
71 }
72 }
73
74 // This object has the same lifetime as the GrContext so we want it to survive freeGpuResources
75 // calls
76 bool retainOnFreeGpuResources() override { return true; }
77
78 const GrSurfaceProxyView* getViews(int* numActiveProxies) {
79 *numActiveProxies = fAtlas->numActivePages();
80 return fAtlas->getViews();
81 }
82
84
85private:
87
88 void evict(skgpu::PlotLocator) override;
89
91 typedef SkTInternalLList<SmallPathShapeData> ShapeDataList;
92
93 std::unique_ptr<GrDrawOpAtlas> fAtlas;
94 ShapeCache fShapeCache;
95 ShapeDataList fShapeList;
96};
97
98} // namespace skgpu::ganesh
99
100#endif // SK_ENABLE_OPTIMIZE_SIZE
101
102#endif // SmallPathAtlasMgr_DEFINED
Definition: GrCaps.h:57
void deleteCacheEntry(SmallPathShapeData *)
bool initAtlas(GrProxyProvider *, const GrCaps *)
void postFlush(skgpu::AtlasToken startTokenForNextFlush) override
bool preFlush(GrOnFlushResourceProvider *onFlushRP) override
GrDrawOpAtlas::ErrorCode addToAtlas(GrResourceProvider *, GrDeferredUploadTarget *, int width, int height, const void *image, skgpu::AtlasLocator *)
void setUseToken(SmallPathShapeData *, skgpu::AtlasToken)
SmallPathShapeData * findOrCreate(const GrStyledShape &, int desiredDimension)
const GrSurfaceProxyView * getViews(int *numActiveProxies)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
int32_t height
int32_t width