Extract stroke destination dispatch helper
This commit is contained in:
@@ -515,6 +515,9 @@ Progress Notes:
|
||||
closeout.
|
||||
- 2026-06-13: `STR-004` closed the last inline stroke dispatch glue. `LATER-003`
|
||||
remains at the binding-only tail.
|
||||
- 2026-06-13: `Canvas::stroke_draw_samples()` now reuses a retained destination
|
||||
texture dispatch helper for the live sample path; `Canvas` still owns the
|
||||
concrete face textures and callback execution.
|
||||
- 2026-06-13: `pp_paint_renderer_stroke_execution_tests` now also covers the
|
||||
new retained main-pass texture dispatch helper builder and its pattern/mixer
|
||||
wiring. Next slice should target another narrow `stroke_draw()` seam or stop
|
||||
|
||||
@@ -564,17 +564,17 @@ glm::vec4 Canvas::stroke_draw_samples(
|
||||
.slot = 1,
|
||||
},
|
||||
};
|
||||
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch destination_texture_dispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.bind_stroke_destination = [&] {
|
||||
m_tex[i].bind(); // bg, copy of framebuffer (copied before drawing)
|
||||
},
|
||||
.unbind_stroke_destination = [&] {
|
||||
m_tex[i].unbind();
|
||||
},
|
||||
};
|
||||
const auto destination_texture_dispatch =
|
||||
pp::panopainter::make_legacy_canvas_stroke_destination_texture_dispatch(
|
||||
[&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
[&] {
|
||||
m_tex[i].bind(); // bg, copy of framebuffer (copied before drawing)
|
||||
},
|
||||
[&] {
|
||||
m_tex[i].unbind();
|
||||
});
|
||||
const auto result = pp::panopainter::execute_legacy_canvas_stroke_face_sample_polygon(
|
||||
pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest {
|
||||
.context = "Canvas::stroke_draw_samples",
|
||||
|
||||
@@ -116,6 +116,18 @@ struct LegacyCanvasStrokeTextureInputDispatch {
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_destination_texture_dispatch(
|
||||
std::function<void(int)> activate_texture_unit,
|
||||
std::function<void()> bind_stroke_destination,
|
||||
std::function<void()> unbind_stroke_destination)
|
||||
{
|
||||
return LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = std::move(activate_texture_unit),
|
||||
.bind_stroke_destination = std::move(bind_stroke_destination),
|
||||
.unbind_stroke_destination = std::move(unbind_stroke_destination),
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_pad_destination_texture_dispatch(
|
||||
std::function<void(int)> activate_texture_unit,
|
||||
std::function<void()> bind_stroke_destination,
|
||||
|
||||
@@ -361,6 +361,28 @@ void retained_stroke_pad_destination_texture_dispatch_helper_builds_expected_cal
|
||||
PP_EXPECT(h, events == expected_events);
|
||||
}
|
||||
|
||||
void retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring(pp::tests::Harness& h)
|
||||
{
|
||||
std::vector<std::string> events;
|
||||
const auto dispatch = pp::panopainter::make_legacy_canvas_stroke_destination_texture_dispatch(
|
||||
[&](int slot) { events.emplace_back("activate:" + std::to_string(slot)); },
|
||||
[&] { events.emplace_back("bind:destination"); },
|
||||
[&] { events.emplace_back("unbind:destination"); });
|
||||
|
||||
pp::panopainter::bind_legacy_canvas_stroke_texture_input(
|
||||
LegacyCanvasStrokeTextureInput::stroke_destination,
|
||||
dispatch);
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_texture_input(
|
||||
LegacyCanvasStrokeTextureInput::stroke_destination,
|
||||
dispatch);
|
||||
|
||||
const std::vector<std::string> expected_events {
|
||||
"bind:destination",
|
||||
"unbind:destination",
|
||||
};
|
||||
PP_EXPECT(h, events == expected_events);
|
||||
}
|
||||
|
||||
void retained_stroke_sample_executor_copies_destination_and_expands_quads(pp::tests::Harness& h)
|
||||
{
|
||||
const auto vertices = make_quad_vertices();
|
||||
@@ -1450,6 +1472,9 @@ int main()
|
||||
harness.run(
|
||||
"retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_callback_wiring",
|
||||
retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_callback_wiring);
|
||||
harness.run(
|
||||
"retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring",
|
||||
retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring);
|
||||
harness.run(
|
||||
"retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring",
|
||||
retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring);
|
||||
|
||||
Reference in New Issue
Block a user