Extract layout bootstrap and thin NodeCanvas startup shells
This commit is contained in:
@@ -1112,6 +1112,99 @@ inline void execute_legacy_canvas_draw_unmerged_node_canvas_shell(
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename PrepareDensityRenderTarget,
|
||||
typename PrepareStandardRenderTarget,
|
||||
typename DrawMergedPass,
|
||||
typename DrawUnmergedPass>
|
||||
inline void execute_legacy_canvas_draw_node_canvas_shell(
|
||||
bool use_density_render_target,
|
||||
bool draw_merged,
|
||||
PrepareDensityRenderTarget&& prepare_density_render_target,
|
||||
PrepareStandardRenderTarget&& prepare_standard_render_target,
|
||||
DrawMergedPass&& draw_merged_pass,
|
||||
DrawUnmergedPass&& draw_unmerged_pass)
|
||||
{
|
||||
if (use_density_render_target) {
|
||||
prepare_density_render_target();
|
||||
} else {
|
||||
prepare_standard_render_target();
|
||||
}
|
||||
|
||||
if (draw_merged) {
|
||||
draw_merged_pass();
|
||||
return;
|
||||
}
|
||||
|
||||
draw_unmerged_pass();
|
||||
}
|
||||
|
||||
template <typename NodeCanvasT>
|
||||
inline void prepare_legacy_node_canvas_draw_setup(
|
||||
NodeCanvasT& node_canvas,
|
||||
const glm::vec4& box,
|
||||
const glm::ivec4& c,
|
||||
const glm::mat4& proj,
|
||||
const glm::mat4& camera)
|
||||
{
|
||||
node_canvas.m_canvas->m_mv = camera;
|
||||
node_canvas.m_canvas->m_proj = proj;
|
||||
node_canvas.m_canvas->m_box = box;
|
||||
node_canvas.m_canvas->m_vp = c;
|
||||
|
||||
for (int plane_index = 0; plane_index < 6; plane_index++) {
|
||||
node_canvas.m_canvas->m_plane_unproject[plane_index] =
|
||||
glm::inverse(node_canvas.m_canvas->m_proj * node_canvas.m_canvas->m_mv * node_canvas.m_canvas->m_plane_transform[plane_index]);
|
||||
node_canvas.m_canvas->m_plane_dir[plane_index] =
|
||||
-(node_canvas.m_canvas->m_plane_transform[plane_index] * glm::vec4(node_canvas.m_canvas->m_plane_origin[plane_index], 1));
|
||||
node_canvas.m_canvas->m_plane_shape[plane_index] =
|
||||
node_canvas.m_canvas->face_to_shape2D(plane_index);
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename NodeCanvasT,
|
||||
typename ApplyCapability,
|
||||
typename SetActiveTextureUnit,
|
||||
typename DrawFacePlane>
|
||||
inline void execute_legacy_canvas_draw_merged_pass(
|
||||
NodeCanvasT& node_canvas,
|
||||
const glm::mat4& proj,
|
||||
const glm::mat4& camera,
|
||||
ApplyCapability&& apply_node_canvas_capability,
|
||||
SetActiveTextureUnit&& set_active_texture_unit,
|
||||
DrawFacePlane&& draw_face_plane)
|
||||
{
|
||||
execute_legacy_canvas_draw_merge_background_setup(
|
||||
{
|
||||
.draw_merged = true,
|
||||
},
|
||||
{
|
||||
.disable_blend = [&] {
|
||||
apply_node_canvas_capability(pp::renderer::gl::blend_state(), false);
|
||||
},
|
||||
.draw_checkerboard_plane = make_legacy_canvas_draw_merge_background_checkerboard_plane(
|
||||
proj,
|
||||
camera,
|
||||
node_canvas.m_canvas->m_layers.size() + 500.f,
|
||||
node_canvas.m_canvas->m_plane_transform,
|
||||
std::forward<DrawFacePlane>(draw_face_plane)),
|
||||
});
|
||||
|
||||
const auto draw_merged_texture_plane = make_legacy_canvas_draw_merge_layer_texture_draw(
|
||||
&node_canvas.m_canvas->m_layers_merge,
|
||||
&node_canvas.m_sampler,
|
||||
&node_canvas.m_face_plane,
|
||||
std::forward<SetActiveTextureUnit>(set_active_texture_unit),
|
||||
proj,
|
||||
camera,
|
||||
node_canvas.m_canvas->m_plane_transform);
|
||||
|
||||
for (int plane_index = 0; plane_index < 6; plane_index++) {
|
||||
draw_merged_texture_plane(plane_index);
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename NodeCanvasT,
|
||||
typename ApplyViewport,
|
||||
@@ -1219,6 +1312,63 @@ inline void execute_legacy_canvas_draw_unmerged_node_canvas_pass(
|
||||
});
|
||||
}
|
||||
|
||||
template <
|
||||
typename NodeCanvasT,
|
||||
typename ApplyViewport,
|
||||
typename ApplyCapability,
|
||||
typename SetSampler,
|
||||
typename MakeLayerPathExecution,
|
||||
typename LogOnionRangeFailure>
|
||||
inline void execute_legacy_canvas_draw_node_canvas_unmerged_pass(
|
||||
NodeCanvasT& node_canvas,
|
||||
bool use_blend,
|
||||
bool copy_blend_destination,
|
||||
const glm::mat4& proj,
|
||||
const glm::mat4& camera,
|
||||
const glm::mat4& layer_orientation,
|
||||
const glm::ivec4& c,
|
||||
ApplyViewport&& apply_node_canvas_viewport,
|
||||
ApplyCapability&& apply_node_canvas_capability,
|
||||
SetSampler&& set_sampler,
|
||||
MakeLayerPathExecution&& make_layer_path_execution,
|
||||
LogOnionRangeFailure&& log_onion_range_failure)
|
||||
{
|
||||
const auto& brush = node_canvas.m_canvas->m_current_stroke->m_brush;
|
||||
execute_legacy_canvas_draw_unmerged_node_canvas_pass(
|
||||
node_canvas,
|
||||
use_blend,
|
||||
proj,
|
||||
camera,
|
||||
layer_orientation,
|
||||
c,
|
||||
std::forward<ApplyViewport>(apply_node_canvas_viewport),
|
||||
std::forward<ApplyCapability>(apply_node_canvas_capability),
|
||||
[&] {
|
||||
node_canvas.m_face_plane.draw_fill();
|
||||
},
|
||||
std::forward<SetSampler>(set_sampler),
|
||||
[&](size_t layer_index, int plane_index, const glm::mat4& plane_mvp_z) {
|
||||
return make_layer_path_execution(
|
||||
layer_index,
|
||||
plane_index,
|
||||
plane_mvp_z,
|
||||
brush.get(),
|
||||
copy_blend_destination,
|
||||
node_canvas.m_canvas->m_cam_fov < 20.f);
|
||||
},
|
||||
[&] {
|
||||
return make_legacy_canvas_draw_merge_cache_to_screen_checkerboard_plane(
|
||||
proj,
|
||||
camera,
|
||||
node_canvas.m_canvas->m_layers.size() + 500.f,
|
||||
node_canvas.m_canvas->m_plane_transform,
|
||||
[&] {
|
||||
node_canvas.m_face_plane.draw_fill();
|
||||
});
|
||||
},
|
||||
std::forward<LogOnionRangeFailure>(log_onion_range_failure));
|
||||
}
|
||||
|
||||
inline void execute_legacy_canvas_draw_merge_plane_setup(
|
||||
const LegacyCanvasDrawMergePlaneSetupUniforms& uniforms,
|
||||
const LegacyCanvasDrawMergePlaneSetupExecution& execution)
|
||||
|
||||
Reference in New Issue
Block a user