Plan canvas stroke feedback copies

This commit is contained in:
2026-06-03 18:52:37 +02:00
parent b576143afb
commit 2ac2c45b11
8 changed files with 174 additions and 14 deletions

View File

@@ -15,6 +15,7 @@ using pp::paint_renderer::StrokeCompositePath;
using pp::paint_renderer::StrokeCompositeRequest;
using pp::paint_renderer::composite_layer;
using pp::paint_renderer::plan_canvas_blend_gate;
using pp::paint_renderer::plan_canvas_stroke_feedback;
using pp::paint_renderer::plan_stroke_composite;
using pp::paint_renderer::stroke_composite_path_name;
using pp::paint_renderer::stroke_composite_requires_feedback;
@@ -309,6 +310,7 @@ void plans_canvas_blend_gate_from_persisted_indices(pp::tests::Harness& h)
PP_EXPECT(h, stroke.value().stroke_complex);
PP_EXPECT(h, stroke.value().first_complex_layer_index == -1);
PP_EXPECT(h, stroke.value().path == StrokeCompositePath::ping_pong_textures);
PP_EXPECT(h, !stroke.value().reads_destination_color);
PP_EXPECT(h, stroke.value().requires_texture_copy);
}
}
@@ -381,6 +383,64 @@ void canvas_blend_gate_preserves_legacy_fallbacks(pp::tests::Harness& h)
}
}
void plans_canvas_stroke_feedback_paths(pp::tests::Harness& h)
{
const Extent2D extent { .width = 32, .height = 16 };
const auto fetch = plan_canvas_stroke_feedback(
RenderDeviceFeatures { .framebuffer_fetch = true },
extent);
PP_EXPECT(h, fetch);
if (fetch) {
PP_EXPECT(h, fetch.value().path == StrokeCompositePath::framebuffer_fetch);
PP_EXPECT(h, fetch.value().reads_destination_color);
PP_EXPECT(h, !fetch.value().requires_auxiliary_texture);
PP_EXPECT(h, !fetch.value().compatibility_fallback);
}
const auto copy = plan_canvas_stroke_feedback(
RenderDeviceFeatures { .texture_copy = true },
extent);
PP_EXPECT(h, copy);
if (copy) {
PP_EXPECT(h, copy.value().path == StrokeCompositePath::ping_pong_textures);
PP_EXPECT(h, !copy.value().reads_destination_color);
PP_EXPECT(h, copy.value().requires_auxiliary_texture);
PP_EXPECT(h, copy.value().requires_texture_copy);
PP_EXPECT(h, !copy.value().requires_render_target_blit);
}
const auto blit = plan_canvas_stroke_feedback(
RenderDeviceFeatures { .render_target_blit = true },
extent);
PP_EXPECT(h, blit);
if (blit) {
PP_EXPECT(h, blit.value().path == StrokeCompositePath::ping_pong_textures);
PP_EXPECT(h, blit.value().requires_auxiliary_texture);
PP_EXPECT(h, !blit.value().requires_texture_copy);
PP_EXPECT(h, blit.value().requires_render_target_blit);
}
}
void canvas_stroke_feedback_preserves_legacy_fallback(pp::tests::Harness& h)
{
const auto fallback = plan_canvas_stroke_feedback(
RenderDeviceFeatures {},
Extent2D { .width = 32, .height = 16 });
PP_EXPECT(h, fallback);
if (fallback) {
PP_EXPECT(h, fallback.value().path == StrokeCompositePath::ping_pong_textures);
PP_EXPECT(h, fallback.value().requires_auxiliary_texture);
PP_EXPECT(h, !fallback.value().requires_texture_copy);
PP_EXPECT(h, fallback.value().compatibility_fallback);
}
const auto invalid = plan_canvas_stroke_feedback(
RenderDeviceFeatures { .texture_copy = true },
Extent2D { .width = 0, .height = 16 });
PP_EXPECT(h, !invalid.ok());
PP_EXPECT(h, invalid.status().code == StatusCode::invalid_argument);
}
}
int main()
@@ -394,5 +454,7 @@ int main()
harness.run("rejects_bad_stroke_composite_plans", rejects_bad_stroke_composite_plans);
harness.run("plans_canvas_blend_gate_from_persisted_indices", plans_canvas_blend_gate_from_persisted_indices);
harness.run("canvas_blend_gate_preserves_legacy_fallbacks", canvas_blend_gate_preserves_legacy_fallbacks);
harness.run("plans_canvas_stroke_feedback_paths", plans_canvas_stroke_feedback_paths);
harness.run("canvas_stroke_feedback_preserves_legacy_fallback", canvas_stroke_feedback_preserves_legacy_fallback);
return harness.finish();
}