Share retained stroke sample and mix helpers
This commit is contained in:
@@ -37,6 +37,18 @@ struct LegacyStrokeSampleExecutionResult {
|
||||
glm::vec4 dirty_bounds {};
|
||||
};
|
||||
|
||||
struct LegacyStrokeSamplePolygonExecutionRequest {
|
||||
std::string_view context;
|
||||
glm::vec2 target_size {};
|
||||
std::span<const vertex_t> polygon_vertices;
|
||||
bool copy_stroke_destination = false;
|
||||
std::function<void()> bind_destination_texture;
|
||||
std::function<void(int, int, int, int, int, int)> copy_framebuffer_to_destination_texture;
|
||||
std::function<void()> unbind_destination_texture;
|
||||
std::function<void(std::span<const vertex_t>)> upload_brush_vertices;
|
||||
std::function<void()> draw_brush_shape;
|
||||
};
|
||||
|
||||
enum class LegacyCanvasStrokeTextureInput {
|
||||
brush_tip,
|
||||
stroke_destination,
|
||||
@@ -236,6 +248,7 @@ std::size_t execute_legacy_canvas_stroke_frame_faces(
|
||||
}
|
||||
|
||||
template <typename BindTextureInput, std::size_t BindingCount>
|
||||
requires std::invocable<BindTextureInput&, LegacyCanvasStrokeTextureInput, int>
|
||||
inline void bind_legacy_canvas_stroke_texture_inputs(
|
||||
const std::array<LegacyCanvasStrokeTextureBinding, BindingCount>& bindings,
|
||||
BindTextureInput&& bind_texture_input)
|
||||
@@ -246,6 +259,7 @@ inline void bind_legacy_canvas_stroke_texture_inputs(
|
||||
}
|
||||
|
||||
template <typename UnbindTextureInput, std::size_t BindingCount>
|
||||
requires std::invocable<UnbindTextureInput&, LegacyCanvasStrokeTextureInput, int>
|
||||
inline void unbind_legacy_canvas_stroke_texture_inputs(
|
||||
const std::array<LegacyCanvasStrokeTextureBinding, BindingCount>& bindings,
|
||||
UnbindTextureInput&& unbind_texture_input)
|
||||
@@ -874,4 +888,39 @@ template <typename ExecuteSample, typename BeginFace, typename PrepareDirtyReque
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline LegacyStrokeSampleExecutionResult execute_legacy_canvas_stroke_sample_polygon(
|
||||
const LegacyStrokeSamplePolygonExecutionRequest& request)
|
||||
{
|
||||
std::vector<vertex_t> sample_vertices(
|
||||
request.polygon_vertices.begin(),
|
||||
request.polygon_vertices.end());
|
||||
if (sample_vertices.size() != 3 && sample_vertices.size() != 4) {
|
||||
sample_vertices = triangulate_simple(sample_vertices);
|
||||
}
|
||||
|
||||
std::vector<pp::paint_renderer::CanvasStrokePoint> sample_points;
|
||||
sample_points.reserve(sample_vertices.size());
|
||||
for (const auto& vertex : sample_vertices) {
|
||||
sample_points.push_back(pp::paint_renderer::CanvasStrokePoint {
|
||||
.x = vertex.pos.x,
|
||||
.y = vertex.pos.y,
|
||||
});
|
||||
}
|
||||
|
||||
return execute_legacy_canvas_stroke_sample(
|
||||
LegacyStrokeSampleExecutionRequest {
|
||||
.context = request.context,
|
||||
.target_size = request.target_size,
|
||||
.vertices = sample_vertices,
|
||||
.sample_points = sample_points,
|
||||
.copy_stroke_destination = request.copy_stroke_destination,
|
||||
.bind_destination_texture = request.bind_destination_texture,
|
||||
.copy_framebuffer_to_destination_texture =
|
||||
request.copy_framebuffer_to_destination_texture,
|
||||
.unbind_destination_texture = request.unbind_destination_texture,
|
||||
.upload_brush_vertices = request.upload_brush_vertices,
|
||||
.draw_brush_shape = request.draw_brush_shape,
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace pp::panopainter
|
||||
|
||||
Reference in New Issue
Block a user