Consider scale factor when rendering views

master
Drew DeVault 7 years ago
parent 03c0d41ca9
commit a7446792a1

@ -8,6 +8,7 @@ struct output_config {
char *name;
enum wl_output_transform transform;
int x, y;
int scale;
struct wl_list link;
struct {
int width, height;

@ -48,6 +48,7 @@ enum roots_view_type {
struct roots_view {
struct roots_desktop *desktop;
struct roots_output *output;
double x, y;
float rotation;
// TODO: Something for roots-enforced width/height

@ -1,10 +1,10 @@
#ifndef WLR_TYPES_WLR_SURFACE_H
#define WLR_TYPES_WLR_SURFACE_H
#include <wayland-server.h>
#include <pixman.h>
#include <stdint.h>
#include <stdbool.h>
#include <wlr/types/wlr_output.h>
struct wlr_frame_callback {
struct wl_resource *resource;
@ -135,4 +135,8 @@ struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface);
*/
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y);
void wlr_surface_send_enter(struct wlr_surface *surface,
struct wlr_output *output);
#endif

@ -220,6 +220,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
oc = calloc(1, sizeof(struct output_config));
oc->name = strdup(output_name);
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
oc->scale = 1;
wl_list_insert(&config->outputs, &oc->link);
}
@ -227,6 +228,9 @@ static int config_ini_handler(void *user, const char *section, const char *name,
oc->x = strtol(value, NULL, 10);
} else if (strcmp(name, "y") == 0) {
oc->y = strtol(value, NULL, 10);
} else if (strcmp(name, "scale") == 0) {
oc->scale = strtol(value, NULL, 10);
assert(oc->scale >= 1);
} else if (strcmp(name, "rotate") == 0) {
if (strcmp(value, "90") == 0) {
oc->transform = WL_OUTPUT_TRANSFORM_90;

@ -27,6 +27,8 @@ static void render_surface(struct wlr_surface *surface,
if (wlr_output_layout_intersects(desktop->layout, wlr_output,
lx, ly, lx + width, ly + height)) {
// TODO: accomodate for mismatched scale, which can happen, for
// example, when a view is rendered over two outputs
float matrix[16];
float translate_origin[16];
@ -217,6 +219,7 @@ void output_add_notify(struct wl_listener *listener, void *data) {
if (output_config->mode.width) {
set_mode(wlr_output, output_config);
}
wlr_output->scale = output_config->scale;
wlr_output_transform(wlr_output, output_config->transform);
wlr_output_layout_add(desktop->layout,
wlr_output, output_config->x, output_config->y);

@ -29,8 +29,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) {
if (version >= WL_OUTPUT_MODE_SINCE_VERSION) {
struct wlr_output_mode *mode;
wl_list_for_each(mode, &output->modes, link) {
// TODO: mode->flags should just be preferred
uint32_t flags = mode->flags;
uint32_t flags = mode->flags & ~WL_OUTPUT_MODE_PREFERRED;
if (output->current_mode == mode) {
flags |= WL_OUTPUT_MODE_CURRENT;
}
@ -45,6 +44,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) {
}
}
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION) {
wlr_log(L_DEBUG, "Sending scale");
wl_output_send_scale(resource, output->scale);
}
if (version >= WL_OUTPUT_DONE_SINCE_VERSION) {

@ -649,14 +649,14 @@ void wlr_surface_get_matrix(struct wlr_surface *surface,
float (*matrix)[16],
const float (*projection)[16],
const float (*transform)[16]) {
int width = surface->texture->width / surface->current->scale;
int height = surface->texture->height / surface->current->scale;
int width = surface->texture->width;
int height = surface->texture->height;
float scale[16];
wlr_matrix_identity(matrix);
if (transform) {
wlr_matrix_mul(matrix, transform, matrix);
}
wlr_matrix_scale(&scale, width, height, 1);
wlr_matrix_scale(&scale, width, height, surface->current->scale);
wlr_matrix_mul(matrix, &scale, matrix);
wlr_matrix_mul(projection, matrix, matrix);
}
@ -894,3 +894,16 @@ struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
return NULL;
}
void wlr_surface_send_enter(struct wlr_surface *surface,
struct wlr_output *output) {
struct wl_client *client = wl_resource_get_client(surface->resource);
struct wl_resource *resource;
wl_resource_for_each(resource, &output->wl_resources) {
if (client == wl_resource_get_client(resource)) {
wlr_log(L_DEBUG, "sending output enter");
wl_surface_send_enter(surface->resource, resource);
break;
}
}
}

Loading…
Cancel
Save