Refine stroke sample execution boundary

This commit is contained in:
2026-06-13 16:40:16 +02:00
parent 5b8409718d
commit 226dc95703
3 changed files with 106 additions and 25 deletions

View File

@@ -408,6 +408,65 @@ void retained_stroke_face_sample_polygon_triangulates_and_forwards_face_callback
}
}
void retained_stroke_face_sample_polygon_skips_destination_callbacks_when_copy_is_disabled(pp::tests::Harness& h)
{
const auto polygon_vertices = make_polygon_vertices({
glm::vec2(8.0F, 9.0F),
glm::vec2(18.0F, 9.0F),
glm::vec2(13.0F, 21.0F),
});
int bind_face_index = -1;
int copy_face_index = -1;
int unbind_face_index = -1;
int upload_face_index = -1;
int draw_face_index = -1;
int bind_calls = 0;
int copy_calls = 0;
int unbind_calls = 0;
std::size_t uploaded_vertex_count = 0;
const auto result = pp::panopainter::execute_legacy_canvas_stroke_face_sample_polygon(
pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest {
.context = "test",
.target_size = glm::vec2(64.0F, 64.0F),
.polygon_vertices = polygon_vertices,
.face_index = 3,
.copy_stroke_destination = false,
.bind_destination_texture = [&](int face_index) {
++bind_calls;
bind_face_index = face_index;
},
.copy_framebuffer_to_destination_texture =
[&](int face_index, int, int, int, int, int, int) {
++copy_calls;
copy_face_index = face_index;
},
.unbind_destination_texture = [&](int face_index) {
++unbind_calls;
unbind_face_index = face_index;
},
.upload_brush_vertices = [&](int face_index, std::span<const vertex_t> vertices) {
upload_face_index = face_index;
uploaded_vertex_count = vertices.size();
},
.draw_brush_shape = [&](int face_index) {
draw_face_index = face_index;
},
});
PP_EXPECT(h, result.ok);
PP_EXPECT(h, bind_calls == 0);
PP_EXPECT(h, copy_calls == 0);
PP_EXPECT(h, unbind_calls == 0);
PP_EXPECT(h, upload_face_index == 3);
PP_EXPECT(h, draw_face_index == 3);
PP_EXPECT(h, uploaded_vertex_count == 3U);
PP_EXPECT(h, bind_face_index == -1);
PP_EXPECT(h, copy_face_index == -1);
PP_EXPECT(h, unbind_face_index == -1);
}
struct StrokeFrame {
int id = -1;
std::array<std::vector<vertex_t>, 6> shapes {};
@@ -1185,6 +1244,9 @@ int main()
harness.run(
"retained_stroke_face_sample_polygon_triangulates_and_forwards_face_callbacks",
retained_stroke_face_sample_polygon_triangulates_and_forwards_face_callbacks);
harness.run(
"retained_stroke_face_sample_polygon_skips_destination_callbacks_when_copy_is_disabled",
retained_stroke_face_sample_polygon_skips_destination_callbacks_when_copy_is_disabled);
harness.run(
"retained_stroke_frame_samples_preserve_frame_face_callback_order",
retained_stroke_frame_samples_preserve_frame_face_callback_order);