Reuse main stroke texture dispatch helper

This commit is contained in:
2026-06-13 16:52:08 +02:00
parent 2a29ebb1a9
commit 7659f4907b
3 changed files with 45 additions and 21 deletions

View File

@@ -509,6 +509,12 @@ Done Checks:
Progress Notes:
- 2026-06-13: `Canvas::stroke_draw()` main-pass texture dispatch now reuses
retained helper builders for texture-unit, brush-tip, pattern, and mixer
callback wiring; the live adapter still owns the concrete textures and
sampler state. Next slice should target the remaining inline `stroke_draw()`
dispatch construction or another narrow seam without reopening landed pad or
dual-pass helpers.
- 2026-06-13: `Canvas::stroke_draw()` dual-brush replay now reuses the new
retained brush-tip texture dispatch helper for binding and unbinding; the
live adapter still owns the concrete brush texture object and live-pass

View File

@@ -758,27 +758,27 @@ void Canvas::stroke_draw()
},
};
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch main_pass_texture_dispatch {
.activate_texture_unit = [&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
.bind_brush_tip = [&] {
brush->m_tip_texture->bind();
},
.unbind_brush_tip = [&] {
brush->m_tip_texture->unbind();
},
.bind_pattern = [&] {
brush->m_pattern_texture ?
brush->m_pattern_texture->bind() :
unbind_texture_2d();
},
.bind_mixer = [&] {
m_mixer.bindTexture();
},
.unbind_mixer = [&] {
m_mixer.unbindTexture();
},
};
pp::panopainter::make_legacy_canvas_stroke_main_pass_texture_dispatch(
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
[&] {
brush->m_tip_texture->bind();
},
[&] {
brush->m_tip_texture->unbind();
},
[&] {
brush->m_pattern_texture ?
brush->m_pattern_texture->bind() :
unbind_texture_2d();
},
[&] {
m_mixer.bindTexture();
},
[&] {
m_mixer.unbindTexture();
});
pp::panopainter::bind_legacy_canvas_stroke_sampler_inputs(
live_pass_sampler_bindings,
live_pass_sampler_dispatch);

View File

@@ -86,6 +86,24 @@ struct LegacyCanvasStrokeTextureInputDispatch {
std::function<void()> unbind_mixer;
};
[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_main_pass_texture_dispatch(
std::function<void(int)> activate_texture_unit,
std::function<void()> bind_brush_tip,
std::function<void()> unbind_brush_tip,
std::function<void()> bind_pattern,
std::function<void()> bind_mixer,
std::function<void()> unbind_mixer)
{
return LegacyCanvasStrokeTextureInputDispatch {
.activate_texture_unit = std::move(activate_texture_unit),
.bind_brush_tip = std::move(bind_brush_tip),
.unbind_brush_tip = std::move(unbind_brush_tip),
.bind_pattern = std::move(bind_pattern),
.bind_mixer = std::move(bind_mixer),
.unbind_mixer = std::move(unbind_mixer),
};
}
[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_brush_tip_texture_dispatch(
std::function<void(int)> activate_texture_unit,
std::function<void()> bind_brush_tip,