mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-15 08:56:26 -05:00
render: add simple functions to render rectangles and ellipses
This commit is contained in:
parent
bcb74c2c78
commit
793c3b3047
6 changed files with 61 additions and 30 deletions
|
|
@ -39,13 +39,16 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) {
|
|||
|
||||
bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
|
||||
const float projection[static 9], int x, int y, float alpha) {
|
||||
float mat[9];
|
||||
wlr_matrix_identity(mat);
|
||||
wlr_matrix_translate(mat, x, y);
|
||||
wlr_matrix_scale(mat, texture->width, texture->height);
|
||||
wlr_matrix_multiply(mat, projection, mat);
|
||||
const struct wlr_box box = {
|
||||
.x = x, .y = y,
|
||||
.width = texture->width, .height = texture->height,
|
||||
};
|
||||
|
||||
return wlr_render_texture_with_matrix(r, texture, mat, alpha);
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||
projection);
|
||||
|
||||
return wlr_render_texture_with_matrix(r, texture, matrix, alpha);
|
||||
}
|
||||
|
||||
bool wlr_render_texture_with_matrix(struct wlr_renderer *r,
|
||||
|
|
@ -54,14 +57,32 @@ bool wlr_render_texture_with_matrix(struct wlr_renderer *r,
|
|||
return r->impl->render_texture_with_matrix(r, texture, matrix, alpha);
|
||||
}
|
||||
|
||||
void wlr_render_colored_quad(struct wlr_renderer *r,
|
||||
const float color[static 4], const float matrix[static 9]) {
|
||||
r->impl->render_quad(r, color, matrix);
|
||||
void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box,
|
||||
const float color[static 4], const float projection[static 9]) {
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||
projection);
|
||||
|
||||
wlr_render_quad_with_matrix(r, color, matrix);
|
||||
}
|
||||
|
||||
void wlr_render_colored_ellipse(struct wlr_renderer *r,
|
||||
void wlr_render_quad_with_matrix(struct wlr_renderer *r,
|
||||
const float color[static 4], const float matrix[static 9]) {
|
||||
r->impl->render_ellipse(r, color, matrix);
|
||||
r->impl->render_quad_with_matrix(r, color, matrix);
|
||||
}
|
||||
|
||||
void wlr_render_ellipse(struct wlr_renderer *r, const struct wlr_box *box,
|
||||
const float color[static 4], const float projection[static 9]) {
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||
projection);
|
||||
|
||||
wlr_render_ellipse_with_matrix(r, color, matrix);
|
||||
}
|
||||
|
||||
void wlr_render_ellipse_with_matrix(struct wlr_renderer *r,
|
||||
const float color[static 4], const float matrix[static 9]) {
|
||||
r->impl->render_ellipse_with_matrix(r, color, matrix);
|
||||
}
|
||||
|
||||
const enum wl_shm_format *wlr_renderer_get_formats(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue