Extract draw merge temporary paint request helper

This commit is contained in:
2026-06-14 00:22:37 +02:00
parent 91bd37bca5
commit 1a28716e94

View File

@@ -1219,22 +1219,20 @@ void Canvas::stroke_draw_pad_face_callback_body(
pad_color); pad_color);
} }
void Canvas::draw_merge_temporary_paint_branch( static auto make_canvas_draw_merge_temporary_paint_request(
Canvas& canvas,
int layer_index, int layer_index,
int plane_index, int plane_index,
std::shared_ptr<Layer> layer, const std::shared_ptr<Layer>& layer,
const Brush& brush, const Brush& brush,
const glm::mat4& ortho, const glm::mat4& ortho)
bool copy_blend_destination,
bool draw_checkerboard)
{ {
(void)draw_checkerboard;
const auto stroke_material = canvas_stroke_material_plan(*brush, false); const auto stroke_material = canvas_stroke_material_plan(*brush, false);
glm::vec2 patt_scale = glm::vec2(brush->m_pattern_scale); glm::vec2 patt_scale = glm::vec2(brush->m_pattern_scale);
if (brush->m_pattern_flipx) patt_scale.x *= -1.f; if (brush->m_pattern_flipx) patt_scale.x *= -1.f;
if (brush->m_pattern_flipy) patt_scale.y *= -1.f; if (brush->m_pattern_flipy) patt_scale.y *= -1.f;
const auto execution = pp::panopainter::make_legacy_canvas_draw_merge_temporary_paint_composite( return pp::panopainter::make_legacy_canvas_draw_merge_temporary_paint_composite(
[&] { [&] {
pp::panopainter::setup_legacy_stroke_composite_shader( pp::panopainter::setup_legacy_stroke_composite_shader(
pp::panopainter::LegacyStrokeCompositeUniforms { pp::panopainter::LegacyStrokeCompositeUniforms {
@@ -1251,7 +1249,7 @@ void Canvas::draw_merge_temporary_paint_branch(
.mvp = ortho, .mvp = ortho,
.layer_alpha = layer->m_opacity, .layer_alpha = layer->m_opacity,
.alpha_lock = layer->m_alpha_locked, .alpha_lock = layer->m_alpha_locked,
.mask_enabled = m_smask_active, .mask_enabled = canvas.m_smask_active,
.use_fragcoord = false, .use_fragcoord = false,
.blend_mode = brush->m_blend_mode, .blend_mode = brush->m_blend_mode,
.use_dual = stroke_material.composite_pass.use_dual, .use_dual = stroke_material.composite_pass.use_dual,
@@ -1261,40 +1259,59 @@ void Canvas::draw_merge_temporary_paint_branch(
}); });
}, },
[&] { [&] {
m_sampler.bind(0); canvas.m_sampler.bind(0);
m_sampler.bind(1); canvas.m_sampler.bind(1);
m_sampler.bind(2); canvas.m_sampler.bind(2);
m_sampler.bind(3); canvas.m_sampler.bind(3);
m_sampler_stencil.bind(4); canvas.m_sampler_stencil.bind(4);
}, },
[&] { [&] {
set_active_texture_unit(0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture(); canvas.m_layers[layer_index]->rtt(plane_index).bindTexture();
set_active_texture_unit(1); set_active_texture_unit(1);
m_tmp[plane_index].bindTexture(); canvas.m_tmp[plane_index].bindTexture();
set_active_texture_unit(2); set_active_texture_unit(2);
m_smask.rtt(plane_index).bindTexture(); canvas.m_smask.rtt(plane_index).bindTexture();
set_active_texture_unit(3); set_active_texture_unit(3);
if (stroke_material.composite_pass.use_dual) if (stroke_material.composite_pass.use_dual)
m_tmp_dual[plane_index].bindTexture(); canvas.m_tmp_dual[plane_index].bindTexture();
set_active_texture_unit(4); set_active_texture_unit(4);
brush->m_pattern_texture ? brush->m_pattern_texture->bind() : unbind_texture_2d(); brush->m_pattern_texture ? brush->m_pattern_texture->bind() : unbind_texture_2d();
}, },
[&] { [&] {
m_plane.draw_fill(); canvas.m_plane.draw_fill();
}, },
[&] { [&] {
set_active_texture_unit(3); set_active_texture_unit(3);
if (stroke_material.composite_pass.use_dual) if (stroke_material.composite_pass.use_dual)
m_tmp_dual[plane_index].unbindTexture(); canvas.m_tmp_dual[plane_index].unbindTexture();
set_active_texture_unit(2); set_active_texture_unit(2);
m_smask.rtt(plane_index).unbindTexture(); canvas.m_smask.rtt(plane_index).unbindTexture();
set_active_texture_unit(1); set_active_texture_unit(1);
m_tmp[plane_index].unbindTexture(); canvas.m_tmp[plane_index].unbindTexture();
set_active_texture_unit(0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).unbindTexture(); canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
}); });
pp::panopainter::execute_legacy_canvas_draw_merge_temporary_composite(execution); }
void Canvas::draw_merge_temporary_paint_branch(
int layer_index,
int plane_index,
std::shared_ptr<Layer> layer,
const Brush& brush,
const glm::mat4& ortho,
bool copy_blend_destination,
bool draw_checkerboard)
{
(void)draw_checkerboard;
pp::panopainter::execute_legacy_canvas_draw_merge_temporary_composite(
make_canvas_draw_merge_temporary_paint_request(
*this,
layer_index,
plane_index,
layer,
brush,
ortho));
} }
void Canvas::draw_merge_branch_orchestration( void Canvas::draw_merge_branch_orchestration(