mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 00:22:25 +00:00
implement surface sizing
This commit is contained in:
parent
b49650b555
commit
e46ec57b43
@ -45,8 +45,8 @@ 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_output->transform_matrix, 200, 200);
|
||||
wlr_surface_get_matrix(surface, &matrix,
|
||||
&wlr_output->transform_matrix, 200, 200);
|
||||
wlr_render_with_matrix(sample->renderer, surface->texture, &matrix);
|
||||
|
||||
struct wlr_frame_callback *cb, *cnext;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user