implement surface sizing

This commit is contained in:
Tony Crisci 2017-08-14 13:54:57 -04:00
parent b49650b555
commit e46ec57b43
3 changed files with 18 additions and 2 deletions

View File

@ -45,7 +45,7 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) {
struct wlr_surface *surface = wl_resource_get_user_data(_res);
wlr_surface_flush_damage(surface);
if (surface->texture->valid) {
wlr_texture_get_matrix(surface->texture, &matrix,
wlr_surface_get_matrix(surface, &matrix,
&wlr_output->transform_matrix, 200, 200);
wlr_render_with_matrix(sample->renderer, surface->texture, &matrix);

View File

@ -53,5 +53,7 @@ struct wlr_renderer;
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
struct wlr_renderer *renderer);
void wlr_surface_flush_damage(struct wlr_surface *surface);
void wlr_surface_get_matrix(struct wlr_surface *surface, float (*matrix)[16],
const float (*projection)[16], int x, int y);
#endif

View File

@ -5,6 +5,7 @@
#include <wlr/egl.h>
#include <wlr/render/interface.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/render/matrix.h>
static void surface_destroy(struct wl_client *client, struct wl_resource *resource) {
wl_resource_destroy(resource);
@ -268,3 +269,16 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res,
surface, destroy_surface);
return surface;
}
void wlr_surface_get_matrix(struct wlr_surface *surface,
float (*matrix)[16], const float (*projection)[16], int x, int y) {
int width = surface->texture->width / surface->current.scale;
int height = surface->texture->height / surface->current.scale;
float world[16];
wlr_matrix_identity(matrix);
wlr_matrix_translate(&world, x, y, 0);
wlr_matrix_mul(matrix, &world, matrix);
wlr_matrix_scale(&world, width, height, 1);
wlr_matrix_mul(matrix, &world, matrix);
wlr_matrix_mul(projection, matrix, matrix);
}