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

#include <RasterPathAtlas.h>

Inheritance diagram for skgpu::graphite::RasterPathAtlas:
skgpu::graphite::PathAtlas

Public Member Functions

 RasterPathAtlas (Recorder *recorder)
 
 ~RasterPathAtlas () override
 
void recordUploads (DrawContext *)
 
void postFlush ()
 
- Public Member Functions inherited from skgpu::graphite::PathAtlas
 PathAtlas (Recorder *recorder, uint32_t requestedWidth, uint32_t requestedHeight)
 
virtual ~PathAtlas ()
 
std::pair< const Renderer *, std::optional< MaskAndOrigin > > addShape (const Rect &transformedShapeBounds, const Shape &shape, const Transform &localToDevice, const SkStrokeRec &style)
 
virtual bool isSuitableForAtlasing (const Rect &transformedShapeBounds, const Rect &clipBounds) const
 
uint32_t width () const
 
uint32_t height () const
 

Protected Member Functions

const TextureProxyonAddShape (const Shape &, const Transform &transform, const SkStrokeRec &, skvx::half2 maskSize, skvx::half2 *outPos) override
 
virtual const TextureProxyonAddShape (const Shape &, const Transform &transform, const SkStrokeRec &, skvx::half2 maskSize, skvx::half2 *outPos)=0
 

Additional Inherited Members

- Public Types inherited from skgpu::graphite::PathAtlas
using MaskAndOrigin = std::pair< CoverageMaskShape, SkIPoint >
 
- Static Public Attributes inherited from skgpu::graphite::PathAtlas
static constexpr int kEntryPadding = 1
 
- Protected Attributes inherited from skgpu::graphite::PathAtlas
RecorderfRecorder
 
uint32_t fWidth = 0
 
uint32_t fHeight = 0
 

Detailed Description

PathAtlas class that rasterizes coverage masks on the CPU.

When a new shape gets added, its path is rasterized in preparation for upload. These uploads are recorded by recordUploads() and subsequently added to an UploadTask.

Shapes are cached for future frames to avoid the cost of raster pipeline rendering. Multiple textures (or Pages) are used to cache masks, so if the atlas is full we can reset a Page and start adding new shapes for a future atlas render.

Definition at line 25 of file RasterPathAtlas.h.

Constructor & Destructor Documentation

◆ RasterPathAtlas()

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

Definition at line 26 of file RasterPathAtlas.cpp.

28 , fCachedAtlasMgr(fWidth, fHeight, fWidth, fHeight, recorder->priv().caps())
29 , fSmallPathAtlasMgr(std::max(fWidth/2, kSmallPathPlotWidth),
32 recorder->priv().caps())
33 , fUncachedAtlasMgr(fWidth, fHeight, fWidth, fHeight, recorder->priv().caps()) {
34 SkASSERT(recorder);
35}
#define SkASSERT(cond)
Definition: SkAssert.h:116
PathAtlas(Recorder *recorder, uint32_t requestedWidth, uint32_t requestedHeight)
Definition: PathAtlas.cpp:26
const Caps * caps() const
Definition: RecorderPriv.h:31
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static constexpr uint32_t kSmallPathPlotWidth
static constexpr uint32_t kDefaultAtlasDim
static constexpr uint32_t kSmallPathPlotHeight

◆ ~RasterPathAtlas()

skgpu::graphite::RasterPathAtlas::~RasterPathAtlas ( )
inlineoverride

Definition at line 28 of file RasterPathAtlas.h.

28{}

Member Function Documentation

◆ onAddShape()

const TextureProxy * skgpu::graphite::RasterPathAtlas::onAddShape ( const Shape shape,
const Transform transform,
const SkStrokeRec strokeRec,
skvx::half2  maskSize,
skvx::half2 outPos 
)
overrideprotectedvirtual

Implements skgpu::graphite::PathAtlas.

Definition at line 43 of file RasterPathAtlas.cpp.

47 {
48 skgpu::UniqueKey maskKey;
49 bool hasKey = shape.hasKey();
50 if (hasKey) {
51 constexpr int kMaxSmallPathSize = 162;
52 // Try to locate or add to cached DrawAtlas
53 const TextureProxy* proxy = nullptr;
54 if (maskSize.x() <= kMaxSmallPathSize && maskSize.y() <= kMaxSmallPathSize) {
55 proxy = fSmallPathAtlasMgr.findOrCreateEntry(fRecorder,
56 shape,
58 strokeRec,
59 maskSize,
60 outPos);
61 }
62 if (!proxy) {
63 proxy = fCachedAtlasMgr.findOrCreateEntry(fRecorder,
64 shape,
66 strokeRec,
67 maskSize,
68 outPos);
69 }
70 if (proxy) {
71 return proxy;
72 }
73 }
74
75 // try to add to uncached DrawAtlas
76 AtlasLocator loc;
77 return fUncachedAtlasMgr.addToAtlas(fRecorder,
78 shape,
80 strokeRec,
81 maskSize,
82 outPos,
83 &loc);
84}
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47

◆ postFlush()

void skgpu::graphite::RasterPathAtlas::postFlush ( )
inline

Definition at line 31 of file RasterPathAtlas.h.

31 {
32 fCachedAtlasMgr.postFlush(fRecorder);
33 fSmallPathAtlasMgr.postFlush(fRecorder);
34 fUncachedAtlasMgr.postFlush(fRecorder);
35 }

◆ recordUploads()

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

Definition at line 37 of file RasterPathAtlas.cpp.

37 {
38 fCachedAtlasMgr.recordUploads(dc, fRecorder);
39 fSmallPathAtlasMgr.recordUploads(dc, fRecorder);
40 fUncachedAtlasMgr.recordUploads(dc, fRecorder);
41}

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