Plan stroke commit sequencing
This commit is contained in:
@@ -1445,6 +1445,55 @@ pp::foundation::Result<CanvasStrokeRasterizationPlan> plan_canvas_stroke_rasteri
|
||||
return pp::foundation::Result<CanvasStrokeRasterizationPlan>::success(plan);
|
||||
}
|
||||
|
||||
CanvasStrokeCommitSequencePlan plan_canvas_stroke_commit_sequence(CanvasStrokeCommitRequest request) noexcept
|
||||
{
|
||||
CanvasStrokeCommitSequencePlan plan;
|
||||
plan.erase_mode = request.erase_mode;
|
||||
plan.alpha_locked = request.alpha_locked;
|
||||
plan.selection_mask_active = request.selection_mask_active;
|
||||
plan.uses_dual_stroke = !request.erase_mode && request.dual_stroke_enabled;
|
||||
plan.uses_pattern = !request.erase_mode && request.pattern_enabled;
|
||||
plan.updates_layer_bounds = !request.alpha_locked;
|
||||
|
||||
auto append_step = [&plan](CanvasStrokeCommitStep step) noexcept {
|
||||
if (plan.step_count >= plan.steps.size()) {
|
||||
return;
|
||||
}
|
||||
plan.steps[plan.step_count] = step;
|
||||
++plan.step_count;
|
||||
};
|
||||
auto bind = [&plan](CanvasStrokeCommitTextureRole role, std::uint8_t slot) noexcept {
|
||||
if (plan.texture_binding_count >= plan.texture_bindings.size()) {
|
||||
return;
|
||||
}
|
||||
plan.texture_bindings[plan.texture_binding_count] = CanvasStrokeCommitTextureBindingPlan {
|
||||
.role = role,
|
||||
.slot = slot,
|
||||
};
|
||||
++plan.texture_binding_count;
|
||||
};
|
||||
|
||||
append_step(CanvasStrokeCommitStep::readback_history_region);
|
||||
append_step(CanvasStrokeCommitStep::update_layer_dirty_state);
|
||||
append_step(CanvasStrokeCommitStep::copy_layer_rtt_to_scratch);
|
||||
append_step(CanvasStrokeCommitStep::bind_commit_inputs);
|
||||
append_step(request.erase_mode ? CanvasStrokeCommitStep::erase_draw : CanvasStrokeCommitStep::composite_draw);
|
||||
append_step(CanvasStrokeCommitStep::copy_committed_rtt_to_scratch);
|
||||
append_step(CanvasStrokeCommitStep::dilate_edges_draw);
|
||||
|
||||
bind(CanvasStrokeCommitTextureRole::layer_scratch, 0);
|
||||
bind(CanvasStrokeCommitTextureRole::stroke, 1);
|
||||
bind(CanvasStrokeCommitTextureRole::selection_mask, 2);
|
||||
if (plan.uses_dual_stroke) {
|
||||
bind(CanvasStrokeCommitTextureRole::dual_stroke, 3);
|
||||
}
|
||||
if (plan.uses_pattern) {
|
||||
bind(CanvasStrokeCommitTextureRole::pattern, 4);
|
||||
}
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
CanvasStrokeSampleBoundsPlan plan_canvas_stroke_sample_bounds(
|
||||
CanvasStrokeSampleBoundsRequest request) noexcept
|
||||
{
|
||||
|
||||
@@ -187,6 +187,55 @@ struct CanvasStrokeRasterizationPlan {
|
||||
bool compatibility_fallback = false;
|
||||
};
|
||||
|
||||
enum class CanvasStrokeCommitStep : std::uint8_t {
|
||||
readback_history_region,
|
||||
update_layer_dirty_state,
|
||||
copy_layer_rtt_to_scratch,
|
||||
bind_commit_inputs,
|
||||
erase_draw,
|
||||
composite_draw,
|
||||
copy_committed_rtt_to_scratch,
|
||||
dilate_edges_draw,
|
||||
};
|
||||
|
||||
enum class CanvasStrokeCommitTextureRole : std::uint8_t {
|
||||
layer_scratch,
|
||||
stroke,
|
||||
selection_mask,
|
||||
dual_stroke,
|
||||
pattern,
|
||||
};
|
||||
|
||||
struct CanvasStrokeCommitTextureBindingPlan {
|
||||
CanvasStrokeCommitTextureRole role = CanvasStrokeCommitTextureRole::layer_scratch;
|
||||
std::uint8_t slot = 0;
|
||||
};
|
||||
|
||||
struct CanvasStrokeCommitRequest {
|
||||
bool erase_mode = false;
|
||||
bool alpha_locked = false;
|
||||
bool selection_mask_active = false;
|
||||
bool dual_stroke_enabled = false;
|
||||
bool pattern_enabled = false;
|
||||
};
|
||||
|
||||
struct CanvasStrokeCommitSequencePlan {
|
||||
std::array<CanvasStrokeCommitStep, 8> steps {};
|
||||
std::size_t step_count = 0;
|
||||
std::array<CanvasStrokeCommitTextureBindingPlan, 5> texture_bindings {};
|
||||
std::size_t texture_binding_count = 0;
|
||||
bool erase_mode = false;
|
||||
bool alpha_locked = false;
|
||||
bool selection_mask_active = false;
|
||||
bool uses_dual_stroke = false;
|
||||
bool uses_pattern = false;
|
||||
bool requires_history_readback = true;
|
||||
bool updates_layer_bounds = true;
|
||||
bool requires_layer_scratch_copy = true;
|
||||
bool requires_committed_scratch_copy = true;
|
||||
bool requires_dilate = true;
|
||||
};
|
||||
|
||||
struct CanvasStrokePoint {
|
||||
float x = 0.0F;
|
||||
float y = 0.0F;
|
||||
@@ -493,6 +542,9 @@ export_document_animation_frames_equirectangular_pngs(
|
||||
pp::renderer::RenderDeviceFeatures features,
|
||||
pp::renderer::Extent2D extent) noexcept;
|
||||
|
||||
[[nodiscard]] CanvasStrokeCommitSequencePlan plan_canvas_stroke_commit_sequence(
|
||||
CanvasStrokeCommitRequest request) noexcept;
|
||||
|
||||
[[nodiscard]] CanvasStrokeSampleBoundsPlan plan_canvas_stroke_sample_bounds(
|
||||
CanvasStrokeSampleBoundsRequest request) noexcept;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user