matrix: unify API, don't use array pointers
This commit is contained in:
parent
b6a3f240c7
commit
d26b67cb06
|
@ -648,9 +648,9 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0);
|
wlr_texture_get_matrix(plane->wlr_tex, matrix, plane->matrix, 0, 0);
|
||||||
wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex,
|
wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex,
|
||||||
&matrix, 1.0f);
|
matrix, 1.0f);
|
||||||
|
|
||||||
glFinish();
|
glFinish();
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride);
|
||||||
|
|
|
@ -239,7 +239,7 @@ struct gbm_bo *wlr_drm_surface_mgpu_copy(struct wlr_drm_surface *dest,
|
||||||
glViewport(0, 0, dest->width, dest->height);
|
glViewport(0, 0, dest->width, dest->height);
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
wlr_render_with_matrix(dest->renderer->wlr_rend, tex, &matrix, 1.0f);
|
wlr_render_with_matrix(dest->renderer->wlr_rend, tex, matrix, 1.0f);
|
||||||
|
|
||||||
return wlr_drm_surface_swap_buffers(dest, NULL);
|
return wlr_drm_surface_swap_buffers(dest, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ static void handle_output_frame(struct output_state *output,
|
||||||
|
|
||||||
wlr_output_make_current(wlr_output, NULL);
|
wlr_output_make_current(wlr_output, NULL);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
|
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
||||||
|
|
||||||
animate_cat(sample, output->output);
|
animate_cat(sample, output->output);
|
||||||
|
|
||||||
|
@ -119,10 +119,10 @@ static void handle_output_frame(struct output_state *output,
|
||||||
wlr_output_layout_output_coords(sample->layout, output->output,
|
wlr_output_layout_output_coords(sample->layout, output->output,
|
||||||
&local_x, &local_y);
|
&local_x, &local_y);
|
||||||
|
|
||||||
wlr_texture_get_matrix(sample->cat_texture, &matrix,
|
wlr_texture_get_matrix(sample->cat_texture, matrix,
|
||||||
&wlr_output->transform_matrix, local_x, local_y);
|
wlr_output->transform_matrix, local_x, local_y);
|
||||||
wlr_render_with_matrix(sample->renderer,
|
wlr_render_with_matrix(sample->renderer,
|
||||||
sample->cat_texture, &matrix, 1.0f);
|
sample->cat_texture, matrix, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
|
|
@ -44,15 +44,15 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
|
|
||||||
wlr_output_make_current(wlr_output, NULL);
|
wlr_output_make_current(wlr_output, NULL);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
|
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
for (int y = -128 + (int)odata->y_offs; y < height; y += 128) {
|
for (int y = -128 + (int)odata->y_offs; y < height; y += 128) {
|
||||||
for (int x = -128 + (int)odata->x_offs; x < width; x += 128) {
|
for (int x = -128 + (int)odata->x_offs; x < width; x += 128) {
|
||||||
wlr_texture_get_matrix(sample->cat_texture, &matrix,
|
wlr_texture_get_matrix(sample->cat_texture, matrix,
|
||||||
&wlr_output->transform_matrix, x, y);
|
wlr_output->transform_matrix, x, y);
|
||||||
wlr_render_with_matrix(sample->renderer,
|
wlr_render_with_matrix(sample->renderer,
|
||||||
sample->cat_texture, &matrix, 1.0f);
|
sample->cat_texture, matrix, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
|
|
||||||
wlr_output_make_current(wlr_output, NULL);
|
wlr_output_make_current(wlr_output, NULL);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
|
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
float distance = 0.8f * (1 - sample->distance);
|
float distance = 0.8f * (1 - sample->distance);
|
||||||
|
@ -65,9 +65,8 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
.x = left, .y = top,
|
.x = left, .y = top,
|
||||||
.width = pad_width, .height = pad_height,
|
.width = pad_width, .height = pad_height,
|
||||||
};
|
};
|
||||||
wlr_matrix_project_box(&matrix, &box, 0, 0,
|
wlr_matrix_project_box(matrix, &box, 0, 0, wlr_output->transform_matrix);
|
||||||
&wlr_output->transform_matrix);
|
wlr_render_colored_quad(sample->renderer, sample->pad_color, matrix);
|
||||||
wlr_render_colored_quad(sample->renderer, &sample->pad_color, &matrix);
|
|
||||||
|
|
||||||
if (sample->proximity) {
|
if (sample->proximity) {
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
|
@ -76,16 +75,16 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
.width = 16 * (sample->pressure + 1),
|
.width = 16 * (sample->pressure + 1),
|
||||||
.height = 16 * (sample->pressure + 1),
|
.height = 16 * (sample->pressure + 1),
|
||||||
};
|
};
|
||||||
wlr_matrix_project_box(&matrix, &box, 0, sample->ring,
|
wlr_matrix_project_box(matrix, &box, 0, sample->ring,
|
||||||
&wlr_output->transform_matrix);
|
wlr_output->transform_matrix);
|
||||||
wlr_render_colored_quad(sample->renderer, &tool_color, &matrix);
|
wlr_render_colored_quad(sample->renderer, tool_color, matrix);
|
||||||
box.x += sample->x_tilt;
|
box.x += sample->x_tilt;
|
||||||
box.y += sample->y_tilt;
|
box.y += sample->y_tilt;
|
||||||
box.width /= 2;
|
box.width /= 2;
|
||||||
box.height /= 2;
|
box.height /= 2;
|
||||||
wlr_matrix_project_box(&matrix, &box, 0, 0,
|
wlr_matrix_project_box(matrix, &box, 0, 0,
|
||||||
&wlr_output->transform_matrix);
|
wlr_output->transform_matrix);
|
||||||
wlr_render_colored_quad(sample->renderer, &tool_color, &matrix);
|
wlr_render_colored_quad(sample->renderer, tool_color, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
|
|
@ -43,17 +43,17 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
|
|
||||||
wlr_output_make_current(wlr_output, NULL);
|
wlr_output_make_current(wlr_output, NULL);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
|
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
struct touch_point *p;
|
struct touch_point *p;
|
||||||
wl_list_for_each(p, &sample->touch_points, link) {
|
wl_list_for_each(p, &sample->touch_points, link) {
|
||||||
wlr_texture_get_matrix(sample->cat_texture, &matrix,
|
wlr_texture_get_matrix(sample->cat_texture, matrix,
|
||||||
&wlr_output->transform_matrix,
|
wlr_output->transform_matrix,
|
||||||
(int)(p->x * width) - sample->cat_texture->width / 2,
|
(int)(p->x * width) - sample->cat_texture->width / 2,
|
||||||
(int)(p->y * height) - sample->cat_texture->height / 2);
|
(int)(p->y * height) - sample->cat_texture->height / 2);
|
||||||
wlr_render_with_matrix(sample->renderer,
|
wlr_render_with_matrix(sample->renderer, sample->cat_texture,
|
||||||
sample->cat_texture, &matrix, 1.0f);
|
matrix, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct wlr_renderer;
|
||||||
|
|
||||||
void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *output);
|
void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *output);
|
||||||
void wlr_renderer_end(struct wlr_renderer *r);
|
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
|
* 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
|
* modified by drawing functions. Providing a NULL `box` disables the scissor
|
||||||
|
@ -38,18 +38,18 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r);
|
||||||
* This will render the texture at <123, 321> with an alpha channel of 0.5.
|
* This will render the texture at <123, 321> with an alpha channel of 0.5.
|
||||||
*/
|
*/
|
||||||
bool wlr_render_with_matrix(struct wlr_renderer *r,
|
bool wlr_render_with_matrix(struct wlr_renderer *r,
|
||||||
struct wlr_texture *texture, const float (*matrix)[16], float alpha);
|
struct wlr_texture *texture, const float matrix[static 16], float alpha);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a solid quad in the specified color.
|
* Renders a solid quad in the specified color.
|
||||||
*/
|
*/
|
||||||
void wlr_render_colored_quad(struct wlr_renderer *r,
|
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 16]);
|
||||||
/**
|
/**
|
||||||
* Renders a solid ellipse in the specified color.
|
* Renders a solid ellipse in the specified color.
|
||||||
*/
|
*/
|
||||||
void wlr_render_colored_ellipse(struct wlr_renderer *r,
|
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 16]);
|
||||||
/**
|
/**
|
||||||
* Returns a list of pixel formats supported by this renderer.
|
* 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
|
* width) and [0, height], and the x and y coordinates provided are used as
|
||||||
* such.
|
* such.
|
||||||
*/
|
*/
|
||||||
void wlr_texture_get_matrix(struct wlr_texture *texture,
|
void wlr_texture_get_matrix(struct wlr_texture *texture, float mat[static 16],
|
||||||
float (*matrix)[16], const float (*projection)[16], int x, int y);
|
const float projection[static 16], int x, int y);
|
||||||
/**
|
/**
|
||||||
* Destroys this wlr_texture.
|
* Destroys this wlr_texture.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,15 +18,16 @@ struct wlr_renderer {
|
||||||
struct wlr_renderer_impl {
|
struct wlr_renderer_impl {
|
||||||
void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output);
|
void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output);
|
||||||
void (*end)(struct wlr_renderer *renderer);
|
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);
|
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
|
||||||
struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer);
|
struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer);
|
||||||
bool (*render_with_matrix)(struct wlr_renderer *renderer,
|
bool (*render_with_matrix)(struct wlr_renderer *renderer,
|
||||||
struct wlr_texture *texture, const float (*matrix)[16], float alpha);
|
struct wlr_texture *texture, const float matrix[static 16],
|
||||||
|
float alpha);
|
||||||
void (*render_quad)(struct wlr_renderer *renderer,
|
void (*render_quad)(struct wlr_renderer *renderer,
|
||||||
const float (*color)[4], const float (*matrix)[16]);
|
const float color[static 4], const float matrix[static 16]);
|
||||||
void (*render_ellipse)(struct wlr_renderer *renderer,
|
void (*render_ellipse)(struct wlr_renderer *renderer,
|
||||||
const float (*color)[4], const float (*matrix)[16]);
|
const float color[static 4], const float matrix[static 16]);
|
||||||
const enum wl_shm_format *(*formats)(
|
const enum wl_shm_format *(*formats)(
|
||||||
struct wlr_renderer *renderer, size_t *len);
|
struct wlr_renderer *renderer, size_t *len);
|
||||||
bool (*buffer_is_drm)(struct wlr_renderer *renderer,
|
bool (*buffer_is_drm)(struct wlr_renderer *renderer,
|
||||||
|
@ -58,8 +59,8 @@ struct wlr_texture_impl {
|
||||||
struct wl_resource *drm_buf);
|
struct wl_resource *drm_buf);
|
||||||
bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image,
|
bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
void (*get_matrix)(struct wlr_texture *state,
|
void (*get_matrix)(struct wlr_texture *state, float mat[static 16],
|
||||||
float (*matrix)[16], const float (*projection)[16], int x, int y);
|
const float projection[static 16], int x, int y);
|
||||||
void (*get_buffer_size)(struct wlr_texture *texture,
|
void (*get_buffer_size)(struct wlr_texture *texture,
|
||||||
struct wl_resource *resource, int *width, int *height);
|
struct wl_resource *resource, int *width, int *height);
|
||||||
void (*bind)(struct wlr_texture *texture);
|
void (*bind)(struct wlr_texture *texture);
|
||||||
|
|
|
@ -4,19 +4,20 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <wlr/types/wlr_box.h>
|
#include <wlr/types/wlr_box.h>
|
||||||
|
|
||||||
void wlr_matrix_identity(float (*output)[16]);
|
void wlr_matrix_identity(float mat[static 16]);
|
||||||
void wlr_matrix_translate(float (*output)[16], float x, float y, float z);
|
void wlr_matrix_translate(float mat[static 16], float x, float y, float z);
|
||||||
void wlr_matrix_scale(float (*output)[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 (*output)[16], float radians);
|
void wlr_matrix_rotate(float mat[static 16], float radians);
|
||||||
void wlr_matrix_mul(const float (*x)[16], const float (*y)[16], float (*product)[16]);
|
void wlr_matrix_mul(float mat[static 16], const float x[static 16],
|
||||||
|
const float y[static 16]);
|
||||||
|
|
||||||
enum wl_output_transform;
|
enum wl_output_transform;
|
||||||
void wlr_matrix_transform(float mat[static 16],
|
void wlr_matrix_transform(float mat[static 16],
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
|
void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
|
void wlr_matrix_project_box(float mat[static 16], const struct wlr_box *box,
|
||||||
enum wl_output_transform transform, float rotation, float
|
enum wl_output_transform transform, float rotation,
|
||||||
(*projection)[16]);
|
const float projection[static 16]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -99,6 +99,7 @@ struct wlr_surface {
|
||||||
struct wlr_renderer;
|
struct wlr_renderer;
|
||||||
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
|
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
|
||||||
struct wlr_renderer *renderer);
|
struct wlr_renderer *renderer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a matrix you can pass into wlr_render_with_matrix to display this
|
* 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
|
* surface. `matrix` is the output matrix, `projection` is the wlr_output
|
||||||
|
@ -108,9 +109,9 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res,
|
||||||
* from 0 to 1 in both dimensions.
|
* from 0 to 1 in both dimensions.
|
||||||
*/
|
*/
|
||||||
void wlr_surface_get_matrix(struct wlr_surface *surface,
|
void wlr_surface_get_matrix(struct wlr_surface *surface,
|
||||||
float (*matrix)[16],
|
float mat[static 16],
|
||||||
const float (*projection)[16],
|
const float projection[static 16],
|
||||||
const float (*transform)[16]);
|
const float transform[static 16]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -122,8 +122,8 @@ static void wlr_gles2_end(struct wlr_renderer *wlr_renderer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_gles2_clear(struct wlr_renderer *wlr_renderer,
|
static void wlr_gles2_clear(struct wlr_renderer *wlr_renderer,
|
||||||
const float (*color)[4]) {
|
const float color[static 4]) {
|
||||||
glClearColor((*color)[0], (*color)[1], (*color)[2], (*color)[3]);
|
glClearColor(color[0], color[1], color[2], color[3]);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,14 +171,15 @@ static void draw_quad() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
|
static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
|
||||||
struct wlr_texture *texture, const float (*matrix)[16], float alpha) {
|
struct wlr_texture *texture, const float matrix[static 16],
|
||||||
|
float alpha) {
|
||||||
if (!texture || !texture->valid) {
|
if (!texture || !texture->valid) {
|
||||||
wlr_log(L_ERROR, "attempt to render invalid texture");
|
wlr_log(L_ERROR, "attempt to render invalid texture");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_texture_bind(texture);
|
wlr_texture_bind(texture);
|
||||||
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
|
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, matrix));
|
||||||
GL_CALL(glUniform1f(2, alpha));
|
GL_CALL(glUniform1f(2, alpha));
|
||||||
draw_quad();
|
draw_quad();
|
||||||
return true;
|
return true;
|
||||||
|
@ -186,18 +187,18 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
|
||||||
|
|
||||||
|
|
||||||
static void wlr_gles2_render_quad(struct wlr_renderer *wlr_renderer,
|
static void wlr_gles2_render_quad(struct wlr_renderer *wlr_renderer,
|
||||||
const float (*color)[4], const float (*matrix)[16]) {
|
const float color[static 4], const float matrix[static 16]) {
|
||||||
GL_CALL(glUseProgram(shaders.quad));
|
GL_CALL(glUseProgram(shaders.quad));
|
||||||
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
|
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, matrix));
|
||||||
GL_CALL(glUniform4f(1, (*color)[0], (*color)[1], (*color)[2], (*color)[3]));
|
GL_CALL(glUniform4f(1, color[0], color[1], color[2], color[3]));
|
||||||
draw_quad();
|
draw_quad();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_gles2_render_ellipse(struct wlr_renderer *wlr_renderer,
|
static void wlr_gles2_render_ellipse(struct wlr_renderer *wlr_renderer,
|
||||||
const float (*color)[4], const float (*matrix)[16]) {
|
const float color[static 4], const float matrix[static 16]) {
|
||||||
GL_CALL(glUseProgram(shaders.ellipse));
|
GL_CALL(glUseProgram(shaders.ellipse));
|
||||||
GL_CALL(glUniformMatrix4fv(0, 1, GL_TRUE, *matrix));
|
GL_CALL(glUniformMatrix4fv(0, 1, GL_TRUE, matrix));
|
||||||
GL_CALL(glUniform4f(1, (*color)[0], (*color)[1], (*color)[2], (*color)[3]));
|
GL_CALL(glUniform4f(1, color[0], color[1], color[2], color[3]));
|
||||||
draw_quad();
|
draw_quad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,16 +227,16 @@ static bool gles2_texture_upload_eglimage(struct wlr_texture *wlr_tex,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gles2_texture_get_matrix(struct wlr_texture *_texture,
|
static void gles2_texture_get_matrix(struct wlr_texture *_texture,
|
||||||
float (*matrix)[16], const float (*projection)[16], int x, int y) {
|
float mat[static 16], const float projection[static 16], int x, int y) {
|
||||||
struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture;
|
struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture;
|
||||||
float world[16];
|
float world[16];
|
||||||
wlr_matrix_identity(matrix);
|
wlr_matrix_identity(mat);
|
||||||
wlr_matrix_translate(&world, x, y, 0);
|
wlr_matrix_translate(world, x, y, 0);
|
||||||
wlr_matrix_mul(matrix, &world, matrix);
|
wlr_matrix_mul(mat, mat, world);
|
||||||
wlr_matrix_scale(&world,
|
wlr_matrix_scale(world,
|
||||||
texture->wlr_texture.width, texture->wlr_texture.height, 1);
|
texture->wlr_texture.width, texture->wlr_texture.height, 1);
|
||||||
wlr_matrix_mul(matrix, &world, matrix);
|
wlr_matrix_mul(mat, mat, world);
|
||||||
wlr_matrix_mul(projection, matrix, matrix);
|
wlr_matrix_mul(mat, projection, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct
|
static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct
|
||||||
|
|
|
@ -23,7 +23,7 @@ void wlr_renderer_end(struct wlr_renderer *r) {
|
||||||
r->impl->end(r);
|
r->impl->end(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]) {
|
||||||
r->impl->clear(r, color);
|
r->impl->clear(r, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,17 +36,18 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_render_with_matrix(struct wlr_renderer *r,
|
bool wlr_render_with_matrix(struct wlr_renderer *r,
|
||||||
struct wlr_texture *texture, const float (*matrix)[16], float alpha) {
|
struct wlr_texture *texture, const float matrix[static 16],
|
||||||
|
float alpha) {
|
||||||
return r->impl->render_with_matrix(r, texture, matrix, alpha);
|
return r->impl->render_with_matrix(r, texture, matrix, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_render_colored_quad(struct wlr_renderer *r,
|
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 16]) {
|
||||||
r->impl->render_quad(r, color, matrix);
|
r->impl->render_quad(r, color, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_render_colored_ellipse(struct wlr_renderer *r,
|
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 16]) {
|
||||||
r->impl->render_ellipse(r, color, matrix);
|
r->impl->render_ellipse(r, color, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ bool wlr_texture_upload_eglimage(struct wlr_texture *texture,
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_texture_get_matrix(struct wlr_texture *texture,
|
void wlr_texture_get_matrix(struct wlr_texture *texture,
|
||||||
float (*matrix)[16], const float (*projection)[16], int x, int y) {
|
float mat[static 16], const float projection[static 16], int x, int y) {
|
||||||
texture->impl->get_matrix(texture, matrix, projection, x, y);
|
texture->impl->get_matrix(texture, mat, projection, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_texture_get_buffer_size(struct wlr_texture *texture, struct wl_resource
|
void wlr_texture_get_buffer_size(struct wlr_texture *texture, struct wl_resource
|
||||||
|
|
|
@ -290,14 +290,14 @@ static void render_surface(struct wlr_surface *surface, double lx, double ly,
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
enum wl_output_transform transform =
|
enum wl_output_transform transform =
|
||||||
wlr_output_transform_invert(surface->current->transform);
|
wlr_output_transform_invert(surface->current->transform);
|
||||||
wlr_matrix_project_box(&matrix, &box, transform, rotation,
|
wlr_matrix_project_box(matrix, &box, transform, rotation,
|
||||||
&output->wlr_output->transform_matrix);
|
output->wlr_output->transform_matrix);
|
||||||
|
|
||||||
int nrects;
|
int nrects;
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
scissor_output(output, &rects[i]);
|
scissor_output(output, &rects[i]);
|
||||||
wlr_render_with_matrix(renderer, surface->texture, &matrix, data->alpha);
|
wlr_render_with_matrix(renderer, surface->texture, matrix, data->alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
damage_finish:
|
damage_finish:
|
||||||
|
@ -354,8 +354,8 @@ static void render_decorations(struct roots_view *view,
|
||||||
}
|
}
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
wlr_matrix_project_box(&matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
view->rotation, &output->wlr_output->transform_matrix);
|
view->rotation, output->wlr_output->transform_matrix);
|
||||||
float color[] = { 0.2, 0.2, 0.2, view->alpha };
|
float color[] = { 0.2, 0.2, 0.2, view->alpha };
|
||||||
|
|
||||||
int nrects;
|
int nrects;
|
||||||
|
@ -363,7 +363,7 @@ static void render_decorations(struct roots_view *view,
|
||||||
pixman_region32_rectangles(&damage, &nrects);
|
pixman_region32_rectangles(&damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
scissor_output(output, &rects[i]);
|
scissor_output(output, &rects[i]);
|
||||||
wlr_render_colored_quad(renderer, &color, &matrix);
|
wlr_render_colored_quad(renderer, color, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
damage_finish:
|
damage_finish:
|
||||||
|
@ -489,7 +489,7 @@ static void render_output(struct roots_output *output) {
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
scissor_output(output, &rects[i]);
|
scissor_output(output, &rects[i]);
|
||||||
wlr_renderer_clear(renderer, &clear_color);
|
wlr_renderer_clear(renderer, clear_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a view is fullscreen on this output, render it
|
// If a view is fullscreen on this output, render it
|
||||||
|
|
|
@ -10,79 +10,80 @@ static inline int mind(int row, int col) {
|
||||||
return (row - 1) * 4 + col - 1;
|
return (row - 1) * 4 + col - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_matrix_identity(float (*output)[16]) {
|
void wlr_matrix_identity(float mat[static 16]) {
|
||||||
static const float identity[16] = {
|
static const float identity[16] = {
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, 1.0f
|
0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
};
|
};
|
||||||
memcpy(*output, identity, sizeof(identity));
|
memcpy(mat, identity, sizeof(identity));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_matrix_translate(float (*output)[16], float x, float y, float z) {
|
void wlr_matrix_translate(float mat[static 16], float x, float y, float z) {
|
||||||
wlr_matrix_identity(output);
|
wlr_matrix_identity(mat);
|
||||||
(*output)[mind(1, 4)] = x;
|
mat[mind(1, 4)] = x;
|
||||||
(*output)[mind(2, 4)] = y;
|
mat[mind(2, 4)] = y;
|
||||||
(*output)[mind(3, 4)] = z;
|
mat[mind(3, 4)] = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_matrix_scale(float (*output)[16], float x, float y, float z) {
|
void wlr_matrix_scale(float mat[static 16], float x, float y, float z) {
|
||||||
wlr_matrix_identity(output);
|
wlr_matrix_identity(mat);
|
||||||
(*output)[mind(1, 1)] = x;
|
mat[mind(1, 1)] = x;
|
||||||
(*output)[mind(2, 2)] = y;
|
mat[mind(2, 2)] = y;
|
||||||
(*output)[mind(3, 3)] = z;
|
mat[mind(3, 3)] = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_matrix_rotate(float (*output)[16], float radians) {
|
void wlr_matrix_rotate(float mat[static 16], float radians) {
|
||||||
wlr_matrix_identity(output);
|
wlr_matrix_identity(mat);
|
||||||
float _cos = cosf(radians);
|
float _cos = cosf(radians);
|
||||||
float _sin = sinf(radians);
|
float _sin = sinf(radians);
|
||||||
(*output)[mind(1, 1)] = _cos;
|
mat[mind(1, 1)] = _cos;
|
||||||
(*output)[mind(1, 2)] = _sin;
|
mat[mind(1, 2)] = _sin;
|
||||||
(*output)[mind(2, 1)] = -_sin;
|
mat[mind(2, 1)] = -_sin;
|
||||||
(*output)[mind(2, 2)] = _cos;
|
mat[mind(2, 2)] = _cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_matrix_mul(const float (*x)[16], const float (*y)[16], float (*product)[16]) {
|
void wlr_matrix_mul(float mat[static 16], const float x[static 16],
|
||||||
float _product[16] = {
|
const float y[static 16]) {
|
||||||
(*x)[mind(1, 1)] * (*y)[mind(1, 1)] + (*x)[mind(1, 2)] * (*y)[mind(2, 1)] +
|
float product[16] = {
|
||||||
(*x)[mind(1, 3)] * (*y)[mind(3, 1)] + (*x)[mind(1, 4)] * (*y)[mind(4, 1)],
|
x[mind(1, 1)] * y[mind(1, 1)] + x[mind(1, 2)] * y[mind(2, 1)] +
|
||||||
(*x)[mind(1, 1)] * (*y)[mind(1, 2)] + (*x)[mind(1, 2)] * (*y)[mind(2, 2)] +
|
x[mind(1, 3)] * y[mind(3, 1)] + x[mind(1, 4)] * y[mind(4, 1)],
|
||||||
(*x)[mind(1, 3)] * (*y)[mind(3, 2)] + (*x)[mind(1, 4)] * (*y)[mind(4, 2)],
|
x[mind(1, 1)] * y[mind(1, 2)] + x[mind(1, 2)] * y[mind(2, 2)] +
|
||||||
(*x)[mind(1, 1)] * (*y)[mind(1, 3)] + (*x)[mind(1, 2)] * (*y)[mind(2, 3)] +
|
x[mind(1, 3)] * y[mind(3, 2)] + x[mind(1, 4)] * y[mind(4, 2)],
|
||||||
(*x)[mind(1, 3)] * (*y)[mind(3, 3)] + (*x)[mind(1, 4)] * (*y)[mind(4, 3)],
|
x[mind(1, 1)] * y[mind(1, 3)] + x[mind(1, 2)] * y[mind(2, 3)] +
|
||||||
(*x)[mind(1, 1)] * (*y)[mind(1, 4)] + (*x)[mind(1, 2)] * (*y)[mind(2, 4)] +
|
x[mind(1, 3)] * y[mind(3, 3)] + x[mind(1, 4)] * y[mind(4, 3)],
|
||||||
(*x)[mind(1, 4)] * (*y)[mind(3, 4)] + (*x)[mind(1, 4)] * (*y)[mind(4, 4)],
|
x[mind(1, 1)] * y[mind(1, 4)] + x[mind(1, 2)] * y[mind(2, 4)] +
|
||||||
|
x[mind(1, 4)] * y[mind(3, 4)] + x[mind(1, 4)] * y[mind(4, 4)],
|
||||||
|
|
||||||
(*x)[mind(2, 1)] * (*y)[mind(1, 1)] + (*x)[mind(2, 2)] * (*y)[mind(2, 1)] +
|
x[mind(2, 1)] * y[mind(1, 1)] + x[mind(2, 2)] * y[mind(2, 1)] +
|
||||||
(*x)[mind(2, 3)] * (*y)[mind(3, 1)] + (*x)[mind(2, 4)] * (*y)[mind(4, 1)],
|
x[mind(2, 3)] * y[mind(3, 1)] + x[mind(2, 4)] * y[mind(4, 1)],
|
||||||
(*x)[mind(2, 1)] * (*y)[mind(1, 2)] + (*x)[mind(2, 2)] * (*y)[mind(2, 2)] +
|
x[mind(2, 1)] * y[mind(1, 2)] + x[mind(2, 2)] * y[mind(2, 2)] +
|
||||||
(*x)[mind(2, 3)] * (*y)[mind(3, 2)] + (*x)[mind(2, 4)] * (*y)[mind(4, 2)],
|
x[mind(2, 3)] * y[mind(3, 2)] + x[mind(2, 4)] * y[mind(4, 2)],
|
||||||
(*x)[mind(2, 1)] * (*y)[mind(1, 3)] + (*x)[mind(2, 2)] * (*y)[mind(2, 3)] +
|
x[mind(2, 1)] * y[mind(1, 3)] + x[mind(2, 2)] * y[mind(2, 3)] +
|
||||||
(*x)[mind(2, 3)] * (*y)[mind(3, 3)] + (*x)[mind(2, 4)] * (*y)[mind(4, 3)],
|
x[mind(2, 3)] * y[mind(3, 3)] + x[mind(2, 4)] * y[mind(4, 3)],
|
||||||
(*x)[mind(2, 1)] * (*y)[mind(1, 4)] + (*x)[mind(2, 2)] * (*y)[mind(2, 4)] +
|
x[mind(2, 1)] * y[mind(1, 4)] + x[mind(2, 2)] * y[mind(2, 4)] +
|
||||||
(*x)[mind(2, 4)] * (*y)[mind(3, 4)] + (*x)[mind(2, 4)] * (*y)[mind(4, 4)],
|
x[mind(2, 4)] * y[mind(3, 4)] + x[mind(2, 4)] * y[mind(4, 4)],
|
||||||
|
|
||||||
(*x)[mind(3, 1)] * (*y)[mind(1, 1)] + (*x)[mind(3, 2)] * (*y)[mind(2, 1)] +
|
x[mind(3, 1)] * y[mind(1, 1)] + x[mind(3, 2)] * y[mind(2, 1)] +
|
||||||
(*x)[mind(3, 3)] * (*y)[mind(3, 1)] + (*x)[mind(3, 4)] * (*y)[mind(4, 1)],
|
x[mind(3, 3)] * y[mind(3, 1)] + x[mind(3, 4)] * y[mind(4, 1)],
|
||||||
(*x)[mind(3, 1)] * (*y)[mind(1, 2)] + (*x)[mind(3, 2)] * (*y)[mind(2, 2)] +
|
x[mind(3, 1)] * y[mind(1, 2)] + x[mind(3, 2)] * y[mind(2, 2)] +
|
||||||
(*x)[mind(3, 3)] * (*y)[mind(3, 2)] + (*x)[mind(3, 4)] * (*y)[mind(4, 2)],
|
x[mind(3, 3)] * y[mind(3, 2)] + x[mind(3, 4)] * y[mind(4, 2)],
|
||||||
(*x)[mind(3, 1)] * (*y)[mind(1, 3)] + (*x)[mind(3, 2)] * (*y)[mind(2, 3)] +
|
x[mind(3, 1)] * y[mind(1, 3)] + x[mind(3, 2)] * y[mind(2, 3)] +
|
||||||
(*x)[mind(3, 3)] * (*y)[mind(3, 3)] + (*x)[mind(3, 4)] * (*y)[mind(4, 3)],
|
x[mind(3, 3)] * y[mind(3, 3)] + x[mind(3, 4)] * y[mind(4, 3)],
|
||||||
(*x)[mind(3, 1)] * (*y)[mind(1, 4)] + (*x)[mind(3, 2)] * (*y)[mind(2, 4)] +
|
x[mind(3, 1)] * y[mind(1, 4)] + x[mind(3, 2)] * y[mind(2, 4)] +
|
||||||
(*x)[mind(3, 4)] * (*y)[mind(3, 4)] + (*x)[mind(3, 4)] * (*y)[mind(4, 4)],
|
x[mind(3, 4)] * y[mind(3, 4)] + x[mind(3, 4)] * y[mind(4, 4)],
|
||||||
|
|
||||||
(*x)[mind(4, 1)] * (*y)[mind(1, 1)] + (*x)[mind(4, 2)] * (*y)[mind(2, 1)] +
|
x[mind(4, 1)] * y[mind(1, 1)] + x[mind(4, 2)] * y[mind(2, 1)] +
|
||||||
(*x)[mind(4, 3)] * (*y)[mind(3, 1)] + (*x)[mind(4, 4)] * (*y)[mind(4, 1)],
|
x[mind(4, 3)] * y[mind(3, 1)] + x[mind(4, 4)] * y[mind(4, 1)],
|
||||||
(*x)[mind(4, 1)] * (*y)[mind(1, 2)] + (*x)[mind(4, 2)] * (*y)[mind(2, 2)] +
|
x[mind(4, 1)] * y[mind(1, 2)] + x[mind(4, 2)] * y[mind(2, 2)] +
|
||||||
(*x)[mind(4, 3)] * (*y)[mind(3, 2)] + (*x)[mind(4, 4)] * (*y)[mind(4, 2)],
|
x[mind(4, 3)] * y[mind(3, 2)] + x[mind(4, 4)] * y[mind(4, 2)],
|
||||||
(*x)[mind(4, 1)] * (*y)[mind(1, 3)] + (*x)[mind(4, 2)] * (*y)[mind(2, 3)] +
|
x[mind(4, 1)] * y[mind(1, 3)] + x[mind(4, 2)] * y[mind(2, 3)] +
|
||||||
(*x)[mind(4, 3)] * (*y)[mind(3, 3)] + (*x)[mind(4, 4)] * (*y)[mind(4, 3)],
|
x[mind(4, 3)] * y[mind(3, 3)] + x[mind(4, 4)] * y[mind(4, 3)],
|
||||||
(*x)[mind(4, 1)] * (*y)[mind(1, 4)] + (*x)[mind(4, 2)] * (*y)[mind(2, 4)] +
|
x[mind(4, 1)] * y[mind(1, 4)] + x[mind(4, 2)] * y[mind(2, 4)] +
|
||||||
(*x)[mind(4, 4)] * (*y)[mind(3, 4)] + (*x)[mind(4, 4)] * (*y)[mind(4, 4)],
|
x[mind(4, 4)] * y[mind(3, 4)] + x[mind(4, 4)] * y[mind(4, 4)],
|
||||||
};
|
};
|
||||||
memcpy(*product, _product, sizeof(_product));
|
memcpy(mat, product, sizeof(product));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const float transforms[][4] = {
|
static const float transforms[][4] = {
|
||||||
|
@ -161,9 +162,9 @@ void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
|
||||||
mat[15] = 1.0f;
|
mat[15] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
|
void wlr_matrix_project_box(float mat[static 16], const struct wlr_box *box,
|
||||||
enum wl_output_transform transform, float rotation,
|
enum wl_output_transform transform, float rotation,
|
||||||
float (*projection)[16]) {
|
const float projection[static 16]) {
|
||||||
int x = box->x;
|
int x = box->x;
|
||||||
int y = box->y;
|
int y = box->y;
|
||||||
int width = box->width;
|
int width = box->width;
|
||||||
|
@ -173,38 +174,38 @@ void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
|
||||||
|
|
||||||
if (rotation != 0) {
|
if (rotation != 0) {
|
||||||
float translate_center[16];
|
float translate_center[16];
|
||||||
wlr_matrix_translate(&translate_center, width/2, height/2, 0);
|
wlr_matrix_translate(translate_center, width/2, height/2, 0);
|
||||||
|
|
||||||
float rotate[16];
|
float rotate[16];
|
||||||
wlr_matrix_rotate(&rotate, rotation);
|
wlr_matrix_rotate(rotate, rotation);
|
||||||
|
|
||||||
float translate_origin[16];
|
float translate_origin[16];
|
||||||
wlr_matrix_translate(&translate_origin, -width/2, -height/2, 0);
|
wlr_matrix_translate(translate_origin, -width/2, -height/2, 0);
|
||||||
|
|
||||||
wlr_matrix_mul(mat, &translate_center, mat);
|
wlr_matrix_mul(mat, mat, translate_center);
|
||||||
wlr_matrix_mul(mat, &rotate, mat);
|
wlr_matrix_mul(mat, mat, rotate);
|
||||||
wlr_matrix_mul(mat, &translate_origin, mat);
|
wlr_matrix_mul(mat, mat, translate_origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale[16];
|
float scale[16];
|
||||||
wlr_matrix_scale(&scale, width, height, 1);
|
wlr_matrix_scale(scale, width, height, 1);
|
||||||
|
|
||||||
wlr_matrix_mul(mat, &scale, mat);
|
wlr_matrix_mul(mat, mat, scale);
|
||||||
|
|
||||||
if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
||||||
float surface_translate_center[16];
|
float surface_translate_center[16];
|
||||||
wlr_matrix_translate(&surface_translate_center, 0.5, 0.5, 0);
|
wlr_matrix_translate(surface_translate_center, 0.5, 0.5, 0);
|
||||||
|
|
||||||
float surface_transform[16];
|
float surface_transform[16];
|
||||||
wlr_matrix_transform(surface_transform, transform);
|
wlr_matrix_transform(surface_transform, transform);
|
||||||
|
|
||||||
float surface_translate_origin[16];
|
float surface_translate_origin[16];
|
||||||
wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0);
|
wlr_matrix_translate(surface_translate_origin, -0.5, -0.5, 0);
|
||||||
|
|
||||||
wlr_matrix_mul(mat, &surface_translate_center, mat);
|
wlr_matrix_mul(mat, mat, surface_translate_center);
|
||||||
wlr_matrix_mul(mat, &surface_transform, mat);
|
wlr_matrix_mul(mat, mat, surface_transform);
|
||||||
wlr_matrix_mul(mat, &surface_translate_origin, mat);
|
wlr_matrix_mul(mat, mat, surface_translate_origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_matrix_mul(projection, mat, mat);
|
wlr_matrix_mul(mat, projection, mat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,7 +368,7 @@ static void output_fullscreen_surface_render(struct wlr_output *output,
|
||||||
assert(renderer);
|
assert(renderer);
|
||||||
|
|
||||||
if (!wlr_surface_has_buffer(surface)) {
|
if (!wlr_surface_has_buffer(surface)) {
|
||||||
wlr_renderer_clear(renderer, &(float[]){0, 0, 0, 0});
|
wlr_renderer_clear(renderer, (float[]){0, 0, 0, 0});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,15 +378,15 @@ static void output_fullscreen_surface_render(struct wlr_output *output,
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
enum wl_output_transform transform =
|
enum wl_output_transform transform =
|
||||||
wlr_output_transform_invert(surface->current->transform);
|
wlr_output_transform_invert(surface->current->transform);
|
||||||
wlr_matrix_project_box(&matrix, &box, transform, 0,
|
wlr_matrix_project_box(matrix, &box, transform, 0,
|
||||||
&output->transform_matrix);
|
output->transform_matrix);
|
||||||
|
|
||||||
int nrects;
|
int nrects;
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
output_scissor(output, &rects[i]);
|
output_scissor(output, &rects[i]);
|
||||||
wlr_renderer_clear(renderer, &(float[]){0, 0, 0, 0});
|
wlr_renderer_clear(renderer, (float[]){0, 0, 0, 0});
|
||||||
wlr_render_with_matrix(surface->renderer, surface->texture, &matrix, 1.0f);
|
wlr_render_with_matrix(surface->renderer, surface->texture, matrix, 1.0f);
|
||||||
}
|
}
|
||||||
wlr_renderer_scissor(renderer, NULL);
|
wlr_renderer_scissor(renderer, NULL);
|
||||||
|
|
||||||
|
@ -436,14 +436,14 @@ static void output_cursor_render(struct wlr_output_cursor *cursor,
|
||||||
}
|
}
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
wlr_matrix_project_box(&matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||||
&cursor->output->transform_matrix);
|
cursor->output->transform_matrix);
|
||||||
|
|
||||||
int nrects;
|
int nrects;
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(&surface_damage, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(&surface_damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
output_scissor(cursor->output, &rects[i]);
|
output_scissor(cursor->output, &rects[i]);
|
||||||
wlr_render_with_matrix(renderer, texture, &matrix, 1.0f);
|
wlr_render_with_matrix(renderer, texture, matrix, 1.0f);
|
||||||
}
|
}
|
||||||
wlr_renderer_scissor(renderer, NULL);
|
wlr_renderer_scissor(renderer, NULL);
|
||||||
|
|
||||||
|
|
|
@ -625,19 +625,19 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res,
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_surface_get_matrix(struct wlr_surface *surface,
|
void wlr_surface_get_matrix(struct wlr_surface *surface,
|
||||||
float (*matrix)[16],
|
float mat[static 16],
|
||||||
const float (*projection)[16],
|
const float projection[static 16],
|
||||||
const float (*transform)[16]) {
|
const float transform[static 16]) {
|
||||||
int width = surface->texture->width;
|
int width = surface->texture->width;
|
||||||
int height = surface->texture->height;
|
int height = surface->texture->height;
|
||||||
float scale[16];
|
float scale[16];
|
||||||
wlr_matrix_identity(matrix);
|
wlr_matrix_identity(mat);
|
||||||
if (transform) {
|
if (transform) {
|
||||||
wlr_matrix_mul(matrix, transform, matrix);
|
wlr_matrix_mul(mat, mat, transform);
|
||||||
}
|
}
|
||||||
wlr_matrix_scale(&scale, width, height, 1);
|
wlr_matrix_scale(scale, width, height, 1);
|
||||||
wlr_matrix_mul(matrix, &scale, matrix);
|
wlr_matrix_mul(mat, mat, scale);
|
||||||
wlr_matrix_mul(projection, matrix, matrix);
|
wlr_matrix_mul(mat, projection, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_surface_has_buffer(struct wlr_surface *surface) {
|
bool wlr_surface_has_buffer(struct wlr_surface *surface) {
|
||||||
|
|
Loading…
Reference in New Issue