Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
GrAtlasManager Class Reference

#include <GrAtlasManager.h>

Inheritance diagram for GrAtlasManager:
GrOnFlushCallbackObject skgpu::AtlasGenerationCounter

Public Member Functions

 GrAtlasManager (GrProxyProvider *, size_t maxTextureBytes, GrDrawOpAtlas::AllowMultitexturing, bool supportBilerpAtlas)
 
 ~GrAtlasManager () override
 
const GrSurfaceProxyViewgetViews (skgpu::MaskFormat format, unsigned int *numActiveProxies)
 
void freeAll ()
 
bool hasGlyph (skgpu::MaskFormat, sktext::gpu::Glyph *)
 
GrDrawOpAtlas::ErrorCode addGlyphToAtlas (const SkGlyph &, sktext::gpu::Glyph *, int srcPadding, GrResourceProvider *, GrDeferredUploadTarget *)
 
void addGlyphToBulkAndSetUseToken (skgpu::BulkUsePlotUpdater *, skgpu::MaskFormat, sktext::gpu::Glyph *, skgpu::AtlasToken)
 
void setUseTokenBulk (const skgpu::BulkUsePlotUpdater &updater, skgpu::AtlasToken token, skgpu::MaskFormat format)
 
GrDrawOpAtlas::ErrorCode addToAtlas (GrResourceProvider *, GrDeferredUploadTarget *, skgpu::MaskFormat, int width, int height, const void *image, skgpu::AtlasLocator *)
 
uint64_t atlasGeneration (skgpu::MaskFormat format) const
 
bool preFlush (GrOnFlushResourceProvider *onFlushRP) override
 
void postFlush (skgpu::AtlasToken startTokenForNextFlush) override
 
bool retainOnFreeGpuResources () override
 
- Public Member Functions inherited from GrOnFlushCallbackObject
virtual ~GrOnFlushCallbackObject ()
 
- Public Member Functions inherited from skgpu::AtlasGenerationCounter
uint64_t next ()
 

Friends

class GrAtlasManagerTools
 

Additional Inherited Members

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

Detailed Description

The GrAtlasManager manages the lifetime of and access to GrDrawOpAtlases. It is only available at flush and only via the GrOpFlushState.

This implies that all of the advanced atlasManager functionality (i.e., adding glyphs to the atlas) are only available at flush time.

Definition at line 43 of file GrAtlasManager.h.

Constructor & Destructor Documentation

◆ GrAtlasManager()

GrAtlasManager::GrAtlasManager ( GrProxyProvider proxyProvider,
size_t  maxTextureBytes,
GrDrawOpAtlas::AllowMultitexturing  allowMultitexturing,
bool  supportBilerpAtlas 
)

Definition at line 35 of file GrAtlasManager.cpp.

39 : fAllowMultitexturing{allowMultitexturing}
40 , fSupportBilerpAtlas{supportBilerpAtlas}
41 , fProxyProvider{proxyProvider}
42 , fCaps{fProxyProvider->refCaps()}
43 , fAtlasConfig{fCaps->maxTextureSize(), maxTextureBytes} { }
int maxTextureSize() const
Definition GrCaps.h:229
sk_sp< const GrCaps > refCaps() const

◆ ~GrAtlasManager()

GrAtlasManager::~GrAtlasManager ( )
overridedefault

Member Function Documentation

◆ addGlyphToAtlas()

GrDrawOpAtlas::ErrorCode GrAtlasManager::addGlyphToAtlas ( const SkGlyph skGlyph,
sktext::gpu::Glyph glyph,
int  srcPadding,
GrResourceProvider resourceProvider,
GrDeferredUploadTarget uploadTarget 
)

Definition at line 155 of file GrAtlasManager.cpp.

