aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/backend/drm/drm.h2
-rw-r--r--include/wlr/render.h53
-rw-r--r--include/wlr/render/interface.h13
-rw-r--r--include/wlr/render/matrix.h22
-rw-r--r--include/wlr/types/wlr_matrix.h21
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--include/wlr/types/wlr_surface.h17
7 files changed, 49 insertions, 81 deletions
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index ee3fd38e..26189340 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -26,7 +26,7 @@ struct wlr_drm_plane {
struct wlr_drm_surface mgpu_surf;
// Only used by cursor
- float matrix[16];
+ float matrix[9];
struct wlr_texture *wlr_tex;
struct gbm_bo *cursor_bo;
bool cursor_enabled;
diff --git a/include/wlr/render.h b/include/wlr/render.h
index 9080175f..01d05fb1 100644
--- a/include/wlr/render.h
+++ b/include/wlr/render.h
@@ -13,7 +13,7 @@ struct wlr_renderer;
void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *output);
void wlr_renderer_end(struct wlr_renderer *r);
-void wlr_renderer_clear(struct wlr_renderer *r, const float (*color)[4]);
+void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
/**
* Defines a scissor box. Only pixels that lie within the scissor box can be
* modified by drawing functions. Providing a NULL `box` disables the scissor
@@ -25,31 +25,25 @@ void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box);
*/
struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r);
/**
- * Renders the requested texture using the provided matrix. A typical texture
- * rendering goes like so:
- *
- * struct wlr_renderer *renderer;
- * struct wlr_texture *texture;
- * float projection[16];
- * float matrix[16];
- * wlr_texture_get_matrix(texture, &matrix, &projection, 123, 321);
- * wlr_render_with_matrix(renderer, texture, &matrix, 0.5f);
- *
- * This will render the texture at <123, 321> with an alpha channel of 0.5.
- */
-bool wlr_render_with_matrix(struct wlr_renderer *r,
- struct wlr_texture *texture, const float (*matrix)[16], float alpha);
-
+ * Renders the requested texture.
+ */
+bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
+ const float projection[static 9], int x, int y, float alpha);
+/**
+ * Renders the requested texture using the provided matrix.
+ */
+bool wlr_render_texture_with_matrix(struct wlr_renderer *r,
+ struct wlr_texture *texture, const float matrix[static 9], float alpha);
/**
* Renders a solid quad in the specified color.
*/
void wlr_render_colored_quad(struct wlr_renderer *r,
- const float (*color)[4], const float (*matrix)[16]);
+ const float color[static 4], const float matrix[static 9]);
/**
* Renders a solid ellipse in the specified color.
*/
void wlr_render_colored_ellipse(struct wlr_renderer *r,
- const float (*color)[4], const float (*matrix)[16]);
+ const float color[static 4], const float matrix[static 9]);
/**
* Returns a list of pixel formats supported by this renderer.
*/
@@ -95,22 +89,22 @@ struct wlr_texture {
* returns.
*/
bool wlr_texture_upload_pixels(struct wlr_texture *tex,
- enum wl_shm_format format, int stride, int width, int height,
- const unsigned char *pixels);
+ enum wl_shm_format format, int stride, int width, int height,
+ const unsigned char *pixels);
/**
* Copies pixels to this texture. The buffer is not accessed after this function
* returns. Under some circumstances, this function may re-upload the entire
* buffer - therefore, the entire buffer must be valid.
*/
bool wlr_texture_update_pixels(struct wlr_texture *surf,
- enum wl_shm_format format, int stride, int x, int y,
- int width, int height, const unsigned char *pixels);
+ enum wl_shm_format format, int stride, int x, int y,
+ int width, int height, const unsigned char *pixels);
/**
* Copies pixels from a wl_shm_buffer into this texture. The buffer is not
* accessed after this function returns.
*/
bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format,
- struct wl_shm_buffer *shm);
+ struct wl_shm_buffer *shm);
/**
* Attaches the contents from the given wl_drm wl_buffer resource onto the
@@ -132,18 +126,7 @@ bool wlr_texture_upload_dmabuf(struct wlr_texture *tex,
* must be valid.
*/
bool wlr_texture_update_shm(struct wlr_texture *surf, uint32_t format,
- int x, int y, int width, int height, struct wl_shm_buffer *shm);
-/**
- * Prepares a matrix with the appropriate scale for the given texture and
- * multiplies it with the projection, producing a matrix that the shader can
- * muptlipy vertex coordinates with to get final screen coordinates.
- *
- * The projection matrix is assumed to be an orthographic projection of [0,
- * width) and [0, height], and the x and y coordinates provided are used as
- * such.
- */
-void wlr_texture_get_matrix(struct wlr_texture *texture,
- float (*matrix)[16], const float (*projection)[16], int x, int y);
+ int x, int y, int width, int height, struct wl_shm_buffer *shm);
/**
* Destroys this wlr_texture.
*/
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index 2ba584d9..1b8b7946 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -19,15 +19,16 @@ struct wlr_renderer {
struct wlr_renderer_impl {
void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output);
void (*end)(struct wlr_renderer *renderer);
- void (*clear)(struct wlr_renderer *renderer, const float (*color)[4]);
+ void (*clear)(struct wlr_renderer *renderer, const float color[static 4]);
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer);
- bool (*render_with_matrix)(struct wlr_renderer *renderer,
- struct wlr_texture *texture, const float (*matrix)[16], float alpha);
+ bool (*render_texture_with_matrix)(struct wlr_renderer *renderer,
+ struct wlr_texture *texture, const float matrix[static 9],
+ float alpha);
void (*render_quad)(struct wlr_renderer *renderer,
- const float (*color)[4], const float (*matrix)[16]);
+ const float color[static 4], const float matrix[static 9]);
void (*render_ellipse)(struct wlr_renderer *renderer,
- const float (*color)[4], const float (*matrix)[16]);
+ const float color[static 4], const float matrix[static 9]);
const enum wl_shm_format *(*formats)(
struct wlr_renderer *renderer, size_t *len);
bool (*buffer_is_drm)(struct wlr_renderer *renderer,
@@ -61,8 +62,6 @@ struct wlr_texture_impl {
uint32_t width, uint32_t height);
bool (*upload_dmabuf)(struct wlr_texture *texture,
struct wl_resource *dmabuf_resource);
- void (*get_matrix)(struct wlr_texture *state,
- float (*matrix)[16], const float (*projection)[16], int x, int y);
void (*get_buffer_size)(struct wlr_texture *texture,
struct wl_resource *resource, int *width, int *height);
void (*bind)(struct wlr_texture *texture);
diff --git a/include/wlr/render/matrix.h b/include/wlr/render/matrix.h
deleted file mode 100644
index a333bf0f..00000000
--- a/include/wlr/render/matrix.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef WLR_RENDER_MATRIX_H
-#define WLR_RENDER_MATRIX_H
-
-#include <stdint.h>
-#include <wlr/types/wlr_box.h>
-
-void wlr_matrix_identity(float (*output)[16]);
-void wlr_matrix_translate(float (*output)[16], float x, float y, float z);
-void wlr_matrix_scale(float (*output)[16], float x, float y, float z);
-void wlr_matrix_rotate(float (*output)[16], float radians);
-void wlr_matrix_mul(const float (*x)[16], const float (*y)[16], float (*product)[16]);
-
-enum wl_output_transform;
-void wlr_matrix_transform(float mat[static 16],
- enum wl_output_transform transform);
-void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
- enum wl_output_transform transform);
-void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
- enum wl_output_transform transform, float rotation, float
- (*projection)[16]);
-
-#endif
diff --git a/include/wlr/types/wlr_matrix.h b/include/wlr/types/wlr_matrix.h
new file mode 100644
index 00000000..fd060d11
--- /dev/null
+++ b/include/wlr/types/wlr_matrix.h
@@ -0,0 +1,21 @@
+#ifndef WLR_TYPES_WLR_MATRIX_H
+#define WLR_TYPES_WLR_MATRIX_H
+
+#include <wayland-server.h>
+#include <wlr/types/wlr_box.h>
+
+void wlr_matrix_identity(float mat[static 9]);
+void wlr_matrix_translate(float mat[static 9], float x, float y);
+void wlr_matrix_scale(float mat[static 9], float x, float y);
+void wlr_matrix_rotate(float mat[static 9], float rad);
+void wlr_matrix_multiply(float mat[static 9], const float a[static 9],
+ const float b[static 9]);
+void wlr_matrix_transform(float mat[static 9],
+ enum wl_output_transform transform);
+void wlr_matrix_projection(float mat[static 9], int width, int height,
+ enum wl_output_transform transform);
+void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box,
+ enum wl_output_transform transform, float rotation,
+ const float projection[static 9]);
+
+#endif
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index a8138a80..b838a737 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -76,7 +76,7 @@ struct wlr_output {
// damage for cursors and fullscreen surface, in output-local coordinates
pixman_region32_t damage;
bool frame_pending;
- float transform_matrix[16];
+ float transform_matrix[9];
struct {
struct wl_signal frame;
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 203345bd..5c5b012f 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -70,8 +70,8 @@ struct wlr_surface {
struct wlr_surface_state *current, *pending;
const char *role; // the lifetime-bound role or null
- float buffer_to_surface_matrix[16];
- float surface_to_buffer_matrix[16];
+ float buffer_to_surface_matrix[9];
+ float surface_to_buffer_matrix[9];
struct {
struct wl_signal commit;
@@ -99,19 +99,6 @@ struct wlr_surface {
struct wlr_renderer;
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
struct wlr_renderer *renderer);
-/**
- * Gets a matrix you can pass into wlr_render_with_matrix to display this
- * surface. `matrix` is the output matrix, `projection` is the wlr_output
- * projection matrix, and `transform` is any additional transformations you want
- * to perform on the surface (or NULL/the identity matrix if you don't).
- * `transform` is used before the surface is scaled, so its geometry extends
- * from 0 to 1 in both dimensions.
- */
-void wlr_surface_get_matrix(struct wlr_surface *surface,
- float (*matrix)[16],
- const float (*projection)[16],
- const float (*transform)[16]);
-
/**
* Set the lifetime role for this surface. Returns 0 on success or -1 if the