Narrow retained canvas stroke execution helpers
This commit is contained in:
@@ -1832,6 +1832,99 @@ void retained_stroke_commit_runner_clamps_malformed_step_count(pp::tests::Harnes
|
||||
PP_EXPECT(h, timelapse == 1);
|
||||
}
|
||||
|
||||
void retained_stroke_commit_input_binder_uses_sequence_slots(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<int> active_slots;
|
||||
std::vector<CanvasStrokeCommitTextureRole> bound_textures;
|
||||
std::vector<std::pair<CanvasStrokeCommitTextureRole, int>> bound_samplers;
|
||||
|
||||
pp::panopainter::bind_legacy_canvas_stroke_commit_inputs(
|
||||
sequence,
|
||||
[&](int texture_slot) {
|
||||
active_slots.push_back(texture_slot);
|
||||
},
|
||||
[&](CanvasStrokeCommitTextureRole role) {
|
||||
bound_textures.push_back(role);
|
||||
},
|
||||
[&](CanvasStrokeCommitTextureRole role, int texture_slot) {
|
||||
bound_samplers.emplace_back(role, texture_slot);
|
||||
});
|
||||
|
||||
PP_EXPECT(h, active_slots.size() == 5U);
|
||||
PP_EXPECT(h, active_slots[0] == 0);
|
||||
PP_EXPECT(h, active_slots[1] == 1);
|
||||
PP_EXPECT(h, active_slots[2] == 2);
|
||||
PP_EXPECT(h, active_slots[3] == 3);
|
||||
PP_EXPECT(h, active_slots[4] == 4);
|
||||
PP_EXPECT(h, bound_textures.size() == 5U);
|
||||
PP_EXPECT(h, bound_textures[0] == CanvasStrokeCommitTextureRole::layer_scratch);
|
||||
PP_EXPECT(h, bound_textures[1] == CanvasStrokeCommitTextureRole::stroke);
|
||||
PP_EXPECT(h, bound_textures[2] == CanvasStrokeCommitTextureRole::selection_mask);
|
||||
PP_EXPECT(h, bound_textures[3] == CanvasStrokeCommitTextureRole::dual_stroke);
|
||||
PP_EXPECT(h, bound_textures[4] == CanvasStrokeCommitTextureRole::pattern);
|
||||
PP_EXPECT(h, bound_samplers.size() == 5U);
|
||||
PP_EXPECT(h, bound_samplers[0].first == CanvasStrokeCommitTextureRole::layer_scratch);
|
||||
PP_EXPECT(h, bound_samplers[0].second == 0);
|
||||
PP_EXPECT(h, bound_samplers[4].first == CanvasStrokeCommitTextureRole::pattern);
|
||||
PP_EXPECT(h, bound_samplers[4].second == 4);
|
||||
}
|
||||
|
||||
void retained_stroke_commit_dilate_copy_uses_layer_scratch_slot(pp::tests::Harness& h)
|
||||
{
|
||||
const auto sequence = plan_canvas_stroke_commit_sequence(
|
||||
CanvasStrokeCommitRequest {
|
||||
.erase_mode = true,
|
||||
.alpha_locked = true,
|
||||
.selection_mask_active = false,
|
||||
.dual_stroke_enabled = false,
|
||||
.pattern_enabled = false,
|
||||
});
|
||||
|
||||
int setup_calls = 0;
|
||||
std::vector<int> active_slots;
|
||||
int bind_layer_scratch_calls = 0;
|
||||
std::vector<pp::paint_renderer::CanvasStrokeCopyRegion> copy_regions;
|
||||
|
||||
pp::panopainter::copy_legacy_canvas_stroke_commit_to_dilate_source(
|
||||
sequence,
|
||||
[&]() { ++setup_calls; },
|
||||
[&](int texture_slot) { active_slots.push_back(texture_slot); },
|
||||
[&]() { ++bind_layer_scratch_calls; },
|
||||
[&](int src_x, int src_y, int dst_x, int dst_y, int width, int height) {
|
||||
copy_regions.push_back(pp::paint_renderer::CanvasStrokeCopyRegion {
|
||||
.x = src_x,
|
||||
.y = src_y,
|
||||
.width = width,
|
||||
.height = height,
|
||||
});
|
||||
PP_EXPECT(h, dst_x == 0);
|
||||
PP_EXPECT(h, dst_y == 0);
|
||||
},
|
||||
pp::panopainter::LegacyCanvasStrokeCommitCopyExtent {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, setup_calls == 1);
|
||||
PP_EXPECT(h, active_slots.size() == 1U);
|
||||
PP_EXPECT(h, active_slots[0] == 0);
|
||||
PP_EXPECT(h, bind_layer_scratch_calls == 1);
|
||||
PP_EXPECT(h, copy_regions.size() == 1U);
|
||||
PP_EXPECT(h, copy_regions[0].x == 0);
|
||||
PP_EXPECT(h, copy_regions[0].y == 0);
|
||||
PP_EXPECT(h, copy_regions[0].width == 256);
|
||||
PP_EXPECT(h, copy_regions[0].height == 128);
|
||||
}
|
||||
|
||||
void plans_stroke_preview_composite_for_simple_brush(pp::tests::Harness& h)
|
||||
{
|
||||
const auto plan = plan_stroke_preview_composite(StrokePreviewCompositeRequest {});
|
||||
@@ -2344,6 +2437,12 @@ int main()
|
||||
harness.run(
|
||||
"retained_stroke_commit_runner_clamps_malformed_step_count",
|
||||
retained_stroke_commit_runner_clamps_malformed_step_count);
|
||||
harness.run(
|
||||
"retained_stroke_commit_input_binder_uses_sequence_slots",
|
||||
retained_stroke_commit_input_binder_uses_sequence_slots);
|
||||
harness.run(
|
||||
"retained_stroke_commit_dilate_copy_uses_layer_scratch_slot",
|
||||
retained_stroke_commit_dilate_copy_uses_layer_scratch_slot);
|
||||
harness.run("plans_stroke_preview_composite_for_simple_brush", plans_stroke_preview_composite_for_simple_brush);
|
||||
harness.run("plans_stroke_preview_composite_with_mixer_input", plans_stroke_preview_composite_with_mixer_input);
|
||||
harness.run("plans_stroke_preview_composite_with_dual_input", plans_stroke_preview_composite_with_dual_input);
|
||||
|
||||
Reference in New Issue
Block a user