matrix: use 2D matrices

This commit is contained in:
emersion 2018-03-15 15:33:58 +01:00
parent d26b67cb06
commit 824a95ad19
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
21 changed files with 216 additions and 271 deletions

View file

@ -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;

View file

@ -30,26 +30,26 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r);
*
* 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);
* float projection[9];
* float matrix[9];
* wlr_texture_get_matrix(texture, matrix, projection, 123, 321);
* wlr_render_texture_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[static 16], float alpha);
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[static 4], const float matrix[static 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[static 4], const float matrix[static 16]);
const float color[static 4], const float matrix[static 9]);
/**
* Returns a list of pixel formats supported by this renderer.
*/
@ -139,8 +139,8 @@ bool wlr_texture_update_shm(struct wlr_texture *surf, uint32_t format,
* 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 mat[static 16],
const float projection[static 16], int x, int y);
void wlr_texture_get_matrix(struct wlr_texture *texture, float mat[static 9],
const float projection[static 9], int x, int y);
/**
* Destroys this wlr_texture.
*/

View file

@ -21,13 +21,13 @@ struct wlr_renderer_impl {
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[static 16],
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[static 4], const float matrix[static 16]);
const float color[static 4], const float matrix[static 9]);
void (*render_ellipse)(struct wlr_renderer *renderer,
const float color[static 4], const float matrix[static 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,
@ -59,8 +59,8 @@ struct wlr_texture_impl {
struct wl_resource *drm_buf);
bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image,
uint32_t width, uint32_t height);
void (*get_matrix)(struct wlr_texture *state, float mat[static 16],
const float projection[static 16], int x, int y);
void (*get_matrix)(struct wlr_texture *state, float mat[static 9],
const float projection[static 9], 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);

View file

@ -2,22 +2,22 @@
#define WLR_TYPES_WLR_MATRIX_H
#include <stdint.h>
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
void wlr_matrix_identity(float mat[static 16]);
void wlr_matrix_translate(float mat[static 16], float x, float y, float z);
void wlr_matrix_scale(float mat[static 16], float x, float y, float z);
void wlr_matrix_rotate(float mat[static 16], float radians);
void wlr_matrix_mul(float mat[static 16], const float x[static 16],
const float y[static 16]);
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);
enum wl_output_transform;
void wlr_matrix_transform(float mat[static 16],
void wlr_matrix_texture(float mat[static 9], int32_t width, int32_t height,
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[static 16], const struct wlr_box *box,
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 16]);
const float projection[static 9]);
#endif

View file

@ -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;

View file

@ -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;
@ -109,9 +109,9 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res,
* from 0 to 1 in both dimensions.
*/
void wlr_surface_get_matrix(struct wlr_surface *surface,
float mat[static 16],
const float projection[static 16],
const float transform[static 16]);
float mat[static 9],
const float projection[static 9],
const float transform[static 9]);
/**