Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
skgpu::graphite::DrawWriter::Appender Class Reference

#include <DrawWriter.h>

Inheritance diagram for skgpu::graphite::DrawWriter::Appender:
skgpu::graphite::DrawWriter::DynamicInstances< LinearToleranceProxy > skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy > skgpu::graphite::DrawWriter::Instances skgpu::graphite::DrawWriter::Vertices

Public Types

enum class  Target { kVertices , kInstances }
 

Public Member Functions

 Appender (DrawWriter &w, Target target)
 
virtual ~Appender ()
 

Protected Member Functions

virtual void onFlush ()
 
void reserve (unsigned int count)
 
VertexWriter append (unsigned int count)
 

Protected Attributes

DrawWriterfDrawer
 
BindBufferInfofTarget
 
size_t fStride
 
unsigned int fReservedCount
 
VertexWriter fNextWriter
 

Detailed Description

Definition at line 241 of file DrawWriter.h.

Member Enumeration Documentation

◆ Target

Enumerator
kVertices 
kInstances 

Definition at line 243 of file DrawWriter.h.

243{ kVertices, kInstances };

Constructor & Destructor Documentation

◆ Appender()

skgpu::graphite::DrawWriter::Appender::Appender ( DrawWriter w,
Target  target 
)
inline

Definition at line 245 of file DrawWriter.h.

246 : fDrawer(w)
247 , fTarget(target == Target::kVertices ? w.fVertices : w.fInstances)
248 , fStride(target == Target::kVertices ? w.fVertexStride : w.fInstanceStride)
249 , fReservedCount(0)
250 , fNextWriter() {
251 SkASSERT(fStride > 0);
252 SkASSERT(!w.fAppender);
253 SkDEBUGCODE(w.fAppender = this;)
254 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
uint32_t * target
SkScalar w

◆ ~Appender()

virtual skgpu::graphite::DrawWriter::Appender::~Appender ( )
inlinevirtual

Definition at line 256 of file DrawWriter.h.

256 {
257 if (fReservedCount > 0) {
259 }
260 SkASSERT(fDrawer.fAppender == this);
261 SkDEBUGCODE(fDrawer.fAppender = nullptr;)
262 }
void returnVertexBytes(size_t unusedBytes)

Member Function Documentation

◆ append()

VertexWriter skgpu::graphite::DrawWriter::Appender::append ( unsigned int  count)
inlineprotected

Definition at line 301 of file DrawWriter.h.

301 {
302 SkASSERT(count > 0);
303 this->reserve(count);
304
305 const size_t size = count * fStride;
307 // If the GPU mapped buffer failed, ensure we have a sufficiently large CPU address to
308 // write to so that RenderSteps don't have to worry about error handling. The Recording
309 // will fail since the map failure is tracked by BufferManager.
310 return VertexWriter(fDrawer.fFailureStorage.reset(size, SkAutoMalloc::kReuse_OnShrink),
311 size);
312 }
313
316 fDrawer.fPendingCount += count;
317 return std::exchange(fNextWriter, fNextWriter.makeOffset(size));
318 }
int count
Definition: FontMgrTest.cpp:50
#define SK_UNLIKELY
Definition: SkAssert.h:28
void * reset(size_t size=0, OnShrink shrink=kAlloc_OnShrink)
Definition: SkAutoMalloc.h:53
void reserve(unsigned int count)
Definition: DrawWriter.h:274
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
VertexWriter makeOffset(size_t offsetInBytes) const
Definition: BufferWriter.h:142

◆ onFlush()

virtual void skgpu::graphite::DrawWriter::Appender::onFlush ( )
inlineprotectedvirtual

Definition at line 272 of file DrawWriter.h.

272{}

◆ reserve()

void skgpu::graphite::DrawWriter::Appender::reserve ( unsigned int  count)
inlineprotected

Definition at line 274 of file DrawWriter.h.

274 {
275 if (fReservedCount >= count) {
276 return;
277 } else if (fReservedCount > 0) {
278 // Have contiguous bytes that can't satisfy request, so return them in the event the
279 // DBM has additional contiguous bytes after the prior reserved range.
281 }
282
284 // NOTE: Cannot bind tuple directly to fNextWriter, compilers don't produce the right
285 // move assignment.
286 auto [writer, reservedChunk] = fDrawer.fManager->getVertexWriter(count * fStride);
287 if (reservedChunk.fBuffer != fTarget.fBuffer ||
288 reservedChunk.fOffset !=
289 (fTarget.fOffset + (fDrawer.fPendingBase + fDrawer.fPendingCount) * fStride)) {
290 // Not contiguous, so flush and update binding to 'reservedChunk'
291 this->onFlush();
292 fDrawer.flush();
293
294 fTarget = reservedChunk;
295 fDrawer.fPendingBase = 0;
296 fDrawer.fPendingBufferBinds = true;
297 }
298 fNextWriter = std::move(writer);
299 }
std::pair< VertexWriter, BindBufferInfo > getVertexWriter(size_t requiredBytes)

Member Data Documentation

◆ fDrawer

DrawWriter& skgpu::graphite::DrawWriter::Appender::fDrawer
protected

Definition at line 265 of file DrawWriter.h.

◆ fNextWriter

VertexWriter skgpu::graphite::DrawWriter::Appender::fNextWriter
protected

Definition at line 270 of file DrawWriter.h.

◆ fReservedCount

unsigned int skgpu::graphite::DrawWriter::Appender::fReservedCount
protected

Definition at line 269 of file DrawWriter.h.

◆ fStride

size_t skgpu::graphite::DrawWriter::Appender::fStride
protected

Definition at line 267 of file DrawWriter.h.

◆ fTarget

BindBufferInfo& skgpu::graphite::DrawWriter::Appender::fTarget
protected

Definition at line 266 of file DrawWriter.h.


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