Share retained stroke face sample dispatch
This commit is contained in:
@@ -565,17 +565,33 @@ glm::vec4 Canvas::stroke_draw_samples(
|
||||
std::vector<vertex_t>& P,
|
||||
bool copy_stroke_destination)
|
||||
{
|
||||
const auto result = pp::panopainter::execute_legacy_canvas_stroke_sample_polygon(
|
||||
pp::panopainter::LegacyStrokeSamplePolygonExecutionRequest {
|
||||
constexpr std::array destination_texture_binding {
|
||||
pp::panopainter::LegacyCanvasStrokeTextureBinding {
|
||||
.input = pp::panopainter::LegacyCanvasStrokeTextureInput::stroke_destination,
|
||||
.slot = 1,
|
||||
},
|
||||
};
|
||||
const auto result = pp::panopainter::execute_legacy_canvas_stroke_face_sample_polygon(
|
||||
pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest {
|
||||
.context = "Canvas::stroke_draw_samples",
|
||||
.target_size = { m_width, m_height },
|
||||
.polygon_vertices = P,
|
||||
.face_index = i,
|
||||
.copy_stroke_destination = copy_stroke_destination,
|
||||
.bind_destination_texture = [&] {
|
||||
set_active_texture_unit(1);
|
||||
m_tex[i].bind(); // bg, copy of framebuffer (copied before drawing)
|
||||
.bind_destination_texture = [&](int face_index) {
|
||||
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
|
||||
destination_texture_binding,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.bind_stroke_destination = [&] {
|
||||
m_tex[face_index].bind(); // bg, copy of framebuffer (copied before drawing)
|
||||
},
|
||||
});
|
||||
},
|
||||
.copy_framebuffer_to_destination_texture = [](
|
||||
int,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int dst_x,
|
||||
@@ -584,16 +600,24 @@ glm::vec4 Canvas::stroke_draw_samples(
|
||||
int height) {
|
||||
copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height);
|
||||
},
|
||||
.unbind_destination_texture = [&] {
|
||||
set_active_texture_unit(1);
|
||||
m_tex[i].unbind();
|
||||
.unbind_destination_texture = [&](int face_index) {
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
|
||||
destination_texture_binding,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.unbind_stroke_destination = [&] {
|
||||
m_tex[face_index].unbind();
|
||||
},
|
||||
});
|
||||
},
|
||||
.upload_brush_vertices = [&](std::span<const vertex_t> vertices) {
|
||||
.upload_brush_vertices = [&](int, std::span<const vertex_t> vertices) {
|
||||
m_brush_shape.update_vertices(
|
||||
const_cast<vertex_t*>(vertices.data()),
|
||||
static_cast<int>(vertices.size()));
|
||||
},
|
||||
.draw_brush_shape = [&] {
|
||||
.draw_brush_shape = [&](int) {
|
||||
m_brush_shape.draw_fill();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -49,6 +49,19 @@ struct LegacyStrokeSamplePolygonExecutionRequest {
|
||||
std::function<void()> draw_brush_shape;
|
||||
};
|
||||
|
||||
struct LegacyStrokeFaceSamplePolygonExecutionRequest {
|
||||
std::string_view context;
|
||||
glm::vec2 target_size {};
|
||||
std::span<const vertex_t> polygon_vertices;
|
||||
int face_index = 0;
|
||||
bool copy_stroke_destination = false;
|
||||
std::function<void(int)> bind_destination_texture;
|
||||
std::function<void(int, int, int, int, int, int, int)> copy_framebuffer_to_destination_texture;
|
||||
std::function<void(int)> unbind_destination_texture;
|
||||
std::function<void(int, std::span<const vertex_t>)> upload_brush_vertices;
|
||||
std::function<void(int)> draw_brush_shape;
|
||||
};
|
||||
|
||||
enum class LegacyCanvasStrokeTextureInput {
|
||||
brush_tip,
|
||||
stroke_destination,
|
||||
@@ -952,6 +965,52 @@ template <typename ExecuteSample, typename BeginFace, typename PrepareDirtyReque
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] inline LegacyStrokeSampleExecutionResult execute_legacy_canvas_stroke_face_sample_polygon(
|
||||
const LegacyStrokeFaceSamplePolygonExecutionRequest& request)
|
||||
{
|
||||
if (!request.upload_brush_vertices || !request.draw_brush_shape) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (request.copy_stroke_destination &&
|
||||
(!request.bind_destination_texture ||
|
||||
!request.copy_framebuffer_to_destination_texture ||
|
||||
!request.unbind_destination_texture)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return execute_legacy_canvas_stroke_sample_polygon(
|
||||
LegacyStrokeSamplePolygonExecutionRequest {
|
||||
.context = request.context,
|
||||
.target_size = request.target_size,
|
||||
.polygon_vertices = request.polygon_vertices,
|
||||
.copy_stroke_destination = request.copy_stroke_destination,
|
||||
.bind_destination_texture = [&] {
|
||||
request.bind_destination_texture(request.face_index);
|
||||
},
|
||||
.copy_framebuffer_to_destination_texture =
|
||||
[&](int src_x, int src_y, int dst_x, int dst_y, int width, int height) {
|
||||
request.copy_framebuffer_to_destination_texture(
|
||||
request.face_index,
|
||||
src_x,
|
||||
src_y,
|
||||
dst_x,
|
||||
dst_y,
|
||||
width,
|
||||
height);
|
||||
},
|
||||
.unbind_destination_texture = [&] {
|
||||
request.unbind_destination_texture(request.face_index);
|
||||
},
|
||||
.upload_brush_vertices = [&](std::span<const vertex_t> vertices) {
|
||||
request.upload_brush_vertices(request.face_index, vertices);
|
||||
},
|
||||
.draw_brush_shape = [&] {
|
||||
request.draw_brush_shape(request.face_index);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] inline LegacyCanvasStrokeMixPassResult execute_legacy_canvas_stroke_mix_pass(
|
||||
const LegacyCanvasStrokeMixPassRequest& request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user