aboutsummaryrefslogtreecommitdiff
path: root/include/wlr/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-08-16 19:18:05 +0200
committerSimon Ser <contact@emersion.fr>2023-08-16 19:20:12 +0200
commitd3d3e19ffddccd1cf3c48a7076714fe10ba0c172 (patch)
tree10d302ed24c9d2d602e8a55b45034b010ff70a8f /include/wlr/render
parent568b1943b9d1e35ce2c6e39d4d7d1014ec06ba3b (diff)
render: split render pass API into separate header
Keeps the main wlr_renderer.h a tad more tidy.
Diffstat (limited to 'include/wlr/render')
-rw-r--r--include/wlr/render/pass.h123
-rw-r--r--include/wlr/render/wlr_renderer.h104
2 files changed, 124 insertions, 103 deletions
diff --git a/include/wlr/render/pass.h b/include/wlr/render/pass.h
new file mode 100644
index 00000000..d1b3eb15
--- /dev/null
+++ b/include/wlr/render/pass.h
@@ -0,0 +1,123 @@
+/*
+ * This an unstable interface of wlroots. No guarantees are made regarding the
+ * future consistency of this API.
+ */
+#ifndef WLR_USE_UNSTABLE
+#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
+#endif
+
+#ifndef WLR_RENDER_PASS_H
+#define WLR_RENDER_PASS_H
+
+#include <pixman.h>
+#include <stdint.h>
+#include <wayland-server-core.h>
+#include <wlr/util/box.h>
+
+struct wlr_renderer;
+struct wlr_buffer;
+
+/**
+ * A render pass accumulates drawing operations until submitted to the GPU.
+ */
+struct wlr_render_pass;
+
+/**
+ * An object that can be queried after a render to get the duration of the render.
+ */
+struct wlr_render_timer;
+
+struct wlr_buffer_pass_options {
+ /* Timer to measure the duration of the render pass */
+ struct wlr_render_timer *timer;
+};
+
+/**
+ * Begin a new render pass with the supplied destination buffer.
+ *
+ * Callers must call wlr_render_pass_submit() once they are done with the
+ * render pass.
+ */
+struct wlr_render_pass *wlr_renderer_begin_buffer_pass(struct wlr_renderer *renderer,
+ struct wlr_buffer *buffer, const struct wlr_buffer_pass_options *options);
+
+/**
+ * Submit the render pass.
+ *
+ * The render pass cannot be used after this function is called.
+ */
+bool wlr_render_pass_submit(struct wlr_render_pass *render_pass);
+
+/**
+ * Blend modes.
+ */
+enum wlr_render_blend_mode {
+ /* Pre-multiplied alpha (default) */
+ WLR_RENDER_BLEND_MODE_PREMULTIPLIED,
+ /* Blending is disabled */
+ WLR_RENDER_BLEND_MODE_NONE,
+};
+
+/**
+ * Filter modes.
+ */
+enum wlr_scale_filter_mode {
+ /* bilinear texture filtering (default) */
+ WLR_SCALE_FILTER_BILINEAR,
+ /* nearest texture filtering */
+ WLR_SCALE_FILTER_NEAREST,
+};
+
+struct wlr_render_texture_options {
+ /* Source texture */
+ struct wlr_texture *texture;
+ /* Source coordinates, leave empty to render the whole texture */
+ struct wlr_fbox src_box;
+ /* Destination coordinates, width/height default to the texture size */
+ struct wlr_box dst_box;
+ /* Opacity between 0 (transparent) and 1 (opaque), leave NULL for opaque */
+ const float *alpha;
+ /* Clip region, leave NULL to disable clipping */
+ const pixman_region32_t *clip;
+ /* Transform applied to the source texture */
+ enum wl_output_transform transform;
+ /* Filtering */
+ enum wlr_scale_filter_mode filter_mode;
+ /* Blend mode */
+ enum wlr_render_blend_mode blend_mode;
+};
+
+/**
+ * Render a texture.
+ */
+void wlr_render_pass_add_texture(struct wlr_render_pass *render_pass,
+ const struct wlr_render_texture_options *options);
+
+/**
+ * A color value.
+ *
+ * Each channel has values between 0 and 1 inclusive. The R, G, B
+ * channels need to be pre-multiplied by A.
+ */
+struct wlr_render_color {
+ float r, g, b, a;
+};
+
+struct wlr_render_rect_options {
+ /* Rectangle coordinates */
+ struct wlr_box box;
+ /* Source color */
+ struct wlr_render_color color;
+ /* Clip region, leave NULL to disable clipping */
+ const pixman_region32_t *clip;
+ /* Blend mode */
+ enum wlr_render_blend_mode blend_mode;
+};
+
+/**
+ * Render a rectangle.
+ */
+void wlr_render_pass_add_rect(struct wlr_render_pass *render_pass,
+ const struct wlr_render_rect_options *options);
+
+#endif
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
index 038b25d8..450d61e2 100644
--- a/include/wlr/render/wlr_renderer.h
+++ b/include/wlr/render/wlr_renderer.h
@@ -11,6 +11,7 @@
#include <stdint.h>
#include <wayland-server-core.h>
+#include <wlr/render/pass.h>
#include <wlr/render/wlr_texture.h>
#include <wlr/util/box.h>
@@ -157,109 +158,6 @@ int wlr_renderer_get_drm_fd(struct wlr_renderer *r);
void wlr_renderer_destroy(struct wlr_renderer *renderer);
/**
- * A render pass accumulates drawing operations until submitted to the GPU.
- */
-struct wlr_render_pass;
-
-/**
- * An object that can be queried after a render to get the duration of the render.
- */
-struct wlr_render_timer;
-
-struct wlr_buffer_pass_options {
- /* Timer to measure the duration of the render pass */
- struct wlr_render_timer *timer;
-};
-
-/**
- * Begin a new render pass with the supplied destination buffer.
- *
- * Callers must call wlr_render_pass_submit() once they are done with the
- * render pass.
- */
-struct wlr_render_pass *wlr_renderer_begin_buffer_pass(struct wlr_renderer *renderer,
- struct wlr_buffer *buffer, const struct wlr_buffer_pass_options *options);
-
-/**
- * Submit the render pass.
- *
- * The render pass cannot be used after this function is called.
- */
-bool wlr_render_pass_submit(struct wlr_render_pass *render_pass);
-
-/**
- * Blend modes.
- */
-enum wlr_render_blend_mode {
- /* Pre-multiplied alpha (default) */
- WLR_RENDER_BLEND_MODE_PREMULTIPLIED,
- /* Blending is disabled */
- WLR_RENDER_BLEND_MODE_NONE,
-};
-
-/**
- * Filter modes.
- */
-enum wlr_scale_filter_mode {
- /* bilinear texture filtering (default) */
- WLR_SCALE_FILTER_BILINEAR,
- /* nearest texture filtering */
- WLR_SCALE_FILTER_NEAREST,
-};
-
-struct wlr_render_texture_options {
- /* Source texture */
- struct wlr_texture *texture;
- /* Source coordinates, leave empty to render the whole texture */
- struct wlr_fbox src_box;
- /* Destination coordinates, width/height default to the texture size */
- struct wlr_box dst_box;
- /* Opacity between 0 (transparent) and 1 (opaque), leave NULL for opaque */
- const float *alpha;
- /* Clip region, leave NULL to disable clipping */
- const pixman_region32_t *clip;
- /* Transform applied to the source texture */
- enum wl_output_transform transform;
- /* Filtering */
- enum wlr_scale_filter_mode filter_mode;
- /* Blend mode */
- enum wlr_render_blend_mode blend_mode;
-};
-
-/**
- * Render a texture.
- */
-void wlr_render_pass_add_texture(struct wlr_render_pass *render_pass,
- const struct wlr_render_texture_options *options);
-
-/**
- * A color value.
- *
- * Each channel has values between 0 and 1 inclusive. The R, G, B
- * channels need to be pre-multiplied by A.
- */
-struct wlr_render_color {
- float r, g, b, a;
-};
-
-struct wlr_render_rect_options {
- /* Rectangle coordinates */
- struct wlr_box box;
- /* Source color */
- struct wlr_render_color color;
- /* Clip region, leave NULL to disable clipping */
- const pixman_region32_t *clip;
- /* Blend mode */
- enum wlr_render_blend_mode blend_mode;
-};
-
-/**
- * Render a rectangle.
- */
-void wlr_render_pass_add_rect(struct wlr_render_pass *render_pass,
- const struct wlr_render_rect_options *options);
-
-/**
* Allocate and initialise a new render timer.
*/
struct wlr_render_timer *wlr_render_timer_create(struct wlr_renderer *renderer);