Extract draw toolbar and thin NodeCanvas and Win32 shell

This commit is contained in:
2026-06-16 13:37:08 +02:00
parent 8ea56cbd30
commit 9c33ecc22b
10 changed files with 285 additions and 186 deletions

View File

@@ -1,5 +1,7 @@
#pragma once
#include "app.h"
#include "app_core/document_animation.h"
#include "legacy_canvas_stroke_composite_services.h"
#include "legacy_canvas_stroke_erase_services.h"
#include "shader.h"
@@ -988,6 +990,128 @@ inline void execute_legacy_canvas_draw_unmerged_shell(
}
}
template <
typename MakeLayerPathExecution,
typename ShouldDrawTemporaryErase,
typename ShouldDrawTemporaryPaint,
typename FrameAlpha>
inline void execute_legacy_canvas_draw_unmerged_layer_path(
const LegacyCanvasDrawLayerVisit& visit,
const auto& onion_range,
bool use_blend,
const glm::mat4& proj,
const glm::mat4& camera,
const glm::mat4& orientation,
const auto& plane_transform,
MakeLayerPathExecution&& make_layer_path_execution,
ShouldDrawTemporaryErase&& should_draw_temporary_erase,
ShouldDrawTemporaryPaint&& should_draw_temporary_paint,
FrameAlpha&& frame_alpha)
{
const auto plane_index = visit.plane_index;
const auto plane_mvp_z = proj * camera *
glm::scale(glm::vec3(visit.z + 1)) *
orientation *
plane_transform[plane_index] *
glm::translate(glm::vec3(0, 0, -1));
const auto layer_path_execution = make_layer_path_execution(visit.layer_index, plane_index, plane_mvp_z);
execute_legacy_canvas_draw_merge_layer_path(
should_draw_temporary_erase(visit),
should_draw_temporary_paint(visit),
use_blend,
visit.first_frame,
visit.last_frame,
[&](int frame) {
return frame_alpha(onion_range, frame);
},
layer_path_execution);
}
template <
typename NodeCanvasT,
typename PrepareBlendCache,
typename DrawBackground,
typename ConfigureBlendState,
typename DisableDepthTest,
typename MakeLayerPathExecution,
typename LogOnionRangeFailure,
typename CompositeBlendCache>
inline void execute_legacy_canvas_draw_unmerged_node_canvas_shell(
NodeCanvasT& node_canvas,
bool use_blend,
const glm::mat4& proj,
const glm::mat4& camera,
const glm::mat4& orientation,
PrepareBlendCache&& prepare_blend_cache,
DrawBackground&& draw_background,
ConfigureBlendState&& configure_blend_state,
DisableDepthTest&& disable_depth_test,
MakeLayerPathExecution&& make_layer_path_execution,
LogOnionRangeFailure&& log_onion_range_failure,
CompositeBlendCache&& composite_blend_cache)
{
if (use_blend) {
prepare_blend_cache();
}
draw_background();
configure_blend_state(use_blend);
disable_depth_test();
const auto plan_onion_range = [&](size_t layer_index) {
return pp::app::plan_animation_onion_frame_range(
node_canvas.m_canvas->m_layers[layer_index]->frames_count(),
node_canvas.m_canvas->m_layers[layer_index]->m_frame_index,
App::I->animation->get_onion_size());
};
const auto should_draw_plane = [&](size_t layer_index, int plane_index, int first_frame, int last_frame) {
bool faces = false;
for (int frame = first_frame; frame <= last_frame; ++frame) {
faces |= node_canvas.m_canvas->m_layers[layer_index]->face(plane_index, frame);
}
if (node_canvas.m_canvas->m_show_tmp && node_canvas.m_canvas->m_current_layer_idx == layer_index) {
return true;
}
return node_canvas.m_canvas->m_layers[layer_index]->m_visible &&
node_canvas.m_canvas->m_layers[layer_index]->m_opacity != .0f &&
faces;
};
execute_legacy_canvas_draw_layer_traversal(
node_canvas.m_canvas->m_layers.size(),
plan_onion_range,
should_draw_plane,
[&](const LegacyCanvasDrawLayerVisit& visit, const auto& onion_range) {
execute_legacy_canvas_draw_unmerged_layer_path(
visit,
onion_range,
use_blend,
proj,
camera,
orientation,
node_canvas.m_canvas->m_plane_transform,
make_layer_path_execution,
[&](const LegacyCanvasDrawLayerVisit& visit) {
return node_canvas.m_canvas->m_current_stroke && node_canvas.m_canvas->m_current_mode == kCanvasMode::Erase && node_canvas.m_canvas->m_show_tmp && node_canvas.m_canvas->m_current_layer_idx == visit.layer_index;
},
[&](const LegacyCanvasDrawLayerVisit& visit) {
return node_canvas.m_canvas->m_current_stroke && node_canvas.m_canvas->m_show_tmp && node_canvas.m_canvas->m_current_layer_idx == visit.layer_index;
},
[&](const auto& onion_range, int frame) {
return pp::app::animation_onion_frame_alpha(onion_range, frame);
});
},
std::forward<LogOnionRangeFailure>(log_onion_range_failure));
if (use_blend) {
composite_blend_cache();
}
}
inline void execute_legacy_canvas_draw_merge_plane_setup(
const LegacyCanvasDrawMergePlaneSetupUniforms& uniforms,
const LegacyCanvasDrawMergePlaneSetupExecution& execution)