Route NodeCanvas erase setup through helper

This commit is contained in:
2026-06-13 05:17:10 +02:00
parent b46b2c3184
commit a57d9f18f2
4 changed files with 67 additions and 6 deletions

View File

@@ -0,0 +1,49 @@
#pragma once
#include "shader.h"
#include <functional>
namespace pp::panopainter {
struct LegacyStrokeEraseUniforms {
glm::mat4 mvp { 1.0f };
int texture_slot = 0;
int stroke_texture_slot = 1;
int mask_texture_slot = 2;
bool mask_enabled = false;
};
struct LegacyStrokeEraseShaderExecution {
std::function<void(kShader)> use_shader;
std::function<void(kShaderUniform, int)> set_int;
std::function<void(kShaderUniform, const glm::mat4&)> set_mat4;
};
[[nodiscard]] inline LegacyStrokeEraseShaderExecution legacy_shader_manager_stroke_erase_execution() noexcept
{
return {
.use_shader = [](kShader shader) { ShaderManager::use(shader); },
.set_int = [](kShaderUniform uniform, int value) { ShaderManager::u_int(uniform, value); },
.set_mat4 = [](kShaderUniform uniform, const glm::mat4& value) { ShaderManager::u_mat4(uniform, value); },
};
}
inline void setup_legacy_stroke_erase_shader(
const LegacyStrokeEraseUniforms& uniforms,
const LegacyStrokeEraseShaderExecution& execution) noexcept
{
execution.use_shader(kShader::CompErase);
execution.set_int(kShaderUniform::Tex, uniforms.texture_slot);
execution.set_int(kShaderUniform::TexStroke, uniforms.stroke_texture_slot);
execution.set_int(kShaderUniform::TexMask, uniforms.mask_texture_slot);
execution.set_int(kShaderUniform::Mask, uniforms.mask_enabled);
execution.set_mat4(kShaderUniform::MVP, uniforms.mvp);
}
inline void setup_legacy_stroke_erase_shader(const LegacyStrokeEraseUniforms& uniforms)
{
setup_legacy_stroke_erase_shader(uniforms, legacy_shader_manager_stroke_erase_execution());
}
} // namespace pp::panopainter