Extract draw merge erase branch helper

This commit is contained in:
2026-06-13 22:47:28 +02:00
parent 42d4f6df1b
commit e8fdd96d37
5 changed files with 94 additions and 10 deletions

View File

@@ -1439,10 +1439,10 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
m_current_stroke && m_show_tmp && m_current_layer_idx == layer_index,
use_blend,
pp::panopainter::LegacyCanvasDrawMergeLayerCompositeExecution {
.execute_temporary_erase = [&] {
.execute_temporary_erase = [&] {
pp::panopainter::execute_legacy_canvas_draw_merge_temporary_composite(
pp::panopainter::LegacyCanvasDrawMergeTemporaryCompositeExecution {
.setup = [&] {
pp::panopainter::make_legacy_canvas_draw_merge_temporary_erase_composite(
[&] {
//ShaderManager::u_vec2(kShaderUniform::Resolution, zw(m_box) / zoom);
//ShaderManager::u_int(kShaderUniform::Lock, m_layers[layer_index]->m_alpha_locked);
pp::panopainter::setup_legacy_stroke_erase_shader(
@@ -1455,12 +1455,12 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
.mask_enabled = m_smask_active,
});
},
.bind_samplers = [&] {
[&] {
m_sampler.bind(0);
m_sampler.bind(1);
m_sampler.bind(2);
},
.bind_textures = [&] {
[&] {
set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture();
set_active_texture_unit(1);
@@ -1468,17 +1468,16 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
set_active_texture_unit(2);
m_smask.rtt(plane_index).bindTexture();
},
.draw = [&] {
[&] {
m_plane.draw_fill();
},
.unbind_textures = [&] {
[&] {
m_smask.rtt(plane_index).unbindTexture();
set_active_texture_unit(1);
m_tmp[plane_index].unbindTexture();
set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).unbindTexture();
},
});
}));
},
.execute_temporary_paint = [&] {
const auto stroke_material = canvas_stroke_material_plan(*b, false);

View File

@@ -102,6 +102,28 @@ struct LegacyCanvasDrawMergeTemporaryCompositeExecution {
std::function<void()> unbind_textures;
};
template <
typename Setup,
typename BindSamplers,
typename BindTextures,
typename Draw,
typename UnbindTextures>
[[nodiscard]] inline LegacyCanvasDrawMergeTemporaryCompositeExecution make_legacy_canvas_draw_merge_temporary_erase_composite(
Setup&& setup,
BindSamplers&& bind_samplers,
BindTextures&& bind_textures,
Draw&& draw,
UnbindTextures&& unbind_textures)
{
return LegacyCanvasDrawMergeTemporaryCompositeExecution {
.setup = std::forward<Setup>(setup),
.bind_samplers = std::forward<BindSamplers>(bind_samplers),
.bind_textures = std::forward<BindTextures>(bind_textures),
.draw = std::forward<Draw>(draw),
.unbind_textures = std::forward<UnbindTextures>(unbind_textures),
};
}
struct LegacyCanvasDrawMergePlaneSetupUniforms {
LegacyCanvasDrawMergeCheckerboardUniforms checkerboard;
bool use_blend = false;