Use blend gate plan for canvas copy decisions
This commit is contained in:
@@ -49,7 +49,7 @@ pp::renderer::RenderDeviceFeatures canvas_stroke_composite_features() noexcept
|
||||
return ShaderManager::render_device_features();
|
||||
}
|
||||
|
||||
bool draw_merge_needs_shader_blend(
|
||||
pp::paint_renderer::CanvasBlendGatePlan draw_merge_blend_gate_plan(
|
||||
int width,
|
||||
int height,
|
||||
const std::vector<std::shared_ptr<Layer>>& layers,
|
||||
@@ -75,7 +75,15 @@ bool draw_merge_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;
|
||||
}
|
||||
|
||||
GLenum unsigned_byte_component_type()
|
||||
@@ -1121,11 +1129,13 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
||||
auto ortho = glm::ortho<float>(-0.5f, 0.5f, -0.5f, 0.5f, -1.f, 1.f);
|
||||
const auto& b = m_current_stroke->m_brush;
|
||||
|
||||
const bool use_blend = draw_merge_needs_shader_blend(
|
||||
const auto blend_gate = draw_merge_blend_gate_plan(
|
||||
m_width,
|
||||
m_height,
|
||||
m_layers,
|
||||
m_current_stroke ? 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 not using shader blend, use gl rasterizer blend
|
||||
glDisable(depth_test_state());
|
||||
@@ -1289,7 +1299,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
||||
ShaderManager::u_int(kShaderUniform::BlendMode, m_layers[layer_index]->m_blend_mode);
|
||||
ShaderManager::u_float(kShaderUniform::Alpha, 1.f);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, ortho);
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
m_sampler.bind(2);
|
||||
ShaderManager::u_int(kShaderUniform::TexBG, 2);
|
||||
@@ -1297,7 +1307,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
||||
|
||||
set_active_texture_unit(0);
|
||||
m_merge_rtt.bindTexture();
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_merge_tex.bind();
|
||||
@@ -1306,7 +1316,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
||||
|
||||
m_plane.draw_fill();
|
||||
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_merge_tex.unbind();
|
||||
|
||||
Reference in New Issue
Block a user