Extract stroke commit request assembly

This commit is contained in:
2026-06-13 20:00:21 +02:00
parent 532286e81a
commit 536f268349
3 changed files with 84 additions and 14 deletions

View File

@@ -531,11 +531,13 @@ static auto make_canvas_stroke_mix_pass_shell(
});
}
template <typename SetActiveTextureUnit>
static auto make_canvas_stroke_commit_callbacks(
Canvas& canvas,
const glm::vec4& vp,
const glm::vec4& cc,
bool blend,
SetActiveTextureUnit&& set_active_texture_unit,
ActionStroke* action,
const Stroke* current_stroke,
const pp::paint_renderer::CanvasStrokeCommitSequencePlan& sequence,
@@ -734,6 +736,19 @@ static auto make_canvas_stroke_commit_callbacks(
});
}
static auto make_canvas_stroke_commit_request(
const std::array<pp::panopainter::LegacyCanvasStrokeCommitFace, 6>& faces,
const pp::paint_renderer::CanvasStrokeCommitSequencePlan& sequence,
const pp::panopainter::LegacyCanvasStrokeCommitCallbacks& callbacks)
{
return pp::panopainter::LegacyCanvasStrokeCommitRequest {
.context = "Canvas::stroke_commit",
.faces = faces,
.sequence = sequence,
.callbacks = callbacks,
};
}
glm::vec4 Canvas::stroke_draw_samples(
int i,
std::vector<vertex_t>& P,
@@ -1315,31 +1330,30 @@ void Canvas::stroke_commit()
.pattern_enabled = stroke_material.composite_pass.use_pattern,
});
std::array<pp::panopainter::LegacyCanvasStrokeCommitFace, 6> faces {};
for (int i = 0; i < 6; ++i) {
faces[i] = pp::panopainter::LegacyCanvasStrokeCommitFace {
.index = i,
.dirty = m_dirty_face[i],
};
}
const auto commit_callbacks = make_canvas_stroke_commit_callbacks(
*this,
vp,
cc,
blend,
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
action,
m_current_stroke,
sequence,
stroke_material);
const std::array<pp::panopainter::LegacyCanvasStrokeCommitFace, 6> faces {
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 0, .dirty = m_dirty_face[0] },
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 1, .dirty = m_dirty_face[1] },
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 2, .dirty = m_dirty_face[2] },
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 3, .dirty = m_dirty_face[3] },
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 4, .dirty = m_dirty_face[4] },
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 5, .dirty = m_dirty_face[5] },
};
[[maybe_unused]] const auto commit_result = pp::panopainter::execute_legacy_canvas_stroke_commit_sequence(
pp::panopainter::LegacyCanvasStrokeCommitRequest {
.context = "Canvas::stroke_commit",
.faces = faces,
.sequence = sequence,
.callbacks = commit_callbacks,
});
make_canvas_stroke_commit_request(faces, sequence, commit_callbacks));
}
void Canvas::stroke_commit_timelapse()