159 {
160#if !defined(SK_DISABLE_SDF_TEXT)
161 SkASSERT(0 <= srcPadding && srcPadding <= SK_DistanceFieldInset);
162#else
163 SkASSERT(0 <= srcPadding);
164#endif
165
166 if (skGlyph.image() == nullptr) {
168 }
169 SkASSERT(glyph != nullptr);
170
171 MaskFormat glyphFormat = Glyph::FormatFromSkGlyph(skGlyph.maskFormat());
172 MaskFormat expectedMaskFormat = this->resolveMaskFormat(glyphFormat);
173 int bytesPerPixel = MaskFormatBytesPerPixel(expectedMaskFormat);
174
175 int padding;
176 switch (srcPadding) {
177 case 0:
178 // The direct mask/image case.
179 padding = 0;
180 if (fSupportBilerpAtlas) {
181 // Force direct masks (glyph with no padding) to have padding.
182 padding = 1;
183 srcPadding = 1;
184 }
185 break;
186 case 1:
187 // The transformed mask/image case.
188 padding = 1;
189 break;
190#if !defined(SK_DISABLE_SDF_TEXT)
192 // The SDFT case.
193 // If the srcPadding == SK_DistanceFieldInset (SDFT case) then the padding is built
194 // into the image on the glyph; no extra padding needed.
195 // TODO: can the SDFT glyph image in the cache be reduced by the padding?
196 padding = 0;
197 break;
198#endif
199 default:
200 // The padding is not one of the know forms.
202 }
203
204 const int width = skGlyph.width() + 2*padding;
205 const int height = skGlyph.height() + 2*padding;
206 int rowBytes = width * bytesPerPixel;
207 size_t size = height * rowBytes;
208
209 // Temporary storage for normalizing glyph image.
210 SkAutoSMalloc<1024> storage(size);
211 void* dataPtr = storage.get();
212 if (padding > 0) {
213 sk_bzero(dataPtr, size);
214 // Advance in one row and one column.
215 dataPtr = (char*)(dataPtr) + rowBytes + bytesPerPixel;
216 }
217
218 get_packed_glyph_image(skGlyph, rowBytes, expectedMaskFormat, dataPtr);
219
220 auto errorCode = this->addToAtlas(resourceProvider,
221 uploadTarget,
222 expectedMaskFormat,
223 width,
224 height,
225 storage.get(),
226 &glyph->fAtlasLocator);
227
228 if (errorCode == GrDrawOpAtlas::ErrorCode::kSucceeded) {
229 glyph->fAtlasLocator.insetSrc(srcPadding);
230 }
231
232 return errorCode;
233}
static void get_packed_glyph_image(const SkGlyph &glyph, int dstRB, MaskFormat expectedMaskFormat, void *dst)
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SK_DistanceFieldInset
static void sk_bzero(void *buffer, size_t size)
Definition SkMalloc.h:105
GrDrawOpAtlas::ErrorCode addToAtlas(GrResourceProvider *, GrDeferredUploadTarget *, skgpu::MaskFormat, int width, int height, const void *image, skgpu::AtlasLocator *)
SkMask::Format maskFormat() const
Definition SkGlyph.h:500
int height() const
Definition SkGlyph.h:513
int width() const
Definition SkGlyph.h:512
const void * image() const
Definition SkGlyph.h:465
void insetSrc(int padding)
Definition AtlasTypes.h:327
skgpu::AtlasLocator fAtlasLocator
Definition Glyph.h:40
static skgpu::MaskFormat FormatFromSkGlyph(SkMask::Format format)
Definition Glyph.h:19
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
constexpr int MaskFormatBytesPerPixel(MaskFormat format)
Definition AtlasTypes.h:110
int32_t height
int32_t width

◆ addGlyphToBulkAndSetUseToken()

void GrAtlasManager::addGlyphToBulkAndSetUseToken ( skgpu::BulkUsePlotUpdater updater,
skgpu::MaskFormat  format,
sktext::gpu::Glyph glyph,
skgpu::AtlasToken  token 
)

Definition at line 245 of file GrAtlasManager.cpp.

247 {
248 SkASSERT(glyph);
249 if (updater->add(glyph->fAtlasLocator)) {
250 this->getAtlas(format)->setLastUseToken(glyph->fAtlasLocator, token);
251 }
252}
void setLastUseToken(const skgpu::AtlasLocator &atlasLocator, skgpu::AtlasToken token)
bool add(const skgpu::AtlasLocator &atlasLocator)
Definition AtlasTypes.h:387
uint32_t uint32_t * format

◆ addToAtlas()

GrDrawOpAtlas::ErrorCode GrAtlasManager::addToAtlas ( GrResourceProvider resourceProvider,
GrDeferredUploadTarget target,
skgpu::MaskFormat  format,
int  width,
int  height,
const void *  image,
skgpu::AtlasLocator atlasLocator 
)

