Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::AtlasProvider Class Referencefinal

#include <AtlasProvider.h>

Public Types

enum class  PathAtlasFlags : unsigned { kNone = 0b000 , kCompute = 0b001 , kRaster = 0b010 }
 
using PathAtlasFlagsBitMask = SkEnumBitMask< PathAtlasFlags >
 

Public Member Functions

 AtlasProvider (Recorder *)
 
 ~AtlasProvider ()=default
 
TextAtlasManagertextAtlasManager () const
 
bool isAvailable (PathAtlasFlags atlasType) const
 
std::unique_ptr< ComputePathAtlascreateComputePathAtlas (Recorder *recorder) const
 
RasterPathAtlasgetRasterPathAtlas () const
 
sk_sp< TextureProxygetAtlasTexture (Recorder *, uint16_t width, uint16_t height, SkColorType, uint16_t identifier, bool requireStorageUsage)
 
void clearTexturePool ()
 
void recordUploads (DrawContext *)
 
void postFlush ()
 

Static Public Member Functions

static PathAtlasFlagsBitMask QueryPathAtlasSupport (const Caps *)
 

Detailed Description

AtlasProvider groups various texture atlas management algorithms together.

Definition at line 33 of file AtlasProvider.h.

Member Typedef Documentation

◆ PathAtlasFlagsBitMask

Definition at line 43 of file AtlasProvider.h.

Member Enumeration Documentation

◆ PathAtlasFlags

enum class skgpu::graphite::AtlasProvider::PathAtlasFlags : unsigned
strong
Enumerator
kNone 
kCompute 
kRaster 

Definition at line 35 of file AtlasProvider.h.

35 : unsigned {
36 kNone = 0b000,
37 // ComputePathAtlas is supported
38 kCompute = 0b001,
39 // RasterPathAtlas is supported
40 kRaster = 0b010,
41 };
@ kRaster
Suitable for thread which raster data.
Definition: embedder.h:266
@ kNone
Definition: layer.h:53

Constructor & Destructor Documentation

◆ AtlasProvider()

skgpu::graphite::AtlasProvider::AtlasProvider ( Recorder recorder)
explicit

Definition at line 31 of file AtlasProvider.cpp.

32 : fTextAtlasManager(std::make_unique<TextAtlasManager>(recorder))
33 , fRasterPathAtlas(std::make_unique<RasterPathAtlas>(recorder))
34 , fPathAtlasFlags(QueryPathAtlasSupport(recorder->priv().caps())) {}
static PathAtlasFlagsBitMask QueryPathAtlasSupport(const Caps *)
const Caps * caps() const
Definition: RecorderPriv.h:31

◆ ~AtlasProvider()

skgpu::graphite::AtlasProvider::~AtlasProvider ( )
default

Member Function Documentation

◆ clearTexturePool()

void skgpu::graphite::AtlasProvider::clearTexturePool ( )

Definition at line 86 of file AtlasProvider.cpp.

86 {
87 fTexturePool.clear();
88}

◆ createComputePathAtlas()

std::unique_ptr< ComputePathAtlas > skgpu::graphite::AtlasProvider::createComputePathAtlas ( Recorder recorder) const

Definition at line 36 of file AtlasProvider.cpp.

36 {
38 return ComputePathAtlas::CreateDefault(recorder);
39 }
40 return nullptr;
41}
bool isAvailable(PathAtlasFlags atlasType) const
Definition: AtlasProvider.h:57
static std::unique_ptr< ComputePathAtlas > CreateDefault(Recorder *)

◆ getAtlasTexture()

sk_sp< TextureProxy > skgpu::graphite::AtlasProvider::getAtlasTexture ( Recorder recorder,
uint16_t  width,
uint16_t  height,
SkColorType  colorType,
uint16_t  identifier,
bool  requireStorageUsage 
)

Definition at line 47 of file AtlasProvider.cpp.

52 {
53 uint64_t key = static_cast<uint64_t>(width) << 48 |
54 static_cast<uint64_t>(height) << 32 |
55 static_cast<uint64_t>(colorType) << 16 |
56 static_cast<uint64_t>(identifier);
57 auto iter = fTexturePool.find(key);
58 if (iter != fTexturePool.end()) {
59 return iter->second;
60 }
61
62 // We currently only make the distinction between a storage texture (written by a
63 // compute pass) and a plain sampleable texture (written via upload) that won't be
64 // used as a render attachment.
65 const Caps* caps = recorder->priv().caps();
66 auto textureInfo = requireStorageUsage
68 : caps->getDefaultSampledTextureInfo(colorType,
70 recorder->priv().isProtected(),
73 recorder->priv().resourceProvider(),
74 SkISize::Make((int32_t) width, (int32_t) height),
75 textureInfo,
76 "AtlasProviderTexture",
78 if (!proxy) {
79 return nullptr;
80 }
81
82 fTexturePool[key] = proxy;
83 return proxy;
84}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
Protected isProtected() const
Definition: RecorderPriv.h:52
ResourceProvider * resourceProvider()
Definition: RecorderPriv.h:33
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
static SkString identifier(const FontFamilyDesc &family, const FontDesc &font)
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getRasterPathAtlas()

RasterPathAtlas * skgpu::graphite::AtlasProvider::getRasterPathAtlas ( ) const

Definition at line 43 of file AtlasProvider.cpp.

43 {
44 return fRasterPathAtlas.get();
45}

◆ isAvailable()

bool skgpu::graphite::AtlasProvider::isAvailable ( PathAtlasFlags  atlasType) const
inline

Definition at line 57 of file AtlasProvider.h.

57 {
58 return SkToBool(fPathAtlasFlags & atlasType);
59 }
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ postFlush()

void skgpu::graphite::AtlasProvider::postFlush ( )

Definition at line 100 of file AtlasProvider.cpp.

100 {
101 fTextAtlasManager->postFlush();
102 if (fRasterPathAtlas) {
103 fRasterPathAtlas->postFlush();
104 }
105}

◆ QueryPathAtlasSupport()

AtlasProvider::PathAtlasFlagsBitMask skgpu::graphite::AtlasProvider::QueryPathAtlasSupport ( const Caps caps)
static

Definition at line 22 of file AtlasProvider.cpp.

22 {
23 // The raster-backend path atlas is always supported.
27 }
28 return flags;
29}
SkEnumBitMask< PathAtlasFlags > PathAtlasFlagsBitMask
Definition: AtlasProvider.h:43
static bool IsVelloRendererSupported(const Caps *)
FlutterSemanticsFlag flags

◆ recordUploads()

void skgpu::graphite::AtlasProvider::recordUploads ( DrawContext dc)

Definition at line 90 of file AtlasProvider.cpp.

90 {
91 if (!fTextAtlasManager->recordUploads(dc)) {
92 SKGPU_LOG_E("TextAtlasManager uploads have failed -- may see invalid results.");
93 }
94
95 if (fRasterPathAtlas) {
96 fRasterPathAtlas->recordUploads(dc);
97 }
98}
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38

◆ textAtlasManager()

TextAtlasManager * skgpu::graphite::AtlasProvider::textAtlasManager ( ) const
inline

Definition at line 53 of file AtlasProvider.h.

53{ return fTextAtlasManager.get(); }

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