Plan stroke preview composite sequence
This commit is contained in:
@@ -1264,6 +1264,52 @@ CanvasStrokeMaterialPlan plan_canvas_stroke_material(CanvasStrokeMaterialRequest
|
||||
return plan;
|
||||
}
|
||||
|
||||
StrokePreviewCompositePlan plan_stroke_preview_composite(StrokePreviewCompositeRequest request) noexcept
|
||||
{
|
||||
StrokePreviewCompositePlan plan;
|
||||
plan.uses_mixer = request.uses_mixer;
|
||||
plan.uses_dual = request.uses_dual;
|
||||
plan.uses_pattern = request.uses_pattern;
|
||||
|
||||
auto append_step = [&plan](StrokePreviewCompositeStep step) noexcept {
|
||||
if (plan.step_count >= plan.steps.size()) {
|
||||
return;
|
||||
}
|
||||
plan.steps[plan.step_count] = step;
|
||||
++plan.step_count;
|
||||
};
|
||||
auto bind = [&plan](StrokePreviewTextureRole role, std::uint8_t slot) noexcept {
|
||||
if (plan.texture_slot_count >= plan.texture_slots.size()) {
|
||||
return;
|
||||
}
|
||||
plan.texture_slots[plan.texture_slot_count] = StrokePreviewTextureSlotPlan {
|
||||
.role = role,
|
||||
.slot = slot,
|
||||
};
|
||||
++plan.texture_slot_count;
|
||||
};
|
||||
|
||||
append_step(StrokePreviewCompositeStep::checkerboard_background);
|
||||
append_step(StrokePreviewCompositeStep::capture_background_texture);
|
||||
append_step(StrokePreviewCompositeStep::bind_final_composite_inputs);
|
||||
append_step(StrokePreviewCompositeStep::final_composite_draw);
|
||||
append_step(StrokePreviewCompositeStep::copy_preview_texture);
|
||||
|
||||
bind(StrokePreviewTextureRole::background, 0);
|
||||
bind(StrokePreviewTextureRole::stroke, 1);
|
||||
if (request.uses_dual) {
|
||||
bind(StrokePreviewTextureRole::dual, 3);
|
||||
}
|
||||
if (request.uses_pattern) {
|
||||
bind(StrokePreviewTextureRole::pattern, 4);
|
||||
}
|
||||
if (request.uses_mixer) {
|
||||
bind(StrokePreviewTextureRole::mixer, 3);
|
||||
}
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
pp::foundation::Result<CanvasBlendGatePlan> plan_canvas_blend_gate(
|
||||
pp::renderer::RenderDeviceFeatures features,
|
||||
CanvasBlendGateRequest request) noexcept
|
||||
|
||||
@@ -109,6 +109,44 @@ struct CanvasStrokeMaterialPlan {
|
||||
std::size_t texture_binding_count = 0;
|
||||
};
|
||||
|
||||
enum class StrokePreviewCompositeStep : std::uint8_t {
|
||||
checkerboard_background,
|
||||
capture_background_texture,
|
||||
bind_final_composite_inputs,
|
||||
final_composite_draw,
|
||||
copy_preview_texture,
|
||||
};
|
||||
|
||||
enum class StrokePreviewTextureRole : std::uint8_t {
|
||||
background,
|
||||
stroke,
|
||||
mask,
|
||||
dual,
|
||||
pattern,
|
||||
mixer,
|
||||
};
|
||||
|
||||
struct StrokePreviewTextureSlotPlan {
|
||||
StrokePreviewTextureRole role = StrokePreviewTextureRole::background;
|
||||
std::uint8_t slot = 0;
|
||||
};
|
||||
|
||||
struct StrokePreviewCompositeRequest {
|
||||
bool uses_mixer = false;
|
||||
bool uses_dual = false;
|
||||
bool uses_pattern = false;
|
||||
};
|
||||
|
||||
struct StrokePreviewCompositePlan {
|
||||
std::array<StrokePreviewCompositeStep, 5> steps {};
|
||||
std::size_t step_count = 0;
|
||||
std::array<StrokePreviewTextureSlotPlan, 5> texture_slots {};
|
||||
std::size_t texture_slot_count = 0;
|
||||
bool uses_mixer = false;
|
||||
bool uses_dual = false;
|
||||
bool uses_pattern = false;
|
||||
};
|
||||
|
||||
struct CanvasBlendGateRequest {
|
||||
pp::renderer::Extent2D extent {};
|
||||
std::span<const int> layer_blend_modes;
|
||||
@@ -440,6 +478,9 @@ export_document_animation_frames_equirectangular_pngs(
|
||||
[[nodiscard]] CanvasStrokeMaterialPlan plan_canvas_stroke_material(
|
||||
CanvasStrokeMaterialRequest request) noexcept;
|
||||
|
||||
[[nodiscard]] StrokePreviewCompositePlan plan_stroke_preview_composite(
|
||||
StrokePreviewCompositeRequest request) noexcept;
|
||||
|
||||
[[nodiscard]] pp::foundation::Result<CanvasBlendGatePlan> plan_canvas_blend_gate(
|
||||
pp::renderer::RenderDeviceFeatures features,
|
||||
CanvasBlendGateRequest request) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user