2018-07-13 12:40:56 +00:00
|
|
|
|
/*
|
|
|
|
|
* This is a stable interface of wlroots. Future changes will be limited to:
|
|
|
|
|
*
|
|
|
|
|
* - New functions
|
|
|
|
|
* - New struct members
|
|
|
|
|
* - New enum members
|
|
|
|
|
*
|
|
|
|
|
* Note that wlroots does not make an ABI compatibility promise - in the future,
|
|
|
|
|
* the layout and size of structs used by wlroots may change, requiring code
|
|
|
|
|
* depending on this header to be recompiled (but not edited).
|
|
|
|
|
*
|
2021-07-03 08:34:30 +00:00
|
|
|
|
* Breaking changes are announced in the release notes and follow a 1-year
|
|
|
|
|
* deprecation schedule.
|
2018-07-13 12:40:56 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2018-03-15 08:11:03 +00:00
|
|
|
|
#ifndef WLR_TYPES_WLR_MATRIX_H
|
|
|
|
|
#define WLR_TYPES_WLR_MATRIX_H
|
2017-06-08 01:35:07 +00:00
|
|
|
|
|
2021-07-01 20:36:01 +00:00
|
|
|
|
#include <wayland-server-protocol.h>
|
|
|
|
|
|
|
|
|
|
struct wlr_box;
|
2017-08-06 09:38:40 +00:00
|
|
|
|
|
2018-07-13 12:40:56 +00:00
|
|
|
|
/** Writes the identity matrix into mat */
|
2018-03-15 14:33:58 +00:00
|
|
|
|
void wlr_matrix_identity(float mat[static 9]);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** mat ← a × b */
|
2018-03-19 19:21:02 +00:00
|
|
|
|
void wlr_matrix_multiply(float mat[static 9], const float a[static 9],
|
|
|
|
|
const float b[static 9]);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
2018-03-19 19:21:02 +00:00
|
|
|
|
void wlr_matrix_transpose(float mat[static 9], const float a[static 9]);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** Writes a 2D translation matrix to mat of magnitude (x, y) */
|
2018-03-15 14:33:58 +00:00
|
|
|
|
void wlr_matrix_translate(float mat[static 9], float x, float y);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** Writes a 2D scale matrix to mat of magnitude (x, y) */
|
2018-03-15 14:33:58 +00:00
|
|
|
|
void wlr_matrix_scale(float mat[static 9], float x, float y);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** Writes a 2D rotation matrix to mat at an angle of rad radians */
|
2018-03-15 14:33:58 +00:00
|
|
|
|
void wlr_matrix_rotate(float mat[static 9], float rad);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** Writes a transformation matrix which applies the specified
|
|
|
|
|
* wl_output_transform to mat */
|
2018-03-15 14:33:58 +00:00
|
|
|
|
void wlr_matrix_transform(float mat[static 9],
|
2018-03-15 10:10:56 +00:00
|
|
|
|
enum wl_output_transform transform);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** Writes a 2D orthographic projection matrix to mat of (width, height) with a
|
2021-04-12 08:07:49 +00:00
|
|
|
|
* specified wl_output_transform.
|
|
|
|
|
*
|
|
|
|
|
* Deprecated: this function is deprecated and will be removed in a future
|
|
|
|
|
* version of wlroots. */
|
2018-03-15 20:26:45 +00:00
|
|
|
|
void wlr_matrix_projection(float mat[static 9], int width, int height,
|
2018-03-15 10:10:56 +00:00
|
|
|
|
enum wl_output_transform transform);
|
2018-07-13 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
/** Shortcut for the various matrix operations involved in projecting the
|
|
|
|
|
* specified wlr_box onto a given orthographic projection with a given
|
|
|
|
|
* rotation. The result is written to mat, which can be applied to each
|
|
|
|
|
* coordinate of the box to get a new coordinate from [-1,1]. */
|
2018-03-15 14:33:58 +00:00
|
|
|
|
void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box,
|
2018-03-15 10:10:56 +00:00
|
|
|
|
enum wl_output_transform transform, float rotation,
|
2018-03-15 14:33:58 +00:00
|
|
|
|
const float projection[static 9]);
|
2017-08-06 09:38:40 +00:00
|
|
|
|
|
2017-06-08 01:35:07 +00:00
|
|
|
|
#endif
|