Extract stroke commit callback orchestration
This commit is contained in:
@@ -2013,6 +2013,88 @@ void retained_stroke_commit_runner_preserves_per_face_step_order(pp::tests::Harn
|
||||
PP_EXPECT(h, events == expected);
|
||||
}
|
||||
|
||||
void retained_stroke_commit_callback_builder_preserves_order(pp::tests::Harness& h)
|
||||
{
|
||||
const auto sequence = plan_canvas_stroke_commit_sequence(
|
||||
CanvasStrokeCommitRequest {
|
||||
.erase_mode = false,
|
||||
.alpha_locked = false,
|
||||
.selection_mask_active = true,
|
||||
.dual_stroke_enabled = true,
|
||||
.pattern_enabled = true,
|
||||
});
|
||||
|
||||
std::vector<std::string> events;
|
||||
const auto record = [&](std::string_view event, int face_index = -1) {
|
||||
if (face_index >= 0) {
|
||||
events.push_back(std::string(event) + ":" + std::to_string(face_index));
|
||||
} else {
|
||||
events.push_back(std::string(event));
|
||||
}
|
||||
};
|
||||
|
||||
const auto callbacks = pp::panopainter::make_legacy_canvas_stroke_commit_callbacks(
|
||||
[&]() { record("start"); },
|
||||
[&]() { record("capture"); },
|
||||
[&]() { record("prepare"); },
|
||||
[&]() { record("restore"); },
|
||||
[&]() { record("publish"); },
|
||||
[&]() { record("timelapse"); },
|
||||
[&](int face_index) { record("bind-fbo", face_index); },
|
||||
[&](int face_index) { record("history", face_index); },
|
||||
[&](int face_index) { record("dirty", face_index); },
|
||||
[&](int face_index) { record("copy-layer", face_index); },
|
||||
[&](int face_index) { record("bind-inputs", face_index); },
|
||||
[&](int face_index) { record("erase", face_index); },
|
||||
[&](int face_index) { record("paint", face_index); },
|
||||
[&](int face_index) { record("copy-committed", face_index); },
|
||||
[&](int face_index) { record("dilate", face_index); },
|
||||
[&](int face_index) { record("unbind-fbo", face_index); });
|
||||
|
||||
const auto result = pp::panopainter::execute_legacy_canvas_stroke_commit_sequence(
|
||||
pp::panopainter::LegacyCanvasStrokeCommitRequest {
|
||||
.context = "test",
|
||||
.faces = {
|
||||
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 0, .dirty = true },
|
||||
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 1, .dirty = false },
|
||||
pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 2, .dirty = true },
|
||||
},
|
||||
.sequence = sequence,
|
||||
.callbacks = callbacks,
|
||||
});
|
||||
|
||||
const std::vector<std::string> expected {
|
||||
"start",
|
||||
"capture",
|
||||
"prepare",
|
||||
"bind-fbo:0",
|
||||
"history:0",
|
||||
"dirty:0",
|
||||
"copy-layer:0",
|
||||
"bind-inputs:0",
|
||||
"paint:0",
|
||||
"copy-committed:0",
|
||||
"dilate:0",
|
||||
"unbind-fbo:0",
|
||||
"bind-fbo:2",
|
||||
"history:2",
|
||||
"dirty:2",
|
||||
"copy-layer:2",
|
||||
"bind-inputs:2",
|
||||
"paint:2",
|
||||
"copy-committed:2",
|
||||
"dilate:2",
|
||||
"unbind-fbo:2",
|
||||
"restore",
|
||||
"publish",
|
||||
"timelapse",
|
||||
};
|
||||
|
||||
PP_EXPECT(h, result.ok);
|
||||
PP_EXPECT(h, result.committed_faces == 2);
|
||||
PP_EXPECT(h, events == expected);
|
||||
}
|
||||
|
||||
void retained_stroke_commit_copy_skips_missing_layer_scratch_or_invalid_extent(pp::tests::Harness& h)
|
||||
{
|
||||
pp::paint_renderer::CanvasStrokeCommitSequencePlan missing_scratch;
|
||||
@@ -3020,6 +3102,9 @@ int main()
|
||||
harness.run(
|
||||
"retained_stroke_commit_runner_preserves_per_face_step_order",
|
||||
retained_stroke_commit_runner_preserves_per_face_step_order);
|
||||
harness.run(
|
||||
"retained_stroke_commit_callback_builder_preserves_order",
|
||||
retained_stroke_commit_callback_builder_preserves_order);
|
||||
harness.run(
|
||||
"retained_stroke_commit_copy_skips_missing_layer_scratch_or_invalid_extent",
|
||||
retained_stroke_commit_copy_skips_missing_layer_scratch_or_invalid_extent);
|
||||
|
||||
Reference in New Issue
Block a user