Extract stroke dual pass boundary
This commit is contained in:
@@ -509,6 +509,12 @@ Done Checks:
|
||||
|
||||
Progress Notes:
|
||||
|
||||
- 2026-06-13: `Canvas::stroke_draw()` dual-brush replay now routes shader
|
||||
setup, brush-tip texture binding, live-pass execution, and brush-tip
|
||||
unbinding through `execute_legacy_canvas_stroke_dual_pass(...)`; the live
|
||||
adapter still owns the concrete texture callbacks and face-frame replay.
|
||||
Next slice should target another narrow `stroke_draw()` seam without
|
||||
reopening landed pad or sample helpers.
|
||||
- 2026-06-13: `Canvas::stroke_draw()` now routes the pad-stroke destination
|
||||
texture dispatch through a local helper lambda, so the repeated bind/unbind
|
||||
callback construction is centralized while the pad executor still owns the
|
||||
|
||||
112
src/canvas.cpp
112
src/canvas.cpp
@@ -906,67 +906,75 @@ void Canvas::stroke_draw()
|
||||
if (stroke_material.dual_pass.enabled && m_dual_stroke)
|
||||
{
|
||||
const auto& dual_brush = m_dual_stroke->m_brush;
|
||||
pp::panopainter::setup_legacy_stroke_dual_shader(stroke_material.dual_pass.uses_pattern);
|
||||
|
||||
constexpr std::array dual_pass_texture_bindings {
|
||||
pp::panopainter::LegacyCanvasStrokeTextureBinding {
|
||||
.input = pp::panopainter::LegacyCanvasStrokeTextureInput::brush_tip,
|
||||
.slot = 0,
|
||||
},
|
||||
};
|
||||
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.bind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->unbind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
auto frames_dual = stroke_draw_compute(*m_dual_stroke);
|
||||
const std::array<bool, 6> include_dual_dirty =
|
||||
SIXPLETTE(stroke_material.composite_pass.dual_blend_mode == 0);
|
||||
pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers(
|
||||
frames_dual,
|
||||
stroke_extent,
|
||||
std::span<glm::vec4>(m_dirty_box),
|
||||
std::span<glm::vec4>(),
|
||||
std::span<const bool>(include_dual_dirty),
|
||||
[&](auto& f) {
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = f.col,
|
||||
.alpha = f.flow,
|
||||
.opacity = f.opacity,
|
||||
});
|
||||
},
|
||||
[](auto&, int, auto&) {},
|
||||
[&](auto&, int i, auto& P) {
|
||||
return stroke_draw_samples(i, P, copy_stroke_destination);
|
||||
},
|
||||
m_tmp_dual,
|
||||
true);
|
||||
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->unbind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
[[maybe_unused]] const auto dual_result =
|
||||
pp::panopainter::execute_legacy_canvas_stroke_dual_pass(
|
||||
pp::panopainter::LegacyCanvasStrokeDualPassRequest {
|
||||
.context = "Canvas::stroke_draw",
|
||||
.planes = dual_pass_texture_bindings,
|
||||
.setup_dual_shader = [&] {
|
||||
pp::panopainter::setup_legacy_stroke_dual_shader(
|
||||
stroke_material.dual_pass.uses_pattern);
|
||||
},
|
||||
.bind_brush_tip = [&] {
|
||||
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.bind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
},
|
||||
.execute_frame_pass = [&] {
|
||||
pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers(
|
||||
frames_dual,
|
||||
stroke_extent,
|
||||
std::span<glm::vec4>(m_dirty_box),
|
||||
std::span<glm::vec4>(),
|
||||
std::span<const bool>(include_dual_dirty),
|
||||
[&](auto& f) {
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = f.col,
|
||||
.alpha = f.flow,
|
||||
.opacity = f.opacity,
|
||||
});
|
||||
},
|
||||
[](auto&, int, auto&) {},
|
||||
[&](auto&, int i, auto& P) {
|
||||
return stroke_draw_samples(i, P, copy_stroke_destination);
|
||||
},
|
||||
m_tmp_dual,
|
||||
true);
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->unbind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_sampler_inputs(
|
||||
|
||||
@@ -179,9 +179,42 @@ struct LegacyCanvasStrokeMixPassResult {
|
||||
std::size_t composed_planes = 0;
|
||||
};
|
||||
|
||||
struct LegacyCanvasStrokeDualPassRequest {
|
||||
std::string_view context;
|
||||
std::span<const LegacyCanvasStrokeMixPassPlane> planes;
|
||||
std::function<void()> bind_brush_tip;
|
||||
std::function<void()> unbind_brush_tip;
|
||||
std::function<void()> setup_dual_shader;
|
||||
std::function<void()> execute_frame_pass;
|
||||
};
|
||||
|
||||
struct LegacyCanvasStrokeDualPassResult {
|
||||
bool ok = false;
|
||||
std::size_t composed_planes = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] inline LegacyCanvasStrokeMixPassResult execute_legacy_canvas_stroke_mix_pass(
|
||||
const LegacyCanvasStrokeMixPassRequest& request);
|
||||
|
||||
[[nodiscard]] inline LegacyCanvasStrokeDualPassResult execute_legacy_canvas_stroke_dual_pass(
|
||||
const LegacyCanvasStrokeDualPassRequest& request)
|
||||
{
|
||||
LegacyCanvasStrokeDualPassResult result;
|
||||
if (!request.setup_dual_shader ||
|
||||
!request.bind_brush_tip ||
|
||||
!request.unbind_brush_tip ||
|
||||
!request.execute_frame_pass) {
|
||||
return result;
|
||||
}
|
||||
|
||||
request.setup_dual_shader();
|
||||
request.bind_brush_tip();
|
||||
request.execute_frame_pass();
|
||||
request.unbind_brush_tip();
|
||||
result.ok = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <std::size_t PlaneCount, typename HasTarget>
|
||||
[[nodiscard]] inline std::array<LegacyCanvasStrokeMixPassPlane, PlaneCount>
|
||||
plan_legacy_canvas_stroke_mix_pass_planes(
|
||||
|
||||
Reference in New Issue
Block a user