Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skgpu::graphite::DrawAtlasConfig Class Reference

#include <DrawAtlas.h>

Public Member Functions

 DrawAtlasConfig (int maxTextureSize, size_t maxBytes)
 
SkISize atlasDimensions (MaskFormat type) const
 
SkISize plotDimensions (MaskFormat type) const
 

Detailed Description

Definition at line 270 of file DrawAtlas.h.

Constructor & Destructor Documentation

◆ DrawAtlasConfig()

skgpu::graphite::DrawAtlasConfig::DrawAtlasConfig ( int  maxTextureSize,
size_t  maxBytes 
)

Definition at line 533 of file DrawAtlas.cpp.

533 {
534 static const SkISize kARGBDimensions[] = {
535 {256, 256}, // maxBytes < 2^19
536 {512, 256}, // 2^19 <= maxBytes < 2^20
537 {512, 512}, // 2^20 <= maxBytes < 2^21
538 {1024, 512}, // 2^21 <= maxBytes < 2^22
539 {1024, 1024}, // 2^22 <= maxBytes < 2^23
540 {2048, 1024}, // 2^23 <= maxBytes
541 };
542
543 // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that
544 maxBytes >>= 18;
545 // Take the floor of the log to get the index
546 int index = maxBytes > 0
547 ? SkTPin<int>(SkPrevLog2(maxBytes), 0, std::size(kARGBDimensions) - 1)
548 : 0;
549
550 SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim);
551 SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim);
552 fARGBDimensions.set(std::min<int>(kARGBDimensions[index].width(), maxTextureSize),
553 std::min<int>(kARGBDimensions[index].height(), maxTextureSize));
554 fMaxTextureSize = std::min<int>(maxTextureSize, kMaxAtlasDim);
555}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static int SkPrevLog2(uint32_t value)
Definition: SkMathPriv.h:257
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
int32_t height
int32_t width
Definition: SkSize.h:16
void set(int32_t w, int32_t h)
Definition: SkSize.h:24

Member Function Documentation

◆ atlasDimensions()

SkISize skgpu::graphite::DrawAtlasConfig::atlasDimensions ( MaskFormat  type) const

Definition at line 557 of file DrawAtlas.cpp.

557 {
558 if (MaskFormat::kA8 == type) {
559 // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size
560 return { std::min<int>(2 * fARGBDimensions.width(), fMaxTextureSize),
561 std::min<int>(2 * fARGBDimensions.height(), fMaxTextureSize) };
562 } else {
563 return fARGBDimensions;
564 }
565}
GLenum type
@ kA8
1-byte per pixel
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ plotDimensions()

SkISize skgpu::graphite::DrawAtlasConfig::plotDimensions ( MaskFormat  type) const

Definition at line 567 of file DrawAtlas.cpp.

567 {
568 if (MaskFormat::kA8 == type) {
570 // For A8 we want to grow the plots at larger texture sizes to accept more of the
571 // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this
572 // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot.
573
574 // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048,
575 // and 256x256 plots otherwise.
576 int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256;
577 int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256;
578
579 return { plotWidth, plotHeight };
580 } else {
581 // ARGB and LCD always use 256x256 plots -- this has been shown to be faster
582 return { 256, 256 };
583 }
584}
SkISize atlasDimensions(MaskFormat type) const
Definition: DrawAtlas.cpp:557

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