render: add wlr_render_subtexture_with_matrix

This renders only a subset of the texture, instead of the full texture.
This commit is contained in:
Simon Ser 2020-04-27 12:27:01 +02:00 committed by Drew DeVault
parent 00ccb89288
commit 315bf08733
4 changed files with 44 additions and 14 deletions

View file

@ -13,7 +13,7 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
assert(impl->begin);
assert(impl->clear);
assert(impl->scissor);
assert(impl->render_texture_with_matrix);
assert(impl->render_subtexture_with_matrix);
assert(impl->render_quad_with_matrix);
assert(impl->render_ellipse_with_matrix);
assert(impl->formats);
@ -80,8 +80,21 @@ bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
bool wlr_render_texture_with_matrix(struct wlr_renderer *r,
struct wlr_texture *texture, const float matrix[static 9],
float alpha) {
struct wlr_fbox box = {
.x = 0,
.y = 0,
.width = texture->width,
.height = texture->height,
};
return wlr_render_subtexture_with_matrix(r, texture, &box, matrix, alpha);
}
bool wlr_render_subtexture_with_matrix(struct wlr_renderer *r,
struct wlr_texture *texture, const struct wlr_fbox *box,
const float matrix[static 9], float alpha) {
assert(r->rendering);
return r->impl->render_texture_with_matrix(r, texture, matrix, alpha);
return r->impl->render_subtexture_with_matrix(r, texture,
box, matrix, alpha);
}
void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box,