Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
skgpu::graphite::DrawList Class Reference

#include <DrawList.h>

Classes

struct  Draw
 

Public Member Functions

void recordDraw (const Renderer *renderer, const Transform &localToDevice, const Geometry &geometry, const Clip &clip, DrawOrder ordering, const PaintParams *paint, const StrokeStyle *stroke)
 
int renderStepCount () const
 
const RectdstCopyBounds () const
 
const TransformdeduplicateTransform (const Transform &)
 

Public Attributes

SkTBlockList< Transform, 16 > fTransforms {SkBlockAllocator::GrowthPolicy::kFibonacci}
 
SkTBlockList< Draw, 16 > fDraws {SkBlockAllocator::GrowthPolicy::kFibonacci}
 
int fRenderStepCount = 0
 
Rect fDstCopyBounds = Rect::InfiniteInverted()
 

Static Public Attributes

static constexpr int kMaxRenderSteps = 4096
 

Detailed Description

A DrawList represents a collection of drawing commands (and related clip/shading state) in a form that closely mirrors what can be rendered efficiently and directly by the GPU backend (while balancing how much pre-processing to do for draws that might get eliminated later due to occlusion culling).

A draw command combines:

Commands are accumulated in an arbitrary order and then sorted by increasing sort z when the list is prepared into an actual command buffer. The result of a draw command is the rasterization of the transformed shape, restricted by its primitive clip (e.g. a scissor rect) and a depth test of "GREATER" vs. its write/test z. (A test of GREATER, as opposed to GEQUAL, avoids double hits for draws that may have overlapping geometry, e.g. stroking.) If the command has a shading description, the color buffer will be modified; if not, it will be a depth-only draw.

In addition to sorting the collected commands, the command list can be optimized during preparation. Commands that are fully occluded by later operations can be skipped entirely without affecting the final results. Adjacent commands (post sort) that would use equivalent GPU pipelines are merged to produce fewer (but larger) operations on the GPU.

Other than flush-time optimizations (sort, cull, and merge), the command list does what you tell it to. Draw-specific simplification, style application, and advanced clipping should be handled at a higher layer.

Definition at line 57 of file DrawList.h.

Member Function Documentation

◆ deduplicateTransform()

const Transform & skgpu::graphite::DrawList::deduplicateTransform ( const Transform localToDevice)

Definition at line 16 of file DrawList.cpp.

16 {
17 // TODO: This is a pretty simple deduplication strategy and doesn't take advantage of the stack
18 // knowledge that Device has.
19 if (fTransforms.empty() || fTransforms.back() != localToDevice) {
20 fTransforms.push_back(localToDevice);
21 }
22 return fTransforms.back();
23}
SkTBlockList< Transform, 16 > fTransforms
Definition DrawList.h:110

◆ dstCopyBounds()

const Rect & skgpu::graphite::DrawList::dstCopyBounds ( ) const
inline

Definition at line 87 of file DrawList.h.

87{ return fDstCopyBounds; }

◆ recordDraw()

void skgpu::graphite::DrawList::recordDraw ( const Renderer renderer,
const Transform localToDevice,
const Geometry geometry,
const Clip clip,
DrawOrder  ordering,
const PaintParams paint,
const StrokeStyle stroke 
)

Definition at line 25 of file DrawList.cpp.

31 {
32 SkASSERT(localToDevice.valid());
33 SkASSERT(!geometry.isEmpty() && !clip.drawBounds().isEmptyNegativeOrNaN());
34 SkASSERT(!(renderer->depthStencilFlags() & DepthStencilFlags::kStencil) ||
35 ordering.stencilIndex() != DrawOrder::kUnassigned);
36
37 // TODO: Add validation that the renderer's expected shape type and stroke params match provided
38
39 fDraws.emplace_back(renderer, this->deduplicateTransform(localToDevice),
40 geometry, clip, ordering, paint, stroke);
41 fRenderStepCount += renderer->numRenderSteps();
42
43#if defined(SK_DEBUG)
44 if (geometry.isCoverageMaskShape()) {
45 fCoverageMaskShapeDrawCount++;
46 }
47#endif
48
49 if (paint && paint->dstReadRequirement() == DstReadRequirement::kTextureCopy) {
50 fDstCopyBounds.join(clip.drawBounds());
51 }
52}
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
const Transform & deduplicateTransform(const Transform &)
Definition DrawList.cpp:16
SkTBlockList< Draw, 16 > fDraws
Definition DrawList.h:111
static constexpr DisjointStencilIndex kUnassigned
Definition DrawOrder.h:115
AI Rect & join(Rect rect)
Definition Rect.h:150
const Paint & paint

◆ renderStepCount()

int skgpu::graphite::DrawList::renderStepCount ( ) const
inline

Definition at line 84 of file DrawList.h.

84{ return fRenderStepCount; }

Member Data Documentation

◆ fDraws

SkTBlockList<Draw, 16> skgpu::graphite::DrawList::fDraws {SkBlockAllocator::GrowthPolicy::kFibonacci}

Definition at line 111 of file DrawList.h.

111{SkBlockAllocator::GrowthPolicy::kFibonacci};

◆ fDstCopyBounds

Rect skgpu::graphite::DrawList::fDstCopyBounds = Rect::InfiniteInverted()

Definition at line 121 of file DrawList.h.

◆ fRenderStepCount

int skgpu::graphite::DrawList::fRenderStepCount = 0

Definition at line 114 of file DrawList.h.

◆ fTransforms

SkTBlockList<Transform, 16> skgpu::graphite::DrawList::fTransforms {SkBlockAllocator::GrowthPolicy::kFibonacci}

Definition at line 110 of file DrawList.h.

110{SkBlockAllocator::GrowthPolicy::kFibonacci};

◆ kMaxRenderSteps

constexpr int skgpu::graphite::DrawList::kMaxRenderSteps = 4096
staticconstexpr

Definition at line 68 of file DrawList.h.


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