Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skgpu::ganesh::SmallPathAtlasMgr Class Referencefinal

#include <SmallPathAtlasMgr.h>

Inheritance diagram for skgpu::ganesh::SmallPathAtlasMgr:
GrOnFlushCallbackObject skgpu::PlotEvictionCallback skgpu::AtlasGenerationCounter

Public Member Functions

 SmallPathAtlasMgr ()
 
 ~SmallPathAtlasMgr () override
 
void reset ()
 
bool initAtlas (GrProxyProvider *, const GrCaps *)
 
SmallPathShapeDatafindOrCreate (const GrStyledShape &, int desiredDimension)
 
SmallPathShapeDatafindOrCreate (const GrStyledShape &, const SkMatrix &ctm)
 
GrDrawOpAtlas::ErrorCode addToAtlas (GrResourceProvider *, GrDeferredUploadTarget *, int width, int height, const void *image, skgpu::AtlasLocator *)
 
void setUseToken (SmallPathShapeData *, skgpu::AtlasToken)
 
bool preFlush (GrOnFlushResourceProvider *onFlushRP) override
 
void postFlush (skgpu::AtlasToken startTokenForNextFlush) override
 
bool retainOnFreeGpuResources () override
 
const GrSurfaceProxyViewgetViews (int *numActiveProxies)
 
void deleteCacheEntry (SmallPathShapeData *)
 
- Public Member Functions inherited from GrOnFlushCallbackObject
virtual ~GrOnFlushCallbackObject ()
 
virtual bool preFlush (GrOnFlushResourceProvider *)=0
 
virtual void postFlush (skgpu::AtlasToken startTokenForNextFlush)
 
virtual bool retainOnFreeGpuResources ()
 
- Public Member Functions inherited from skgpu::PlotEvictionCallback
virtual ~PlotEvictionCallback ()=default
 
virtual void evict (PlotLocator)=0
 
- Public Member Functions inherited from skgpu::AtlasGenerationCounter
uint64_t next ()
 

Additional Inherited Members

- Static Public Attributes inherited from skgpu::AtlasGenerationCounter
static constexpr uint64_t kInvalidGeneration = 0
 

Detailed Description

This class manages the small path renderer's atlas. It solely operates at flush time. Thus the small path renderer will generate ops at record time but the location of the ops' source data and even the number of proxies to be used will not be determined until the recorded DAGs/DDLs are (re)played.

TODO: investigate fusing this class and the GrAtlasManager.

Definition at line 33 of file SmallPathAtlasMgr.h.

Constructor & Destructor Documentation

◆ SmallPathAtlasMgr()

skgpu::ganesh::SmallPathAtlasMgr::SmallPathAtlasMgr ( )

Definition at line 25 of file SmallPathAtlasMgr.cpp.

25{}

◆ ~SmallPathAtlasMgr()

skgpu::ganesh::SmallPathAtlasMgr::~SmallPathAtlasMgr ( )
override

Definition at line 27 of file SmallPathAtlasMgr.cpp.

27 {
28 this->reset();
29}

Member Function Documentation

◆ addToAtlas()

GrDrawOpAtlas::ErrorCode skgpu::ganesh::SmallPathAtlasMgr::addToAtlas ( GrResourceProvider resourceProvider,
GrDeferredUploadTarget target,
int  width,
int  height,
const void *  image,
skgpu::AtlasLocator locator 
)

Definition at line 116 of file SmallPathAtlasMgr.cpp.

119 {
120 return fAtlas->addToAtlas(resourceProvider, target, width, height, image, locator);
121}
uint32_t * target
sk_sp< const SkImage > image
Definition: SkRecords.h:269
int32_t height
int32_t width

◆ deleteCacheEntry()

void skgpu::ganesh::SmallPathAtlasMgr::deleteCacheEntry ( SmallPathShapeData shapeData)

Definition at line 77 of file SmallPathAtlasMgr.cpp.

77 {
78 fShapeCache.remove(shapeData->fKey);
79 fShapeList.remove(shapeData);
80 delete shapeData;
81}
void remove(const Key &key)
void remove(T *entry)

◆ findOrCreate() [1/2]

SmallPathShapeData * skgpu::ganesh::SmallPathAtlasMgr::findOrCreate ( const GrStyledShape shape,
const SkMatrix ctm 
)

Definition at line 108 of file SmallPathAtlasMgr.cpp.

109 {
110 SmallPathShapeDataKey key(shape, ctm);
111
112 // TODO: move the key into 'findOrCreate'
113 return this->findOrCreate(key);
114}
SmallPathShapeData * findOrCreate(const GrStyledShape &, int desiredDimension)

◆ findOrCreate() [2/2]

SmallPathShapeData * skgpu::ganesh::SmallPathAtlasMgr::findOrCreate ( const GrStyledShape shape,
int  desiredDimension 
)

Definition at line 100 of file SmallPathAtlasMgr.cpp.

