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

#include <GrDrawOpAtlas.h>

Public Member Functions

 GrDrawOpAtlasConfig (int maxTextureSize, size_t maxBytes)
 
 GrDrawOpAtlasConfig ()
 
SkISize atlasDimensions (skgpu::MaskFormat type) const
 
SkISize plotDimensions (skgpu::MaskFormat type) const
 

Detailed Description

Definition at line 250 of file GrDrawOpAtlas.h.

Constructor & Destructor Documentation

◆ GrDrawOpAtlasConfig() [1/2]

GrDrawOpAtlasConfig::GrDrawOpAtlasConfig ( int  maxTextureSize,
size_t  maxBytes 
)

Definition at line 559 of file GrDrawOpAtlas.cpp.

559 {
560 static const SkISize kARGBDimensions[] = {
561 {256, 256}, // maxBytes < 2^19
562 {512, 256}, // 2^19 <= maxBytes < 2^20
563 {512, 512}, // 2^20 <= maxBytes < 2^21
564 {1024, 512}, // 2^21 <= maxBytes < 2^22
565 {1024, 1024}, // 2^22 <= maxBytes < 2^23
566 {2048, 1024}, // 2^23 <= maxBytes
567 };
568
569 // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that
570 maxBytes >>= 18;
571 // Take the floor of the log to get the index
572 int index = maxBytes > 0
573 ? SkTPin<int>(SkPrevLog2(maxBytes), 0, std::size(kARGBDimensions) - 1)
574 : 0;
575
576 SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim);
577 SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim);
578 fARGBDimensions.set(std::min<int>(kARGBDimensions[index].width(), maxTextureSize),
579 std::min<int>(kARGBDimensions[index].height(), maxTextureSize));
580 fMaxTextureSize = std::min<int>(maxTextureSize, kMaxAtlasDim);
581}
#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

◆ GrDrawOpAtlasConfig() [2/2]

GrDrawOpAtlasConfig::GrDrawOpAtlasConfig ( )
inline

Definition at line 258 of file GrDrawOpAtlas.h.

258: GrDrawOpAtlasConfig(kMaxAtlasDim, 0) {}

Member Function Documentation

◆ atlasDimensions()

SkISize GrDrawOpAtlasConfig::atlasDimensions ( skgpu::MaskFormat  type) const

Definition at line 583 of file GrDrawOpAtlas.cpp.

583 {
584 if (MaskFormat::kA8 == type) {
585 // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size
586 return { std::min<int>(2 * fARGBDimensions.width(), fMaxTextureSize),
587 std::min<int>(2 * fARGBDimensions.height(), fMaxTextureSize) };
588 } else {
589 return fARGBDimensions;
590 }
591}
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ plotDimensions()

SkISize GrDrawOpAtlasConfig::plotDimensions ( skgpu::MaskFormat  type) const

Definition at line 593 of file GrDrawOpAtlas.cpp.

593 {
594 if (MaskFormat::kA8 == type) {
596 // For A8 we want to grow the plots at larger texture sizes to accept more of the
597 // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this
598 // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot.
599
600 // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048,
601 // and 256x256 plots otherwise.
602 int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256;
603 int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256;
604
605 return { plotWidth, plotHeight };
606 } else {
607 // ARGB and LCD always use 256x256 plots -- this has been shown to be faster
608 return { 256, 256 };
609 }
610}
SkISize atlasDimensions(skgpu::MaskFormat type) const

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