Extract dialog, VR, and canvas draw helpers
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "legacy_canvas_stroke_composite_services.h"
|
||||
#include "legacy_canvas_stroke_erase_services.h"
|
||||
#include "shader.h"
|
||||
|
||||
#include <array>
|
||||
@@ -130,6 +132,40 @@ struct LegacyCanvasDrawMergeLayerPathExecution {
|
||||
std::function<void(int, float)> draw_frame;
|
||||
};
|
||||
|
||||
struct LegacyCanvasDrawMergeLayerPathGlUniforms {
|
||||
LegacyStrokeEraseUniforms temporary_erase;
|
||||
LegacyStrokeCompositeUniforms temporary_paint;
|
||||
LegacyCanvasDrawMergeTextureAlphaUniforms layer_texture;
|
||||
LegacyCanvasDrawMergeLayerBlendUniforms blend;
|
||||
bool use_nearest_sampler = false;
|
||||
bool use_dual_texture = false;
|
||||
};
|
||||
|
||||
struct LegacyCanvasDrawMergeLayerPathGlExecution {
|
||||
std::function<void()> bind_blender_framebuffer;
|
||||
std::function<void()> clear_blender_framebuffer;
|
||||
std::function<void()> unbind_blender_framebuffer;
|
||||
std::function<void(int)> bind_sampler;
|
||||
std::function<void(int)> bind_nearest_sampler;
|
||||
std::function<void(int)> bind_stencil_sampler;
|
||||
std::function<void(int)> set_active_texture_unit;
|
||||
std::function<void()> bind_temporary_texture;
|
||||
std::function<void()> unbind_temporary_texture;
|
||||
std::function<void()> bind_smask_texture;
|
||||
std::function<void()> unbind_smask_texture;
|
||||
std::function<void()> bind_temporary_dual_texture;
|
||||
std::function<void()> unbind_temporary_dual_texture;
|
||||
std::function<void()> bind_pattern_texture;
|
||||
std::function<void()> draw_face;
|
||||
std::function<void()> bind_blender_texture;
|
||||
std::function<void()> unbind_blender_texture;
|
||||
std::function<void()> bind_destination_texture;
|
||||
std::function<void()> unbind_destination_texture;
|
||||
std::function<void()> copy_destination_framebuffer;
|
||||
std::function<void()> draw_debug_outline;
|
||||
std::function<void(int, float)> draw_frame;
|
||||
};
|
||||
|
||||
struct LegacyCanvasDrawLayerVisit {
|
||||
size_t layer_index = 0;
|
||||
int plane_index = 0;
|
||||
@@ -679,6 +715,102 @@ inline void execute_legacy_canvas_draw_merge_layer_path(
|
||||
execution.draw_debug_outline();
|
||||
}
|
||||
|
||||
[[nodiscard]] inline LegacyCanvasDrawMergeLayerPathExecution make_legacy_canvas_draw_merge_layer_path_gl_execution(
|
||||
const LegacyCanvasDrawMergeLayerPathGlUniforms& uniforms,
|
||||
const LegacyCanvasDrawMergeLayerPathGlExecution& execution)
|
||||
{
|
||||
return {
|
||||
.bind_blender_framebuffer = execution.bind_blender_framebuffer,
|
||||
.clear_blender_framebuffer = execution.clear_blender_framebuffer,
|
||||
.unbind_blender_framebuffer = execution.unbind_blender_framebuffer,
|
||||
.prepare_temporary_erase = [uniforms, execution] {
|
||||
execution.bind_sampler(0);
|
||||
execution.bind_sampler(1);
|
||||
execution.bind_sampler(2);
|
||||
setup_legacy_stroke_erase_shader(uniforms.temporary_erase);
|
||||
execution.set_active_texture_unit(1);
|
||||
execution.bind_temporary_texture();
|
||||
execution.set_active_texture_unit(2);
|
||||
execution.bind_smask_texture();
|
||||
},
|
||||
.cleanup_temporary_erase = [execution] {
|
||||
execution.set_active_texture_unit(2);
|
||||
execution.unbind_smask_texture();
|
||||
execution.set_active_texture_unit(1);
|
||||
execution.unbind_temporary_texture();
|
||||
},
|
||||
.prepare_temporary_paint = [uniforms, execution] {
|
||||
execution.bind_sampler(0);
|
||||
execution.bind_sampler(1);
|
||||
execution.bind_sampler(2);
|
||||
execution.bind_sampler(3);
|
||||
execution.bind_stencil_sampler(4);
|
||||
setup_legacy_stroke_composite_shader(uniforms.temporary_paint);
|
||||
execution.set_active_texture_unit(1);
|
||||
execution.bind_temporary_texture();
|
||||
execution.set_active_texture_unit(2);
|
||||
execution.bind_smask_texture();
|
||||
execution.set_active_texture_unit(3);
|
||||
if (uniforms.use_dual_texture) {
|
||||
execution.bind_temporary_dual_texture();
|
||||
}
|
||||
execution.set_active_texture_unit(4);
|
||||
execution.bind_pattern_texture();
|
||||
},
|
||||
.cleanup_temporary_paint = [uniforms, execution] {
|
||||
execution.set_active_texture_unit(3);
|
||||
if (uniforms.use_dual_texture) {
|
||||
execution.unbind_temporary_dual_texture();
|
||||
}
|
||||
execution.set_active_texture_unit(2);
|
||||
execution.unbind_smask_texture();
|
||||
execution.set_active_texture_unit(1);
|
||||
execution.unbind_temporary_texture();
|
||||
},
|
||||
.prepare_layer_texture = [uniforms, execution] {
|
||||
if (uniforms.use_nearest_sampler) {
|
||||
execution.bind_nearest_sampler(0);
|
||||
} else {
|
||||
execution.bind_sampler(0);
|
||||
}
|
||||
setup_legacy_canvas_draw_merge_texture_alpha_shader(uniforms.layer_texture);
|
||||
},
|
||||
.cleanup_layer_texture = [] {
|
||||
},
|
||||
.draw_blend = [uniforms, execution] {
|
||||
execute_legacy_canvas_draw_merge_layer_blend(
|
||||
uniforms.blend,
|
||||
{
|
||||
.unbind_merge_framebuffer = execution.unbind_blender_framebuffer,
|
||||
.bind_samplers = [execution] {
|
||||
execution.bind_sampler(0);
|
||||
execution.bind_sampler(2);
|
||||
},
|
||||
.bind_merge_texture = [execution] {
|
||||
execution.set_active_texture_unit(0);
|
||||
execution.bind_blender_texture();
|
||||
},
|
||||
.bind_destination_texture = [execution] {
|
||||
execution.set_active_texture_unit(2);
|
||||
execution.bind_destination_texture();
|
||||
},
|
||||
.copy_destination_framebuffer = execution.copy_destination_framebuffer,
|
||||
.draw = execution.draw_face,
|
||||
.unbind_destination_texture = [execution] {
|
||||
execution.set_active_texture_unit(2);
|
||||
execution.unbind_destination_texture();
|
||||
},
|
||||
.unbind_merge_texture = [execution] {
|
||||
execution.set_active_texture_unit(0);
|
||||
execution.unbind_blender_texture();
|
||||
},
|
||||
});
|
||||
},
|
||||
.draw_debug_outline = execution.draw_debug_outline,
|
||||
.draw_frame = execution.draw_frame,
|
||||
};
|
||||
}
|
||||
|
||||
template <typename PlanOnionRange, typename ShouldDrawPlane, typename VisitLayerPlane, typename LogOnionRangeFailure>
|
||||
inline void execute_legacy_canvas_draw_layer_traversal(
|
||||
size_t layer_count,
|
||||
|
||||
Reference in New Issue
Block a user