Flutter Engine
The Flutter Engine
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 ()
 
virtual bool preFlush (GrOnFlushResourceProvider *)=0
 
virtual void postFlush (skgpu::AtlasToken startTokenForNextFlush)
 
virtual bool retainOnFreeGpuResources ()
 
- 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 34 of file GrAtlasManager.cpp.

38 : fAllowMultitexturing{allowMultitexturing}
39 , fSupportBilerpAtlas{supportBilerpAtlas}
40 , fProxyProvider{proxyProvider}
41 , fCaps{fProxyProvider->refCaps()}
42 , 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 165 of file GrAtlasManager.cpp.

169 {
170#if !defined(SK_DISABLE_SDF_TEXT)
171 SkASSERT(0 <= srcPadding && srcPadding <= SK_DistanceFieldInset);
172#else
173 SkASSERT(0 <= srcPadding);
174#endif
175
176 if (skGlyph.image() == nullptr) {
178 }
179 SkASSERT(glyph != nullptr);
180
181 MaskFormat glyphFormat = Glyph::FormatFromSkGlyph(skGlyph.maskFormat());
182 MaskFormat expectedMaskFormat = this->resolveMaskFormat(glyphFormat);
183 int bytesPerPixel = MaskFormatBytesPerPixel(expectedMaskFormat);
184
185 int padding;
186 switch (srcPadding) {
187 case 0:
188 // The direct mask/image case.
189 padding = 0;
190 if (fSupportBilerpAtlas) {
191 // Force direct masks (glyph with no padding) to have padding.
192 padding = 1;
193 srcPadding = 1;
194 }
195 break;
196 case 1:
197 // The transformed mask/image case.
198 padding = 1;
199 break;
200#if !defined(SK_DISABLE_SDF_TEXT)
202 // The SDFT case.
203 // If the srcPadding == SK_DistanceFieldInset (SDFT case) then the padding is built
204 // into the image on the glyph; no extra padding needed.
205 // TODO: can the SDFT glyph image in the cache be reduced by the padding?
206 padding = 0;
207 break;
208#endif
209 default:
210 // The padding is not one of the know forms.
212 }
213
214 const int width = skGlyph.width() + 2*padding;
215 const int height = skGlyph.height() + 2*padding;
216 int rowBytes = width * bytesPerPixel;
217 size_t size = height * rowBytes;
218
219 // Temporary storage for normalizing glyph image.
220 SkAutoSMalloc<1024> storage(size);
221 void* dataPtr = storage.get();
222 if (padding > 0) {
223 sk_bzero(dataPtr, size);
224 // Advance in one row and one column.
225 dataPtr = (char*)(dataPtr) + rowBytes + bytesPerPixel;
226 }
227
228 get_packed_glyph_image(skGlyph, rowBytes, expectedMaskFormat, dataPtr);
229
230 auto errorCode = this->addToAtlas(resourceProvider,
231 uploadTarget,
232 expectedMaskFormat,
233 width,
234 height,
235 storage.get(),
236 &glyph->fAtlasLocator);
237
238 if (errorCode == GrDrawOpAtlas::ErrorCode::kSucceeded) {
239 glyph->fAtlasLocator.insetSrc(srcPadding);
240 }
241
242 return errorCode;
243}
sk_bzero(glyphs, sizeof(glyphs))
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
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
MaskFormat
Definition: AtlasTypes.h:98
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 255 of file GrAtlasManager.cpp.

257 {
258 SkASSERT(glyph);
259 if (updater->add(glyph->fAtlasLocator)) {
260 this->getAtlas(format)->setLastUseToken(glyph->fAtlasLocator, token);
261 }
262}
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 246 of file GrAtlasManager.cpp.

250 {
251 return this->getAtlas(format)->addToAtlas(resourceProvider, target, width, height, image,
252 atlasLocator);
253}
ErrorCode addToAtlas(GrResourceProvider *, GrDeferredUploadTarget *, int width, int height, const void *image, skgpu::AtlasLocator *)
uint32_t * target
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ 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 46 of file GrAtlasManager.cpp.

46 {
47 for (int i = 0; i < skgpu::kMaskFormatCount; ++i) {
48 fAtlases[i] = nullptr;
49 }
50}
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 52 of file GrAtlasManager.cpp.

52 {
53 SkASSERT(glyph);
54 return this->getAtlas(format)->hasID(glyph->fAtlasLocator.plotLocator());
55}
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 Function 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: