Extract draw merge branch dispatch helpers
This commit is contained in:
195
src/canvas.cpp
195
src/canvas.cpp
@@ -537,42 +537,12 @@ static void execute_canvas_draw_merge_branch_body(
|
|||||||
use_blend,
|
use_blend,
|
||||||
pp::panopainter::LegacyCanvasDrawMergeLayerCompositeExecution {
|
pp::panopainter::LegacyCanvasDrawMergeLayerCompositeExecution {
|
||||||
.execute_temporary_erase = [&] {
|
.execute_temporary_erase = [&] {
|
||||||
pp::panopainter::execute_legacy_canvas_draw_merge_temporary_composite(
|
execute_canvas_draw_merge_temporary_erase_dispatch(
|
||||||
pp::panopainter::make_legacy_canvas_draw_merge_temporary_erase_composite(
|
canvas,
|
||||||
[&] {
|
plane_index,
|
||||||
pp::panopainter::setup_legacy_stroke_erase_shader(
|
layer_index,
|
||||||
pp::panopainter::LegacyStrokeEraseUniforms {
|
layer,
|
||||||
.mvp = ortho,
|
ortho);
|
||||||
.texture_slot = 0,
|
|
||||||
.stroke_texture_slot = 1,
|
|
||||||
.mask_texture_slot = 2,
|
|
||||||
.alpha = layer->m_opacity,
|
|
||||||
.mask_enabled = canvas.m_smask_active,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
canvas.m_sampler.bind(0);
|
|
||||||
canvas.m_sampler.bind(1);
|
|
||||||
canvas.m_sampler.bind(2);
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
set_active_texture_unit(0);
|
|
||||||
canvas.m_layers[layer_index]->rtt(plane_index).bindTexture();
|
|
||||||
set_active_texture_unit(1);
|
|
||||||
canvas.m_tmp[plane_index].bindTexture();
|
|
||||||
set_active_texture_unit(2);
|
|
||||||
canvas.m_smask.rtt(plane_index).bindTexture();
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
canvas.m_plane.draw_fill();
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
canvas.m_smask.rtt(plane_index).unbindTexture();
|
|
||||||
set_active_texture_unit(1);
|
|
||||||
canvas.m_tmp[plane_index].unbindTexture();
|
|
||||||
set_active_texture_unit(0);
|
|
||||||
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
.execute_temporary_paint = [&] {
|
.execute_temporary_paint = [&] {
|
||||||
canvas.draw_merge_temporary_paint_branch(
|
canvas.draw_merge_temporary_paint_branch(
|
||||||
@@ -592,21 +562,10 @@ static void execute_canvas_draw_merge_branch_body(
|
|||||||
.alpha = layer->m_opacity,
|
.alpha = layer->m_opacity,
|
||||||
.highlight = layer->m_hightlight,
|
.highlight = layer->m_hightlight,
|
||||||
},
|
},
|
||||||
pp::panopainter::LegacyCanvasDrawMergeLayerTextureExecution {
|
make_canvas_draw_merge_layer_texture_dispatch(
|
||||||
.bind_sampler = [&] {
|
canvas,
|
||||||
canvas.m_cam_fov < 20.f ? canvas.m_sampler_nearest.bind(0) : canvas.m_sampler.bind(0);
|
plane_index,
|
||||||
},
|
layer_index));
|
||||||
.bind_layer_texture = [&] {
|
|
||||||
set_active_texture_unit(0);
|
|
||||||
canvas.m_layers[layer_index]->rtt(plane_index).bindTexture();
|
|
||||||
},
|
|
||||||
.draw = [&] {
|
|
||||||
canvas.m_plane.draw_fill();
|
|
||||||
},
|
|
||||||
.unbind_layer_texture = [&] {
|
|
||||||
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
.execute_layer_blend = [&] {
|
.execute_layer_blend = [&] {
|
||||||
execute_canvas_draw_merge_layer_blend(
|
execute_canvas_draw_merge_layer_blend(
|
||||||
@@ -621,41 +580,113 @@ static void execute_canvas_draw_merge_branch_body(
|
|||||||
},
|
},
|
||||||
.copy_destination = copy_blend_destination,
|
.copy_destination = copy_blend_destination,
|
||||||
},
|
},
|
||||||
pp::panopainter::LegacyCanvasDrawMergeLayerBlendExecution {
|
make_canvas_draw_merge_layer_blend_dispatch(
|
||||||
.unbind_merge_framebuffer = [&] {
|
canvas));
|
||||||
canvas.m_merge_rtt.unbindFramebuffer();
|
|
||||||
},
|
|
||||||
.bind_samplers = [&] {
|
|
||||||
canvas.m_sampler.bind(0);
|
|
||||||
canvas.m_sampler.bind(2);
|
|
||||||
},
|
|
||||||
.bind_merge_texture = [&] {
|
|
||||||
set_active_texture_unit(0);
|
|
||||||
canvas.m_merge_rtt.bindTexture();
|
|
||||||
},
|
|
||||||
.bind_destination_texture = [&] {
|
|
||||||
set_active_texture_unit(2);
|
|
||||||
canvas.m_merge_tex.bind();
|
|
||||||
},
|
|
||||||
.copy_destination_framebuffer = [&] {
|
|
||||||
copy_framebuffer_to_texture_2d(0, 0, 0, 0, canvas.m_width, canvas.m_height);
|
|
||||||
},
|
|
||||||
.draw = [&] {
|
|
||||||
canvas.m_plane.draw_fill();
|
|
||||||
},
|
|
||||||
.unbind_destination_texture = [&] {
|
|
||||||
set_active_texture_unit(2);
|
|
||||||
canvas.m_merge_tex.unbind();
|
|
||||||
},
|
|
||||||
.unbind_merge_texture = [&] {
|
|
||||||
set_active_texture_unit(0);
|
|
||||||
canvas.m_merge_rtt.unbindTexture();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static auto make_canvas_draw_merge_temporary_erase_dispatch(
|
||||||
|
Canvas& canvas,
|
||||||
|
int plane_index,
|
||||||
|
int layer_index,
|
||||||
|
const std::shared_ptr<Layer>& layer,
|
||||||
|
const glm::mat4& ortho)
|
||||||
|
{
|
||||||
|
return pp::panopainter::make_legacy_canvas_draw_merge_temporary_erase_composite(
|
||||||
|
[&] {
|
||||||
|
pp::panopainter::setup_legacy_stroke_erase_shader(
|
||||||
|
pp::panopainter::LegacyStrokeEraseUniforms {
|
||||||
|
.mvp = ortho,
|
||||||
|
.texture_slot = 0,
|
||||||
|
.stroke_texture_slot = 1,
|
||||||
|
.mask_texture_slot = 2,
|
||||||
|
.alpha = layer->m_opacity,
|
||||||
|
.mask_enabled = canvas.m_smask_active,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
canvas.m_sampler.bind(0);
|
||||||
|
canvas.m_sampler.bind(1);
|
||||||
|
canvas.m_sampler.bind(2);
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
canvas.m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||||
|
set_active_texture_unit(1);
|
||||||
|
canvas.m_tmp[plane_index].bindTexture();
|
||||||
|
set_active_texture_unit(2);
|
||||||
|
canvas.m_smask.rtt(plane_index).bindTexture();
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
canvas.m_plane.draw_fill();
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
canvas.m_smask.rtt(plane_index).unbindTexture();
|
||||||
|
set_active_texture_unit(1);
|
||||||
|
canvas.m_tmp[plane_index].unbindTexture();
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static auto make_canvas_draw_merge_layer_texture_dispatch(
|
||||||
|
Canvas& canvas,
|
||||||
|
int plane_index,
|
||||||
|
int layer_index)
|
||||||
|
{
|
||||||
|
return pp::panopainter::LegacyCanvasDrawMergeLayerTextureExecution {
|
||||||
|
.bind_sampler = [&] {
|
||||||
|
canvas.m_cam_fov < 20.f ? canvas.m_sampler_nearest.bind(0) : canvas.m_sampler.bind(0);
|
||||||
|
},
|
||||||
|
.bind_layer_texture = [&] {
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
canvas.m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||||
|
},
|
||||||
|
.draw = [&] {
|
||||||
|
canvas.m_plane.draw_fill();
|
||||||
|
},
|
||||||
|
.unbind_layer_texture = [&] {
|
||||||
|
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static auto make_canvas_draw_merge_layer_blend_dispatch(Canvas& canvas)
|
||||||
|
{
|
||||||
|
return pp::panopainter::LegacyCanvasDrawMergeLayerBlendExecution {
|
||||||
|
.unbind_merge_framebuffer = [&] {
|
||||||
|
canvas.m_merge_rtt.unbindFramebuffer();
|
||||||
|
},
|
||||||
|
.bind_samplers = [&] {
|
||||||
|
canvas.m_sampler.bind(0);
|
||||||
|
canvas.m_sampler.bind(2);
|
||||||
|
},
|
||||||
|
.bind_merge_texture = [&] {
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
canvas.m_merge_rtt.bindTexture();
|
||||||
|
},
|
||||||
|
.bind_destination_texture = [&] {
|
||||||
|
set_active_texture_unit(2);
|
||||||
|
canvas.m_merge_tex.bind();
|
||||||
|
},
|
||||||
|
.copy_destination_framebuffer = [&] {
|
||||||
|
copy_framebuffer_to_texture_2d(0, 0, 0, 0, canvas.m_width, canvas.m_height);
|
||||||
|
},
|
||||||
|
.draw = [&] {
|
||||||
|
canvas.m_plane.draw_fill();
|
||||||
|
},
|
||||||
|
.unbind_destination_texture = [&] {
|
||||||
|
set_active_texture_unit(2);
|
||||||
|
canvas.m_merge_tex.unbind();
|
||||||
|
},
|
||||||
|
.unbind_merge_texture = [&] {
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
canvas.m_merge_rtt.unbindTexture();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void execute_canvas_draw_merge_plane_iteration(
|
static void execute_canvas_draw_merge_plane_iteration(
|
||||||
Canvas& canvas,
|
Canvas& canvas,
|
||||||
const std::array<bool, 6>& faces,
|
const std::array<bool, 6>& faces,
|
||||||
|
|||||||
Reference in New Issue
Block a user