Extract pad destination dispatch overload

This commit is contained in:
2026-06-13 18:47:21 +02:00
parent 58885187ba
commit 819b0f31db
5 changed files with 69 additions and 14 deletions

View File

@@ -863,18 +863,6 @@ void Canvas::stroke_draw()
.slot = 1,
},
};
const auto make_pad_destination_texture_dispatch = [&](int face_index) {
return pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch(
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
[&] {
m_tex[face_index].bind();
},
[&] {
m_tex[face_index].unbind();
});
};
[[maybe_unused]] const auto pad_result = pp::panopainter::execute_legacy_canvas_stroke_pad_face_callbacks(
pad_faces,
stroke_extent,
@@ -890,7 +878,17 @@ void Canvas::stroke_draw()
[&](int face_index) {
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
pad_destination_texture_binding,
make_pad_destination_texture_dispatch(face_index));
pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch(
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
[&](int dst_face_index) {
m_tex[dst_face_index].bind();
},
[&](int dst_face_index) {
m_tex[dst_face_index].unbind();
},
face_index));
},
[&](const pp::paint_renderer::CanvasStrokeCopyRegion& copy_region) {
copy_framebuffer_to_texture_2d(
@@ -904,7 +902,17 @@ void Canvas::stroke_draw()
[&](int face_index) {
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
pad_destination_texture_binding,
make_pad_destination_texture_dispatch(face_index));
pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch(
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
[&](int dst_face_index) {
m_tex[dst_face_index].bind();
},
[&](int dst_face_index) {
m_tex[dst_face_index].unbind();
},
face_index));
},
[&] {
m_brush_shape.draw_fill();

View File

@@ -140,6 +140,22 @@ struct LegacyCanvasStrokeTextureInputDispatch {
};
}
[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_pad_destination_texture_dispatch(
std::function<void(int)> activate_texture_unit,
std::function<void(int)> bind_stroke_destination,
std::function<void(int)> unbind_stroke_destination,
int face_index)
{
return make_legacy_canvas_stroke_pad_destination_texture_dispatch(
std::move(activate_texture_unit),
[bind_stroke_destination = std::move(bind_stroke_destination), face_index]() {
bind_stroke_destination(face_index);
},
[unbind_stroke_destination = std::move(unbind_stroke_destination), face_index]() {
unbind_stroke_destination(face_index);
});
}
struct LegacyCanvasStrokeSamplerDispatch {
std::function<void(int)> bind_brush_tip_sampler;
std::function<void()> unbind_brush_tip_sampler;