Extract draw merge temporary paint branch
This commit is contained in:
156
src/canvas.cpp
156
src/canvas.cpp
@@ -931,6 +931,84 @@ void Canvas::stroke_draw_pad_face_callback_body(
|
|||||||
pad_color);
|
pad_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
const auto stroke_material = canvas_stroke_material_plan(*brush, false);
|
||||||
|
glm::vec2 patt_scale = glm::vec2(brush->m_pattern_scale);
|
||||||
|
if (brush->m_pattern_flipx) patt_scale.x *= -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(
|
||||||
|
[&] {
|
||||||
|
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||||
|
pp::panopainter::LegacyStrokeCompositeUniforms {
|
||||||
|
.resolution = Canvas::I->m_size,
|
||||||
|
.pattern = {
|
||||||
|
.scale = patt_scale,
|
||||||
|
.invert = static_cast<float>(brush->m_pattern_invert),
|
||||||
|
.brightness = brush->m_pattern_brightness,
|
||||||
|
.contrast = brush->m_pattern_contrast,
|
||||||
|
.depth = brush->m_pattern_depth,
|
||||||
|
.blend_mode = brush->m_pattern_blend_mode,
|
||||||
|
.offset = Canvas::I->m_pattern_offset,
|
||||||
|
},
|
||||||
|
.mvp = ortho,
|
||||||
|
.layer_alpha = layer->m_opacity,
|
||||||
|
.alpha_lock = layer->m_alpha_locked,
|
||||||
|
.mask_enabled = m_smask_active,
|
||||||
|
.use_fragcoord = false,
|
||||||
|
.blend_mode = brush->m_blend_mode,
|
||||||
|
.use_dual = stroke_material.composite_pass.use_dual,
|
||||||
|
.dual_blend_mode = stroke_material.composite_pass.dual_blend_mode,
|
||||||
|
.dual_alpha = stroke_material.composite_pass.dual_alpha,
|
||||||
|
.use_pattern = stroke_material.composite_pass.use_pattern,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
m_sampler.bind(0);
|
||||||
|
m_sampler.bind(1);
|
||||||
|
m_sampler.bind(2);
|
||||||
|
m_sampler.bind(3);
|
||||||
|
m_sampler_stencil.bind(4);
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||||
|
set_active_texture_unit(1);
|
||||||
|
m_tmp[plane_index].bindTexture();
|
||||||
|
set_active_texture_unit(2);
|
||||||
|
m_smask.rtt(plane_index).bindTexture();
|
||||||
|
set_active_texture_unit(3);
|
||||||
|
if (stroke_material.composite_pass.use_dual)
|
||||||
|
m_tmp_dual[plane_index].bindTexture();
|
||||||
|
set_active_texture_unit(4);
|
||||||
|
brush->m_pattern_texture ? brush->m_pattern_texture->bind() : unbind_texture_2d();
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
m_plane.draw_fill();
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
set_active_texture_unit(3);
|
||||||
|
if (stroke_material.composite_pass.use_dual)
|
||||||
|
m_tmp_dual[plane_index].unbindTexture();
|
||||||
|
set_active_texture_unit(2);
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
pp::panopainter::execute_legacy_canvas_draw_merge_temporary_composite(execution);
|
||||||
|
}
|
||||||
|
|
||||||
void Canvas::stroke_draw_dual_pass(
|
void Canvas::stroke_draw_dual_pass(
|
||||||
const std::vector<StrokeFrame>& frames_dual,
|
const std::vector<StrokeFrame>& frames_dual,
|
||||||
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
|
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
|
||||||
@@ -1558,75 +1636,15 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
|||||||
m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
.execute_temporary_paint = [&] {
|
.execute_temporary_paint = [&] {
|
||||||
const auto stroke_material = canvas_stroke_material_plan(*b, false);
|
draw_merge_temporary_paint_branch(
|
||||||
glm::vec2 patt_scale = glm::vec2(b->m_pattern_scale);
|
layer_index,
|
||||||
if (b->m_pattern_flipx) patt_scale.x *= -1.f;
|
plane_index,
|
||||||
if (b->m_pattern_flipy) patt_scale.y *= -1.f;
|
m_layers[layer_index],
|
||||||
|
*b,
|
||||||
const auto execution = pp::panopainter::make_legacy_canvas_draw_merge_temporary_paint_composite(
|
ortho,
|
||||||
[&] {
|
copy_blend_destination,
|
||||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
draw_checkerboard);
|
||||||
pp::panopainter::LegacyStrokeCompositeUniforms {
|
|
||||||
.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 = ortho,
|
|
||||||
.layer_alpha = m_layers[layer_index]->m_opacity,
|
|
||||||
.alpha_lock = m_layers[layer_index]->m_alpha_locked,
|
|
||||||
.mask_enabled = m_smask_active,
|
|
||||||
.use_fragcoord = false,
|
|
||||||
.blend_mode = b->m_blend_mode,
|
|
||||||
.use_dual = stroke_material.composite_pass.use_dual,
|
|
||||||
.dual_blend_mode = stroke_material.composite_pass.dual_blend_mode,
|
|
||||||
.dual_alpha = stroke_material.composite_pass.dual_alpha,
|
|
||||||
.use_pattern = stroke_material.composite_pass.use_pattern,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
m_sampler.bind(0);
|
|
||||||
m_sampler.bind(1);
|
|
||||||
m_sampler.bind(2);
|
|
||||||
m_sampler.bind(3);
|
|
||||||
m_sampler_stencil.bind(4);
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
set_active_texture_unit(0);
|
|
||||||
m_layers[layer_index]->rtt(plane_index).bindTexture();
|
|
||||||
set_active_texture_unit(1);
|
|
||||||
m_tmp[plane_index].bindTexture();
|
|
||||||
set_active_texture_unit(2);
|
|
||||||
m_smask.rtt(plane_index).bindTexture();
|
|
||||||
set_active_texture_unit(3);
|
|
||||||
if (stroke_material.composite_pass.use_dual)
|
|
||||||
m_tmp_dual[plane_index].bindTexture();
|
|
||||||
set_active_texture_unit(4);
|
|
||||||
b->m_pattern_texture ?
|
|
||||||
b->m_pattern_texture->bind() :
|
|
||||||
unbind_texture_2d();
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
m_plane.draw_fill();
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
set_active_texture_unit(3);
|
|
||||||
if (stroke_material.composite_pass.use_dual)
|
|
||||||
m_tmp_dual[plane_index].unbindTexture();
|
|
||||||
set_active_texture_unit(2);
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
pp::panopainter::execute_legacy_canvas_draw_merge_temporary_composite(execution);
|
|
||||||
},
|
},
|
||||||
.execute_layer_texture = [&] {
|
.execute_layer_texture = [&] {
|
||||||
execute_canvas_draw_merge_layer_texture(
|
execute_canvas_draw_merge_layer_texture(
|
||||||
|
|||||||
@@ -259,6 +259,14 @@ private:
|
|||||||
bool copy_stroke_destination,
|
bool copy_stroke_destination,
|
||||||
const pp::renderer::Extent2D& stroke_extent,
|
const pp::renderer::Extent2D& stroke_extent,
|
||||||
const glm::vec4& pad_color);
|
const glm::vec4& pad_color);
|
||||||
|
void 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 stroke_draw_dual_pass(
|
void stroke_draw_dual_pass(
|
||||||
const std::vector<StrokeFrame>& frames_dual,
|
const std::vector<StrokeFrame>& frames_dual,
|
||||||
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
|
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
|
||||||
|
|||||||
Reference in New Issue
Block a user