Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 256 of file DrawAtlas.h.

Constructor & Destructor Documentation

◆ DrawAtlasConfig()

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

Definition at line 516 of file DrawAtlas.cpp.

516 {
517 static const SkISize kARGBDimensions[] = {
518 {256, 256}, // maxBytes < 2^19
519 {512, 256}, // 2^19 <= maxBytes < 2^20
520 {512, 512}, // 2^20 <= maxBytes < 2^21
521 {1024, 512}, // 2^21 <= maxBytes < 2^22
522 {1024, 1024}, // 2^22 <= maxBytes < 2^23
523 {2048, 1024}, // 2^23 <= maxBytes
524 };
525
526 // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that
527 maxBytes >>= 18;
528 // Take the floor of the log to get the index
529 int index = maxBytes > 0
530 ? SkTPin<int>(SkPrevLog2(maxBytes), 0, std::size(kARGBDimensions) - 1)
531 : 0;
532
533 SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim);
534 SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim);
535 fARGBDimensions.set(std::min<int>(kARGBDimensions[index].width(), maxTextureSize),
536 std::min<int>(kARGBDimensions[index].height(), maxTextureSize));
537 fMaxTextureSize = std::min<int>(maxTextureSize, kMaxAtlasDim);
538}
#define SkASSERT(cond)
Definition SkAssert.h:116
static int SkPrevLog2(uint32_t value)
Definition SkMathPriv.h:257
int32_t height
int32_t width
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 540 of file DrawAtlas.cpp.

540 {
541 if (MaskFormat::kA8 == type) {
542 // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size
543 return { std::min<int>(2 * fARGBDimensions.width(), fMaxTextureSize),
544 std::min<int>(2 * fARGBDimensions.height(), fMaxTextureSize) };
545 } else {
546 return fARGBDimensions;
547 }
548}
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 550 of file DrawAtlas.cpp.

550 {
551 if (MaskFormat::kA8 == type) {
553 // For A8 we want to grow the plots at larger texture sizes to accept more of the
554 // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this
555 // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot.
556
557 // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048,
558 // and 256x256 plots otherwise.
559 int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256;
560 int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256;
561
562 return { plotWidth, plotHeight };
563 } else {
564 // ARGB and LCD always use 256x256 plots -- this has been shown to be faster
565 return { 256, 256 };
566 }
567}
SkISize atlasDimensions(MaskFormat type) const

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