Extract menu, stylus, and canvas draw helpers

This commit is contained in:
2026-06-16 11:25:09 +02:00
parent d135835787
commit 18665bdffc
10 changed files with 510 additions and 361 deletions

View File

@@ -130,6 +130,14 @@ struct LegacyCanvasDrawMergeLayerPathExecution {
std::function<void(int, float)> draw_frame;
};
struct LegacyCanvasDrawLayerVisit {
size_t layer_index = 0;
int plane_index = 0;
int z = 0;
int first_frame = 0;
int last_frame = 0;
};
struct LegacyCanvasDrawMergeTemporaryCompositeExecution {
std::function<void()> setup;
std::function<void()> bind_samplers;
@@ -671,6 +679,39 @@ inline void execute_legacy_canvas_draw_merge_layer_path(
execution.draw_debug_outline();
}
template <typename PlanOnionRange, typename ShouldDrawPlane, typename VisitLayerPlane, typename LogOnionRangeFailure>
inline void execute_legacy_canvas_draw_layer_traversal(
size_t layer_count,
PlanOnionRange&& plan_onion_range,
ShouldDrawPlane&& should_draw_plane,
VisitLayerPlane&& visit_layer_plane,
LogOnionRangeFailure&& log_onion_range_failure)
{
for (size_t i = 0; i < layer_count; ++i) {
const auto layer_index = i;
const auto onion_range_result = plan_onion_range(layer_index);
if (!onion_range_result) {
log_onion_range_failure(onion_range_result.status().message);
continue;
}
const auto onion_range = onion_range_result.value();
for (int plane_index = 0; plane_index < 6; ++plane_index) {
if (!should_draw_plane(layer_index, plane_index, onion_range.first_frame, onion_range.last_frame)) {
continue;
}
visit_layer_plane(LegacyCanvasDrawLayerVisit {
.layer_index = layer_index,
.plane_index = plane_index,
.z = static_cast<int>(layer_count - i),
.first_frame = onion_range.first_frame,
.last_frame = onion_range.last_frame,
}, onion_range);
}
}
}
inline void execute_legacy_canvas_draw_merge_temporary_composite(
const LegacyCanvasDrawMergeTemporaryCompositeExecution& execution)
{