32BufferView new_scratch_slice(ScratchBuffer& scratch) {
33 size_t size = scratch.size();
34 BindBufferInfo
info = scratch.suballocate(
size);
38BufferView new_indirect_slice(DrawBufferManager* mgr,
size_t size) {
43::rust::Slice<uint8_t> to_slice(
void* ptr,
size_t size) {
44 return {
static_cast<uint8_t*
>(ptr),
size};
47vello_cpp::Affine to_vello_affine(
const SkMatrix&
m) {
50 return {{
m.get(0),
m.get(3),
m.get(1),
m.get(4),
m.get(2),
m.get(5)}};
65WorkgroupSize to_wg_size(
const vello_cpp::WorkgroupSize&
src) {
66 return WorkgroupSize(
src.x,
src.y,
src.z);
76 return vello_cpp::Fill::NonZero;
79 return vello_cpp::Fill::EvenOdd;
81 return vello_cpp::Fill::NonZero;
86 case SkPaint::Cap::kButt_Cap:
87 return vello_cpp::CapStyle::Butt;
88 case SkPaint::Cap::kRound_Cap:
89 return vello_cpp::CapStyle::Round;
90 case SkPaint::Cap::kSquare_Cap:
91 return vello_cpp::CapStyle::Square;
98 case SkPaint::Join::kMiter_Join:
99 return vello_cpp::JoinStyle::Miter;
100 case SkPaint::Join::kBevel_Join:
101 return vello_cpp::JoinStyle::Bevel;
102 case SkPaint::Join::kRound_Join:
103 return vello_cpp::JoinStyle::Round;
108vello_cpp::Stroke to_stroke(
const SkStrokeRec& style) {
109 return vello_cpp::Stroke{
112 to_cap_style(style.
getCap()),
113 to_join_style(style.
getJoin()),
122 bool next_element(vello_cpp::PathElement* outElem)
override {
123 if (fConicQuadIdx < fConicConverter.
countQuads()) {
125 outElem->verb = vello_cpp::PathVerb::QuadTo;
126 int pointIdx = fConicQuadIdx * 2;
127 outElem->points[0] = to_vello_point(fConicQuads[pointIdx]);
128 outElem->points[1] = to_vello_point(fConicQuads[pointIdx + 1]);
129 outElem->points[2] = to_vello_point(fConicQuads[pointIdx + 2]);
145 outElem->points[0] = to_vello_point(
points[0]);
149 outElem->points[0] = to_vello_point(
points[0]);
150 outElem->points[1] = to_vello_point(
points[1]);
159 points, *weights, 0.25 / fTransform.maxScaleFactor());
160 outElem->verb = vello_cpp::PathVerb::QuadTo;
161 outElem->points[0] = to_vello_point(fConicQuads[0]);
162 outElem->points[1] = to_vello_point(fConicQuads[1]);
163 outElem->points[2] = to_vello_point(fConicQuads[2]);
170 outElem->verb = vello_cpp::PathVerb::QuadTo;
171 outElem->points[0] = to_vello_point(
points[0]);
172 outElem->points[1] = to_vello_point(
points[1]);
173 outElem->points[2] = to_vello_point(
points[2]);
176 outElem->verb = vello_cpp::PathVerb::CurveTo;
177 outElem->points[0] = to_vello_point(
points[0]);
178 outElem->points[1] = to_vello_point(
points[1]);
179 outElem->points[2] = to_vello_point(
points[2]);
180 outElem->points[3] = to_vello_point(
points[3]);
198 const SkPoint* fConicQuads =
nullptr;
199 int fConicQuadIdx = 0;
214 PathIter iter(shape, t);
215 fEncoding->fill(to_fill_type(fillType),
217 {vello_cpp::BrushKind::Solid, {to_vello_color(fillColor)}},
227 PathIter iter(shape, t);
228 vello_cpp::Brush brush{vello_cpp::BrushKind::Solid, {to_vello_color(fillColor)}};
229 fEncoding->stroke(to_stroke(style), to_vello_affine(t), brush, iter);
233 PathIter iter(shape, t);
234 fEncoding->begin_clip(to_vello_affine(t), iter);
240 fEncoding->end_clip();
245 fEncoding->append(*other.fEncoding);
250 fFineArea = std::make_unique<VelloFineAreaAlpha8Step>();
251 fFineMsaa16 = std::make_unique<VelloFineMsaa16Alpha8Step>();
252 fFineMsaa8 = std::make_unique<VelloFineMsaa8Alpha8Step>();
254 fFineArea = std::make_unique<VelloFineAreaStep>();
255 fFineMsaa16 = std::make_unique<VelloFineMsaa16Step>();
256 fFineMsaa8 = std::make_unique<VelloFineMsaa8Step>();
269 if (scene.fEncoding->is_empty()) {
281 SKGPU_LOG_W(
"VelloRenderer: cannot render to an empty target");
286 auto config = scene.fEncoding->prepare_render(
289 to_vello_color(
params.fBaseColor));
290 auto dispatchInfo = config->workgroup_counts();
291 auto bufferSizes = config->buffer_sizes();
300 size_t uboSize = config->config_uniform_buffer_size();
302 if (!uboPtr || !config->write_config_uniform_buffer(to_slice(uboPtr, uboSize))) {
306 size_t sceneSize = config->scene_buffer_size();
308 if (!scenePtr || !config->write_scene_buffer(to_slice(scenePtr, sceneSize))) {
324 const size_t lines_size = bufferSizes.lines;
325 const size_t bin_data_size = bufferSizes.bin_data;
326 const size_t tiles_size = bufferSizes.tiles;
327 const size_t segments_size = bufferSizes.segments;
328 const size_t seg_counts_size = bufferSizes.seg_counts;
329 const size_t ptcl_size = bufferSizes.ptcl;
346 builder.assignSharedBuffer(new_scratch_slice(pathtagReduceOutput),
349 builder.appendStep(&fPathtagReduce, to_wg_size(dispatchInfo.path_reduce));
356 if (dispatchInfo.use_large_path_scan) {
360 builder.assignSharedBuffer(new_scratch_slice(reduced2),
362 builder.assignSharedBuffer(new_scratch_slice(reducedScan),
365 builder.appendStep(&fPathtagReduce2, to_wg_size(dispatchInfo.path_reduce2));
366 builder.appendStep(&fPathtagScan1, to_wg_size(dispatchInfo.path_scan1));
367 builder.appendStep(&fPathtagScanLarge, to_wg_size(dispatchInfo.path_scan));
369 builder.appendStep(&fPathtagScanSmall, to_wg_size(dispatchInfo.path_scan));
376 builder.appendStep(&fBboxClear, to_wg_size(dispatchInfo.bbox_clear));
381 builder.appendStep(&fFlatten, to_wg_size(dispatchInfo.flatten));
388 builder.appendStep(&fDrawReduce, to_wg_size(dispatchInfo.draw_reduce));
398 builder.appendStep(&fDrawLeaf, to_wg_size(dispatchInfo.draw_leaf));
407 WorkgroupSize clipReduceWgCount = to_wg_size(dispatchInfo.clip_reduce);
408 WorkgroupSize clipLeafWgCount = to_wg_size(dispatchInfo.clip_leaf);
409 bool doClipReduce = clipReduceWgCount.
scalarSize() > 0u;
410 bool doClipLeaf = clipLeafWgCount.
scalarSize() > 0u;
411 if (doClipReduce || doClipLeaf) {
417 builder.appendStep(&fClipReduce, clipReduceWgCount);
420 builder.appendStep(&fClipLeaf, clipLeafWgCount);
431 builder.appendStep(&fBinning, to_wg_size(dispatchInfo.binning));
441 builder.appendStep(&fTileAlloc, to_wg_size(dispatchInfo.tile_alloc));
446 auto indirectCountBuffer = new_indirect_slice(bufMgr, bufferSizes.indirect_count);
448 builder.appendStep(&fPathCountSetup, to_wg_size(dispatchInfo.path_count_setup));
457 builder.appendStepIndirect(&fPathCount, indirectCountBuffer);
460 builder.appendStep(&fBackdrop, to_wg_size(dispatchInfo.backdrop));
464 builder.appendStep(&fCoarse, to_wg_size(dispatchInfo.coarse));
467 builder.appendStep(&fPathTilingSetup, to_wg_size(dispatchInfo.path_tiling_setup));
471 builder.appendStepIndirect(&fPathTiling, indirectCountBuffer);
476 switch (
params.fAaConfig) {
478 fineVariant = fFineArea.get();
481 fineVariant = fFineMsaa16.get();
484 fineVariant = fFineMsaa8.get();
488 builder.appendStep(fineVariant, to_wg_size(dispatchInfo.fine));
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static const int points[]
std::unique_ptr< SkLatticeIter > fIter
#define SKGPU_LOG_W(fmt,...)
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
#define SkColorGetR(color)
#define SkColorGetG(color)
#define SkColorGetA(color)
#define SkColorGetB(color)
@ kClose
SkPath::RawIter returns 0 points.
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
const SkPoint * computeQuads(const SkConic &conic, SkScalar tol)
SkPath::RangeIter RangeIter
SkScalar getWidth() const
SkPaint::Join getJoin() const
SkPaint::Cap getCap() const
SkScalar getMiter() const
ScratchBuffer getScratchStorage(size_t requiredBytes)
std::pair< void *, BindBufferInfo > getUniformPointer(size_t requiredBytes)
std::pair< void *, BindBufferInfo > getStoragePointer(size_t requiredBytes)
DrawBufferManager * drawBufferManager()
std::unique_ptr< DispatchGroup > renderScene(const RenderParams &, const VelloScene &, sk_sp< TextureProxy > target, Recorder *) const
VelloRenderer(const Caps *)
void pushClipLayer(const SkPath &shape, const Transform &transform)
void append(const VelloScene &other)
void solidStroke(const SkPath &, const SkColor4f &, const SkStrokeRec &, const Transform &transform)
void solidFill(const SkPath &, const SkColor4f &, const SkPathFillType, const Transform &transform)
static const char * begin(const StringSlice &s)
const EmbeddedViewParams * params
static float min(float r, float g, float b)
SK_API sk_sp< SkShader > Color(SkColor)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
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
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
void Close(PathBuilder *builder)
constexpr int kVelloSlot_DrawBBoxes
constexpr int kVelloSlot_Lines
SkColorType ComputeShaderCoverageMaskTargetFormat(const Caps *caps)
constexpr int kVelloSlot_LargePathtagScanFirstPassOutput
constexpr int kVelloSlot_BinHeader
constexpr int kVelloSlot_SegmentCounts
constexpr int kVelloSlot_ClipBicyclic
constexpr int kVelloSlot_Scene
constexpr int kVelloSlot_ConfigUniform
constexpr int kVelloSlot_ClipInput
constexpr int kVelloSlot_IndirectCount
constexpr int kVelloSlot_DrawReduceOutput
constexpr int kVelloSlot_LargePathtagReduceSecondPassOutput
constexpr int kVelloSlot_TagMonoid
constexpr int kVelloSlot_Segments
constexpr int kVelloSlot_InfoBinData
constexpr int kVelloSlot_ClipElement
constexpr int kVelloSlot_PathBBoxes
constexpr int kVelloSlot_Path
constexpr int kVelloSlot_OutputImage
constexpr int kVelloSlot_Tile
constexpr int kVelloSlot_PathtagReduceOutput
constexpr int kVelloSlot_PTCL
constexpr int kVelloSlot_ClipBBoxes
constexpr int kVelloSlot_DrawMonoid
constexpr int kVelloSlot_BumpAlloc
skgpu::graphite::Transform Transform
constexpr struct @263 tiles[]
static SkString join(const CommandLineFlags::StringArray &)
uint32_t scalarSize() const
#define TRACE_EVENT0(category_group, name)