Use blend gate plan for canvas copy decisions
This commit is contained in:
@@ -32,7 +32,7 @@ pp::renderer::RenderDeviceFeatures node_canvas_stroke_composite_features() noexc
|
||||
return ShaderManager::render_device_features();
|
||||
}
|
||||
|
||||
bool node_canvas_needs_shader_blend(
|
||||
pp::paint_renderer::CanvasBlendGatePlan node_canvas_blend_gate_plan(
|
||||
int width,
|
||||
int height,
|
||||
const std::vector<std::shared_ptr<Layer>>& layers,
|
||||
@@ -58,7 +58,15 @@ bool node_canvas_needs_shader_blend(
|
||||
.has_stroke_blend_mode = brush != nullptr,
|
||||
.stroke_blend_mode = brush ? brush->m_blend_mode : 0,
|
||||
});
|
||||
return plan ? plan.value().shader_blend : true;
|
||||
if (plan) {
|
||||
return plan.value();
|
||||
}
|
||||
|
||||
pp::paint_renderer::CanvasBlendGatePlan fallback;
|
||||
fallback.shader_blend = true;
|
||||
fallback.complex_blend = true;
|
||||
fallback.compatibility_fallback = true;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
void run_history_undo_if_available()
|
||||
@@ -290,11 +298,13 @@ void NodeCanvas::draw()
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool use_blend = node_canvas_needs_shader_blend(
|
||||
const auto blend_gate = node_canvas_blend_gate_plan(
|
||||
m_cache_rtt.getWidth(),
|
||||
m_cache_rtt.getHeight(),
|
||||
m_canvas->m_layers,
|
||||
m_canvas->m_current_stroke ? m_canvas->m_current_stroke->m_brush.get() : nullptr);
|
||||
const bool use_blend = blend_gate.shader_blend;
|
||||
const bool copy_blend_destination = use_blend && !blend_gate.reads_destination_color;
|
||||
|
||||
if (use_blend)
|
||||
{
|
||||
@@ -485,7 +495,7 @@ void NodeCanvas::draw()
|
||||
|
||||
ShaderManager::use(kShader::TextureBlend);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
if (copy_blend_destination)
|
||||
ShaderManager::u_int(kShaderUniform::TexBG, 2);
|
||||
ShaderManager::u_int(kShaderUniform::BlendMode, m_canvas->m_layers[layer_index]->m_blend_mode);
|
||||
ShaderManager::u_float(kShaderUniform::Alpha, 1.f);
|
||||
@@ -493,7 +503,7 @@ void NodeCanvas::draw()
|
||||
|
||||
set_active_texture_unit(0);
|
||||
m_blender_rtt.bindTexture();
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_blender_bg.bind();
|
||||
@@ -503,7 +513,7 @@ void NodeCanvas::draw()
|
||||
|
||||
m_face_plane.draw_fill();
|
||||
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_blender_bg.unbind();
|
||||
|
||||
Reference in New Issue
Block a user