Extract draw merge branch dispatch helpers
This commit is contained in:
115
src/canvas.cpp
115
src/canvas.cpp
@@ -537,8 +537,63 @@ 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,
|
||||||
|
layer_index,
|
||||||
|
layer,
|
||||||
|
ortho);
|
||||||
|
},
|
||||||
|
.execute_temporary_paint = [&] {
|
||||||
|
canvas.draw_merge_temporary_paint_branch(
|
||||||
|
layer_index,
|
||||||
|
plane_index,
|
||||||
|
layer,
|
||||||
|
brush,
|
||||||
|
ortho,
|
||||||
|
copy_blend_destination,
|
||||||
|
draw_checkerboard);
|
||||||
|
},
|
||||||
|
.execute_layer_texture = [&] {
|
||||||
|
execute_canvas_draw_merge_layer_texture(
|
||||||
|
pp::panopainter::LegacyCanvasDrawMergeTextureAlphaUniforms {
|
||||||
|
.mvp = ortho,
|
||||||
|
.texture_slot = 0,
|
||||||
|
.alpha = layer->m_opacity,
|
||||||
|
.highlight = layer->m_hightlight,
|
||||||
|
},
|
||||||
|
make_canvas_draw_merge_layer_texture_dispatch(
|
||||||
|
canvas,
|
||||||
|
plane_index,
|
||||||
|
layer_index));
|
||||||
|
},
|
||||||
|
.execute_layer_blend = [&] {
|
||||||
|
execute_canvas_draw_merge_layer_blend(
|
||||||
|
pp::panopainter::LegacyCanvasDrawMergeLayerBlendUniforms {
|
||||||
|
.shader = {
|
||||||
|
.mvp = ortho,
|
||||||
|
.texture_slot = 0,
|
||||||
|
.destination_texture_slot = 2,
|
||||||
|
.use_destination_texture = copy_blend_destination,
|
||||||
|
.blend_mode = layer->m_blend_mode,
|
||||||
|
.alpha = 1.f,
|
||||||
|
},
|
||||||
|
.copy_destination = copy_blend_destination,
|
||||||
|
},
|
||||||
|
make_canvas_draw_merge_layer_blend_dispatch(
|
||||||
|
canvas));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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::setup_legacy_stroke_erase_shader(
|
||||||
pp::panopainter::LegacyStrokeEraseUniforms {
|
pp::panopainter::LegacyStrokeEraseUniforms {
|
||||||
@@ -572,27 +627,15 @@ static void execute_canvas_draw_merge_branch_body(
|
|||||||
canvas.m_tmp[plane_index].unbindTexture();
|
canvas.m_tmp[plane_index].unbindTexture();
|
||||||
set_active_texture_unit(0);
|
set_active_texture_unit(0);
|
||||||
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
}));
|
});
|
||||||
},
|
}
|
||||||
.execute_temporary_paint = [&] {
|
|
||||||
canvas.draw_merge_temporary_paint_branch(
|
static auto make_canvas_draw_merge_layer_texture_dispatch(
|
||||||
layer_index,
|
Canvas& canvas,
|
||||||
plane_index,
|
int plane_index,
|
||||||
layer,
|
int layer_index)
|
||||||
brush,
|
{
|
||||||
ortho,
|
return pp::panopainter::LegacyCanvasDrawMergeLayerTextureExecution {
|
||||||
copy_blend_destination,
|
|
||||||
draw_checkerboard);
|
|
||||||
},
|
|
||||||
.execute_layer_texture = [&] {
|
|
||||||
execute_canvas_draw_merge_layer_texture(
|
|
||||||
pp::panopainter::LegacyCanvasDrawMergeTextureAlphaUniforms {
|
|
||||||
.mvp = ortho,
|
|
||||||
.texture_slot = 0,
|
|
||||||
.alpha = layer->m_opacity,
|
|
||||||
.highlight = layer->m_hightlight,
|
|
||||||
},
|
|
||||||
pp::panopainter::LegacyCanvasDrawMergeLayerTextureExecution {
|
|
||||||
.bind_sampler = [&] {
|
.bind_sampler = [&] {
|
||||||
canvas.m_cam_fov < 20.f ? canvas.m_sampler_nearest.bind(0) : canvas.m_sampler.bind(0);
|
canvas.m_cam_fov < 20.f ? canvas.m_sampler_nearest.bind(0) : canvas.m_sampler.bind(0);
|
||||||
},
|
},
|
||||||
@@ -606,22 +649,12 @@ static void execute_canvas_draw_merge_branch_body(
|
|||||||
.unbind_layer_texture = [&] {
|
.unbind_layer_texture = [&] {
|
||||||
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
canvas.m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
},
|
}
|
||||||
.execute_layer_blend = [&] {
|
|
||||||
execute_canvas_draw_merge_layer_blend(
|
static auto make_canvas_draw_merge_layer_blend_dispatch(Canvas& canvas)
|
||||||
pp::panopainter::LegacyCanvasDrawMergeLayerBlendUniforms {
|
{
|
||||||
.shader = {
|
return pp::panopainter::LegacyCanvasDrawMergeLayerBlendExecution {
|
||||||
.mvp = ortho,
|
|
||||||
.texture_slot = 0,
|
|
||||||
.destination_texture_slot = 2,
|
|
||||||
.use_destination_texture = copy_blend_destination,
|
|
||||||
.blend_mode = layer->m_blend_mode,
|
|
||||||
.alpha = 1.f,
|
|
||||||
},
|
|
||||||
.copy_destination = copy_blend_destination,
|
|
||||||
},
|
|
||||||
pp::panopainter::LegacyCanvasDrawMergeLayerBlendExecution {
|
|
||||||
.unbind_merge_framebuffer = [&] {
|
.unbind_merge_framebuffer = [&] {
|
||||||
canvas.m_merge_rtt.unbindFramebuffer();
|
canvas.m_merge_rtt.unbindFramebuffer();
|
||||||
},
|
},
|
||||||
@@ -651,9 +684,7 @@ static void execute_canvas_draw_merge_branch_body(
|
|||||||
set_active_texture_unit(0);
|
set_active_texture_unit(0);
|
||||||
canvas.m_merge_rtt.unbindTexture();
|
canvas.m_merge_rtt.unbindTexture();
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void execute_canvas_draw_merge_plane_iteration(
|
static void execute_canvas_draw_merge_plane_iteration(
|
||||||
|
|||||||
Reference in New Issue
Block a user