101 {
102 SmallPathShapeDataKey key(shape, desiredDimension);
103
104 // TODO: move the key into 'findOrCreate'
105 return this->findOrCreate(key);
106}

◆ getViews()

const GrSurfaceProxyView * skgpu::ganesh::SmallPathAtlasMgr::getViews ( int numActiveProxies)
inline

Definition at line 78 of file SmallPathAtlasMgr.h.

78 {
79 *numActiveProxies = fAtlas->numActivePages();
80 return fAtlas->getViews();
81 }

◆ initAtlas()

bool skgpu::ganesh::SmallPathAtlasMgr::initAtlas ( GrProxyProvider proxyProvider,
const GrCaps caps 
)

Definition at line 50 of file SmallPathAtlasMgr.cpp.

50 {
51 if (fAtlas) {
52 return true;
53 }
54
55 static constexpr size_t kMaxAtlasTextureBytes = 2048 * 2048;
56 static constexpr size_t kPlotWidth = 512;
57 static constexpr size_t kPlotHeight = 256;
58
59 GrColorType atlasColorType = GrColorType::kAlpha_8;
60 const GrBackendFormat format = caps->getDefaultBackendFormat(atlasColorType,
62
63 GrDrawOpAtlasConfig atlasConfig(caps->maxTextureSize(), kMaxAtlasTextureBytes);
64 SkISize size = atlasConfig.atlasDimensions(MaskFormat::kA8);
65 fAtlas = GrDrawOpAtlas::Make(proxyProvider, format,
66 GrColorTypeToSkColorType(atlasColorType),
67 GrColorTypeBytesPerPixel(atlasColorType),
68 size.width(), size.height(),
69 kPlotWidth, kPlotHeight, this,
71 this,
72 /*label=*/"SmallPathAtlas");
73
74 return SkToBool(fAtlas);
75}
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
Definition: GrTypesPriv.h:896
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
Definition: GrTypesPriv.h:589
GrColorType
Definition: GrTypesPriv.h:540
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
int maxTextureSize() const
Definition: GrCaps.h:229
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition: GrCaps.cpp:400
static std::unique_ptr< GrDrawOpAtlas > Make(GrProxyProvider *proxyProvider, const GrBackendFormat &format, SkColorType ct, size_t bpp, int width, int height, int plotWidth, int plotHeight, skgpu::AtlasGenerationCounter *generationCounter, AllowMultitexturing allowMultitexturing, skgpu::PlotEvictionCallback *evictor, std::string_view label)
uint32_t uint32_t * format
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
@ kA8
1-byte per pixel
Definition: SkSize.h:16

◆ postFlush()

void skgpu::ganesh::SmallPathAtlasMgr::postFlush ( skgpu::AtlasToken  startTokenForNextFlush)
inlineoverridevirtual

Called once flushing is complete. startTokenForNextFlush can be used to track resources used in the current flush.

Reimplemented from GrOnFlushCallbackObject.

Definition at line 68 of file SmallPathAtlasMgr.h.

68 {
69 if (fAtlas) {
70 fAtlas->compact(startTokenForNextFlush);
71 }
72 }

◆ preFlush()

bool skgpu::ganesh::SmallPathAtlasMgr::preFlush ( GrOnFlushResourceProvider onFlushRP)
inlineoverridevirtual

Implements GrOnFlushCallbackObject.

Definition at line 55 of file SmallPathAtlasMgr.h.

55 {
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 }

◆ reset()

void skgpu::ganesh::SmallPathAtlasMgr::reset ( )

Definition at line 31 of file SmallPathAtlasMgr.cpp.

31 {
32 ShapeDataList::Iter iter;
33 iter.init(fShapeList, ShapeDataList::Iter::kHead_IterStart);
34 SmallPathShapeData* shapeData;
35 while ((shapeData = iter.get())) {
36 iter.next();
37 delete shapeData;
38 }
39
40 fShapeList.reset();
41 fShapeCache.reset();
42
43#ifdef DF_PATH_TRACKING
44 SkDebugf("Cached shapes: %d, freed shapes: %d\n", g_NumCachedShapes, g_NumFreedShapes);
45#endif
46
47 fAtlas = nullptr;
48}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1

◆ retainOnFreeGpuResources()

bool skgpu::ganesh::SmallPathAtlasMgr::retainOnFreeGpuResources ( )
inlineoverridevirtual

Tells the callback owner to hold onto this object when freeing GPU resources.

Reimplemented from GrOnFlushCallbackObject.

Definition at line 76 of file SmallPathAtlasMgr.h.

76{ return true; }

◆ setUseToken()

void skgpu::ganesh::SmallPathAtlasMgr::setUseToken ( SmallPathShapeData shapeData,
skgpu::AtlasToken  token 
)

Definition at line 123 of file SmallPathAtlasMgr.cpp.

124 {
125 fAtlas->setLastUseToken(shapeData->fAtlasLocator, token);
126}

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