aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-03-26 19:13:13 -0400
committeremersion <contact@emersion.fr>2018-03-26 19:13:13 -0400
commitadf4fb08dde2fa3e981213dd6a8c97de1f93c110 (patch)
tree97dcf2ad621552035626c1c60b84ab5b09700ca7 /render
parent3bda7e2ef8db955bb56e9dbf700974de06a2836b (diff)
parent891610081fe1a8279fbe50d548bb6d42074aaae1 (diff)
Merge branch 'master' into texture-redesign
Diffstat (limited to 'render')
-rw-r--r--render/gles2/renderer.c8
-rw-r--r--render/wlr_renderer.c44
2 files changed, 34 insertions, 18 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index dcda45e9..99884622 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -155,7 +155,7 @@ static bool gles2_render_texture_with_matrix(struct wlr_renderer *wlr_renderer,
}
-static void gles2_render_quad(struct wlr_renderer *wlr_renderer,
+static void gles2_render_quad_with_matrix(struct wlr_renderer *wlr_renderer,
const float color[static 4], const float matrix[static 9]) {
struct wlr_gles2_renderer *renderer =
gles2_get_renderer_in_context(wlr_renderer);
@@ -173,7 +173,7 @@ static void gles2_render_quad(struct wlr_renderer *wlr_renderer,
GLES2_DEBUG_POP;
}
-static void gles2_render_ellipse(struct wlr_renderer *wlr_renderer,
+static void gles2_render_ellipse_with_matrix(struct wlr_renderer *wlr_renderer,
const float color[static 4], const float matrix[static 9]) {
struct wlr_gles2_renderer *renderer =
gles2_get_renderer_in_context(wlr_renderer);
@@ -286,8 +286,8 @@ static const struct wlr_renderer_impl renderer_impl = {
.clear = gles2_clear,
.scissor = gles2_scissor,
.render_texture_with_matrix = gles2_render_texture_with_matrix,
- .render_quad = gles2_render_quad,
- .render_ellipse = gles2_render_ellipse,
+ .render_quad_with_matrix = gles2_render_quad_with_matrix,
+ .render_ellipse_with_matrix = gles2_render_ellipse_with_matrix,
.formats = gles2_renderer_formats,
.resource_is_wl_drm_buffer = gles2_resource_is_wl_drm_buffer,
.wl_drm_buffer_get_size = gles2_wl_drm_buffer_get_size,
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index d5a4d19f..e33c2bed 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -11,8 +11,8 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
assert(impl->clear);
assert(impl->scissor);
assert(impl->render_texture_with_matrix);
- assert(impl->render_quad);
- assert(impl->render_ellipse);
+ assert(impl->render_quad_with_matrix);
+ assert(impl->render_ellipse_with_matrix);
assert(impl->formats);
assert(impl->format_supported);
assert(impl->texture_from_pixels);
@@ -47,16 +47,14 @@ void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) {
bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
const float projection[static 9], int x, int y, float alpha) {
- int width, height;
- wlr_texture_get_size(texture, &width, &height);
+ struct wlr_box box = { .x = x, .y = y };
+ wlr_texture_get_size(texture, &box.width, &box.height);
- float mat[9];
- wlr_matrix_identity(mat);
- wlr_matrix_translate(mat, x, y);
- wlr_matrix_scale(mat, width, height);
- wlr_matrix_multiply(mat, projection, mat);
+ float matrix[9];
+ wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
+ projection);
- return wlr_render_texture_with_matrix(r, texture, mat, alpha);
+ return wlr_render_texture_with_matrix(r, texture, matrix, alpha);
}
bool wlr_render_texture_with_matrix(struct wlr_renderer *r,
@@ -65,14 +63,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,
+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_quad_with_matrix(struct wlr_renderer *r,
const float color[static 4], const float matrix[static 9]) {
- r->impl->render_quad(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_colored_ellipse(struct wlr_renderer *r,
+void wlr_render_ellipse_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_ellipse_with_matrix(r, color, matrix);
}
const enum wl_shm_format *wlr_renderer_get_formats(