Definition at line 236 of file GrAtlasManager.cpp.

240 {
241 return this->getAtlas(format)->addToAtlas(resourceProvider, target, width, height, image,
242 atlasLocator);
243}
ErrorCode addToAtlas(GrResourceProvider *, GrDeferredUploadTarget *, int width, int height, const void *image, skgpu::AtlasLocator *)
sk_sp< SkImage > image
Definition examples.cpp:29
uint32_t * target

◆ atlasGeneration()

uint64_t GrAtlasManager::atlasGeneration ( skgpu::MaskFormat  format) const
inline

Definition at line 97 of file GrAtlasManager.h.

97 {
98 return this->getAtlas(format)->atlasGeneration();
99 }
uint64_t atlasGeneration() const

◆ freeAll()

void GrAtlasManager::freeAll ( )

Definition at line 47 of file GrAtlasManager.cpp.

47 {
48 for (int i = 0; i < skgpu::kMaskFormatCount; ++i) {
49 fAtlases[i] = nullptr;
50 }
51}
static const int kMaskFormatCount
Definition AtlasTypes.h:105

◆ getViews()

const GrSurfaceProxyView * GrAtlasManager::getViews ( skgpu::MaskFormat  format,
unsigned int numActiveProxies 
)
inline

Definition at line 55 of file GrAtlasManager.h.

55 {
56 format = this->resolveMaskFormat(format);
57 if (this->initAtlas(format)) {
58 *numActiveProxies = this->getAtlas(format)->numActivePages();
59 return this->getAtlas(format)->getViews();
60 }
61 *numActiveProxies = 0;
62 return nullptr;
63 }
uint32_t numActivePages()
const GrSurfaceProxyView * getViews() const

◆ hasGlyph()

bool GrAtlasManager::hasGlyph ( skgpu::MaskFormat  format,
sktext::gpu::Glyph glyph 
)

Definition at line 53 of file GrAtlasManager.cpp.

53 {
54 SkASSERT(glyph);
55 return this->getAtlas(format)->hasID(glyph->fAtlasLocator.plotLocator());
56}
bool hasID(const skgpu::PlotLocator &plotLocator)
PlotLocator plotLocator() const
Definition AtlasTypes.h:301

◆ postFlush()

void GrAtlasManager::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 118 of file GrAtlasManager.h.

118 {
119 for (int i = 0; i < skgpu::kMaskFormatCount; ++i) {
120 if (fAtlases[i]) {
121 fAtlases[i]->compact(startTokenForNextFlush);
122 }
123 }
124 }

◆ preFlush()

bool GrAtlasManager::preFlush ( GrOnFlushResourceProvider onFlushRP)
inlineoverridevirtual

Implements GrOnFlushCallbackObject.

Definition at line 103 of file GrAtlasManager.h.

103 {
104#if defined(GR_TEST_UTILS)
105 if (onFlushRP->failFlushTimeCallbacks()) {
106 return false;
107 }
108#endif
109
110 for (int i = 0; i < skgpu::kMaskFormatCount; ++i) {
111 if (fAtlases[i]) {
112 fAtlases[i]->instantiate(onFlushRP);
113 }
114 }
115 return true;
116 }

◆ retainOnFreeGpuResources()

bool GrAtlasManager::retainOnFreeGpuResources ( )
inlineoverridevirtual

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

Reimplemented from GrOnFlushCallbackObject.

Definition at line 128 of file GrAtlasManager.h.

128{ return true; }

◆ setUseTokenBulk()

void GrAtlasManager::setUseTokenBulk ( const skgpu::BulkUsePlotUpdater updater,
skgpu::AtlasToken  token,
skgpu::MaskFormat  format 
)
inline

Definition at line 83 of file GrAtlasManager.h.

85 {
86 this->getAtlas(format)->setLastUseTokenBulk(updater, token);
87 }
void setLastUseTokenBulk(const skgpu::BulkUsePlotUpdater &updater, skgpu::AtlasToken token)

Friends And Related Symbol Documentation

◆ GrAtlasManagerTools

friend class GrAtlasManagerTools
friend

Definition at line 131 of file GrAtlasManager.h.


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