Plan live stroke rasterization boundaries

This commit is contained in:
2026-06-12 22:13:21 +02:00
parent 57c6128d11
commit 81726d30a5
8 changed files with 348 additions and 22 deletions

View File

@@ -3,6 +3,7 @@
#include "canvas.h"
#include "app.h"
#include "legacy_gl_renderbuffer_dispatch.h"
#include "legacy_canvas_stroke_services.h"
#include "legacy_ui_gl_dispatch.h"
#include "legacy_ui_overlay_services.h"
#include "app_core/document_canvas.h"
@@ -43,25 +44,21 @@ pp::renderer::RenderDeviceFeatures canvas_render_device_features() noexcept
return ShaderManager::render_device_features();
}
pp::paint_renderer::CanvasStrokeRasterizationPlan canvas_stroke_rasterization_plan(
int width,
int height) noexcept
{
return pp::panopainter::plan_legacy_canvas_stroke_rasterization(
canvas_render_device_features(),
width,
height);
}
pp::paint_renderer::CanvasStrokeFeedbackPlan canvas_destination_feedback_plan(
int width,
int height) noexcept
{
const auto plan = pp::paint_renderer::plan_canvas_stroke_feedback(
canvas_render_device_features(),
pp::renderer::Extent2D {
.width = static_cast<std::uint32_t>(std::max(width, 0)),
.height = static_cast<std::uint32_t>(std::max(height, 0)),
});
if (plan) {
return plan.value();
}
pp::paint_renderer::CanvasStrokeFeedbackPlan fallback;
fallback.compatibility_fallback = true;
fallback.path = pp::paint_renderer::StrokeCompositePath::ping_pong_textures;
fallback.requires_auxiliary_texture = true;
return fallback;
return canvas_stroke_rasterization_plan(width, height).feedback;
}
pp::paint_renderer::CanvasBlendGatePlan draw_merge_blend_gate_plan(
@@ -667,8 +664,8 @@ void Canvas::stroke_draw()
if (brush->m_pattern_flipx) patt_scale.x *= -1.f;
if (brush->m_pattern_flipy) patt_scale.y *= -1.f;
const auto stroke_feedback = canvas_destination_feedback_plan(m_width, m_height);
const bool copy_stroke_destination = !stroke_feedback.reads_destination_color;
const auto stroke_rasterization = canvas_stroke_rasterization_plan(m_width, m_height);
const bool copy_stroke_destination = stroke_rasterization.copy_stroke_destination;
apply_canvas_capability(blend_state(), false);
ShaderManager::use(kShader::Stroke);