Extract app frame and export dialog helpers
This commit is contained in:
@@ -231,6 +231,170 @@ void run_canvas_tool_mode(pp::app::CanvasToolMode mode)
|
||||
LOG("Canvas input tool action failed: %s", status.message);
|
||||
}
|
||||
|
||||
pp::panopainter::LegacyCanvasDrawMergeLayerPathExecution make_node_canvas_layer_path_execution(
|
||||
NodeCanvas& node_canvas,
|
||||
size_t layer_index,
|
||||
int plane_index,
|
||||
const glm::mat4& plane_mvp_z,
|
||||
const Brush* brush,
|
||||
bool copy_blend_destination,
|
||||
bool use_nearest_sampler)
|
||||
{
|
||||
auto* layer = node_canvas.m_canvas->m_layers[layer_index].get();
|
||||
const auto plane_mvp = plane_mvp_z;
|
||||
const auto brush_ptr = brush;
|
||||
const auto smask_active = node_canvas.m_canvas->m_smask_active;
|
||||
auto draw_layer_frame = pp::panopainter::make_legacy_canvas_draw_merge_layer_frame_draw(
|
||||
layer,
|
||||
&node_canvas.m_face_plane,
|
||||
set_active_texture_unit,
|
||||
plane_index,
|
||||
layer->m_opacity);
|
||||
|
||||
glm::vec2 patt_scale = glm::vec2(brush_ptr->m_pattern_scale);
|
||||
if (brush_ptr->m_pattern_flipx)
|
||||
patt_scale.x *= -1.f;
|
||||
if (brush_ptr->m_pattern_flipy)
|
||||
patt_scale.y *= -1.f;
|
||||
|
||||
return pp::panopainter::make_legacy_canvas_draw_merge_layer_path_gl_execution(
|
||||
{
|
||||
.temporary_erase = {
|
||||
.mvp = plane_mvp,
|
||||
.texture_slot = 0,
|
||||
.stroke_texture_slot = 1,
|
||||
.mask_texture_slot = 2,
|
||||
.mask_enabled = smask_active,
|
||||
},
|
||||
.temporary_paint = {
|
||||
.resolution = Canvas::I->m_size,
|
||||
.pattern = {
|
||||
.scale = patt_scale,
|
||||
.invert = static_cast<float>(brush_ptr->m_pattern_invert),
|
||||
.brightness = brush_ptr->m_pattern_brightness,
|
||||
.contrast = brush_ptr->m_pattern_contrast,
|
||||
.depth = brush_ptr->m_pattern_depth,
|
||||
.blend_mode = brush_ptr->m_pattern_blend_mode,
|
||||
.offset = Canvas::I->m_pattern_offset,
|
||||
},
|
||||
.mvp = plane_mvp,
|
||||
.layer_alpha = 1.0f,
|
||||
.alpha_lock = layer->m_alpha_locked,
|
||||
.mask_enabled = smask_active,
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = brush_ptr->m_blend_mode,
|
||||
.use_dual = brush_ptr->m_dual_enabled,
|
||||
.dual_blend_mode = brush_ptr->m_dual_blend_mode,
|
||||
.dual_alpha = brush_ptr->m_dual_opacity,
|
||||
.use_pattern = brush_ptr->m_pattern_enabled && !brush_ptr->m_pattern_eachsample,
|
||||
},
|
||||
.layer_texture = {
|
||||
.mvp = plane_mvp,
|
||||
.texture_slot = 0,
|
||||
.alpha = 1.f,
|
||||
.highlight = layer->m_hightlight,
|
||||
},
|
||||
.blend = {
|
||||
.shader = {
|
||||
.mvp = glm::ortho(-1, 1, -1, 1),
|
||||
.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,
|
||||
},
|
||||
.use_nearest_sampler = use_nearest_sampler,
|
||||
.use_dual_texture = brush_ptr->m_dual_enabled,
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_rtt.bindFramebuffer();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_rtt.clear();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_rtt.unbindFramebuffer();
|
||||
},
|
||||
[&node_canvas](int unit) {
|
||||
node_canvas.m_sampler.bind(unit);
|
||||
},
|
||||
[&node_canvas](int unit) {
|
||||
node_canvas.m_sampler_nearest.bind(unit);
|
||||
},
|
||||
[&node_canvas](int unit) {
|
||||
node_canvas.m_sampler_stencil.bind(unit);
|
||||
},
|
||||
[](int unit) {
|
||||
set_active_texture_unit(unit);
|
||||
},
|
||||
[&node_canvas, plane_index] {
|
||||
node_canvas.m_canvas->m_tmp[plane_index].bindTexture();
|
||||
},
|
||||
[&node_canvas, plane_index] {
|
||||
node_canvas.m_canvas->m_tmp[plane_index].unbindTexture();
|
||||
},
|
||||
[&node_canvas, plane_index] {
|
||||
node_canvas.m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||
},
|
||||
[&node_canvas, plane_index] {
|
||||
node_canvas.m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||
},
|
||||
[&node_canvas, plane_index] {
|
||||
node_canvas.m_canvas->m_tmp_dual[plane_index].bindTexture();
|
||||
},
|
||||
[&node_canvas, plane_index] {
|
||||
node_canvas.m_canvas->m_tmp_dual[plane_index].unbindTexture();
|
||||
},
|
||||
[brush_ptr] {
|
||||
brush_ptr->m_pattern_texture ? brush_ptr->m_pattern_texture->bind() : unbind_texture_2d();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_face_plane.draw_fill();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_rtt.bindTexture();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_rtt.unbindTexture();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_bg.bind();
|
||||
},
|
||||
[&node_canvas] {
|
||||
node_canvas.m_blender_bg.unbind();
|
||||
},
|
||||
[&node_canvas] {
|
||||
copy_framebuffer_to_texture_2d(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
node_canvas.m_blender_bg.size().x,
|
||||
node_canvas.m_blender_bg.size().y);
|
||||
},
|
||||
#ifdef _DEBUG
|
||||
[&node_canvas, layer_index, plane_index, plane_mvp] {
|
||||
auto bb = node_canvas.m_canvas->m_layers[layer_index]->box(plane_index) / (float)node_canvas.m_canvas->m_layers[layer_index]->w;
|
||||
glm::vec2 bbmin = xy(bb);
|
||||
glm::vec2 bbsz = zw(bb) - xy(bb);
|
||||
pp::panopainter::configure_legacy_ui_color_shader(
|
||||
plane_mvp
|
||||
* glm::translate(glm::vec3(bbmin * 2.f, 0))
|
||||
* glm::translate(glm::vec3(-1, -1, 0))
|
||||
* glm::scale(glm::vec3(bbsz, 1))
|
||||
* glm::translate(glm::vec3(1, 1, 0)),
|
||||
{ 1, 0, 0, 1 });
|
||||
node_canvas.m_face_plane.draw_stroke();
|
||||
},
|
||||
#else
|
||||
[] {
|
||||
},
|
||||
#endif
|
||||
draw_layer_frame);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Node* NodeCanvas::clone_instantiate() const
|
||||
@@ -467,161 +631,14 @@ void NodeCanvas::draw()
|
||||
glm::eulerAngleYXZ(yaw, pitch, roll) *
|
||||
m_canvas->m_plane_transform[plane_index] *
|
||||
glm::translate(glm::vec3(0, 0, -1));
|
||||
|
||||
const auto draw_layer_frame = pp::panopainter::make_legacy_canvas_draw_merge_layer_frame_draw(
|
||||
m_canvas->m_layers[layer_index].get(),
|
||||
&m_face_plane,
|
||||
set_active_texture_unit,
|
||||
const auto layer_path_execution = make_node_canvas_layer_path_execution(
|
||||
*this,
|
||||
layer_index,
|
||||
plane_index,
|
||||
m_canvas->m_layers[layer_index]->m_opacity);
|
||||
|
||||
glm::vec2 patt_scale = glm::vec2(b->m_pattern_scale);
|
||||
if (b->m_pattern_flipx)
|
||||
patt_scale.x *= -1.f;
|
||||
if (b->m_pattern_flipy)
|
||||
patt_scale.y *= -1.f;
|
||||
|
||||
const auto layer_path_execution = pp::panopainter::make_legacy_canvas_draw_merge_layer_path_gl_execution(
|
||||
{
|
||||
.temporary_erase = {
|
||||
.mvp = plane_mvp_z,
|
||||
.texture_slot = 0,
|
||||
.stroke_texture_slot = 1,
|
||||
.mask_texture_slot = 2,
|
||||
.mask_enabled = m_canvas->m_smask_active,
|
||||
},
|
||||
.temporary_paint = {
|
||||
.resolution = Canvas::I->m_size,
|
||||
.pattern = {
|
||||
.scale = patt_scale,
|
||||
.invert = static_cast<float>(b->m_pattern_invert),
|
||||
.brightness = b->m_pattern_brightness,
|
||||
.contrast = b->m_pattern_contrast,
|
||||
.depth = b->m_pattern_depth,
|
||||
.blend_mode = b->m_pattern_blend_mode,
|
||||
.offset = Canvas::I->m_pattern_offset,
|
||||
},
|
||||
.mvp = plane_mvp_z,
|
||||
.layer_alpha = 1.0f,
|
||||
.alpha_lock = m_canvas->m_layers[layer_index]->m_alpha_locked,
|
||||
.mask_enabled = m_canvas->m_smask_active,
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = b->m_dual_enabled,
|
||||
.dual_blend_mode = b->m_dual_blend_mode,
|
||||
.dual_alpha = b->m_dual_opacity,
|
||||
.use_pattern = b->m_pattern_enabled && !b->m_pattern_eachsample,
|
||||
},
|
||||
.layer_texture = {
|
||||
.mvp = plane_mvp_z,
|
||||
.texture_slot = 0,
|
||||
.alpha = 1.f,
|
||||
.highlight = m_canvas->m_layers[layer_index]->m_hightlight,
|
||||
},
|
||||
.blend = {
|
||||
.shader = {
|
||||
.mvp = glm::ortho(-1, 1, -1, 1),
|
||||
.texture_slot = 0,
|
||||
.destination_texture_slot = 2,
|
||||
.use_destination_texture = copy_blend_destination,
|
||||
.blend_mode = m_canvas->m_layers[layer_index]->m_blend_mode,
|
||||
.alpha = 1.f,
|
||||
},
|
||||
.copy_destination = copy_blend_destination,
|
||||
},
|
||||
.use_nearest_sampler = m_canvas->m_cam_fov < 20.f,
|
||||
.use_dual_texture = b->m_dual_enabled,
|
||||
},
|
||||
{
|
||||
.bind_blender_framebuffer = [&] {
|
||||
m_blender_rtt.bindFramebuffer();
|
||||
},
|
||||
.clear_blender_framebuffer = [&] {
|
||||
m_blender_rtt.clear();
|
||||
},
|
||||
.unbind_blender_framebuffer = [&] {
|
||||
m_blender_rtt.unbindFramebuffer();
|
||||
},
|
||||
.bind_sampler = [&](int unit) {
|
||||
m_sampler.bind(unit);
|
||||
},
|
||||
.bind_nearest_sampler = [&](int unit) {
|
||||
m_sampler_nearest.bind(unit);
|
||||
},
|
||||
.bind_stencil_sampler = [&](int unit) {
|
||||
m_sampler_stencil.bind(unit);
|
||||
},
|
||||
.set_active_texture_unit = [&](int unit) {
|
||||
set_active_texture_unit(unit);
|
||||
},
|
||||
.bind_temporary_texture = [&] {
|
||||
m_canvas->m_tmp[plane_index].bindTexture();
|
||||
},
|
||||
.unbind_temporary_texture = [&] {
|
||||
m_canvas->m_tmp[plane_index].unbindTexture();
|
||||
},
|
||||
.bind_smask_texture = [&] {
|
||||
m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||
},
|
||||
.unbind_smask_texture = [&] {
|
||||
m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||
},
|
||||
.bind_temporary_dual_texture = [&] {
|
||||
m_canvas->m_tmp_dual[plane_index].bindTexture();
|
||||
},
|
||||
.unbind_temporary_dual_texture = [&] {
|
||||
m_canvas->m_tmp_dual[plane_index].unbindTexture();
|
||||
},
|
||||
.bind_pattern_texture = [&] {
|
||||
b->m_pattern_texture ?
|
||||
b->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
.draw_face = [&] {
|
||||
m_face_plane.draw_fill();
|
||||
},
|
||||
.bind_blender_texture = [&] {
|
||||
m_blender_rtt.bindTexture();
|
||||
},
|
||||
.unbind_blender_texture = [&] {
|
||||
m_blender_rtt.unbindTexture();
|
||||
},
|
||||
.bind_destination_texture = [&] {
|
||||
m_blender_bg.bind();
|
||||
},
|
||||
.unbind_destination_texture = [&] {
|
||||
m_blender_bg.unbind();
|
||||
},
|
||||
.copy_destination_framebuffer = [&] {
|
||||
copy_framebuffer_to_texture_2d(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
m_blender_bg.size().x,
|
||||
m_blender_bg.size().y);
|
||||
},
|
||||
.draw_debug_outline =
|
||||
#ifdef _DEBUG
|
||||
[&] {
|
||||
auto bb = m_canvas->m_layers[layer_index]->box(plane_index) / (float)m_canvas->m_layers[layer_index]->w;
|
||||
glm::vec2 bbmin = xy(bb);
|
||||
glm::vec2 bbsz = zw(bb) - xy(bb);
|
||||
pp::panopainter::configure_legacy_ui_color_shader(
|
||||
plane_mvp_z
|
||||
* glm::translate(glm::vec3(bbmin * 2.f, 0))
|
||||
* glm::translate(glm::vec3(-1, -1, 0))
|
||||
* glm::scale(glm::vec3(bbsz, 1))
|
||||
* glm::translate(glm::vec3(1, 1, 0)),
|
||||
{ 1, 0, 0, 1 });
|
||||
m_face_plane.draw_stroke();
|
||||
},
|
||||
#else
|
||||
[] {
|
||||
},
|
||||
#endif
|
||||
.draw_frame = draw_layer_frame,
|
||||
});
|
||||
plane_mvp_z,
|
||||
b.get(),
|
||||
copy_blend_destination,
|
||||
m_canvas->m_cam_fov < 20.f);
|
||||
|
||||
pp::panopainter::execute_legacy_canvas_draw_merge_layer_path(
|
||||
m_canvas->m_current_stroke && m_canvas->m_current_mode == kCanvasMode::Erase && m_canvas->m_show_tmp && m_canvas->m_current_layer_idx == layer_index,
|
||||
|
||||
Reference in New Issue
Block a user