window: allow setting a buffer scale on a window

Alexander Larsson 12 years ago committed by Kristian Høgsberg
parent afd319afce
commit 5e9b652a15
  1. 25
      clients/window.c
  2. 7
      clients/window.h

@ -152,7 +152,7 @@ struct toysurface {
* Prepare the surface for drawing. Makes sure there is a surface * Prepare the surface for drawing. Makes sure there is a surface
* of the right size available for rendering, and returns it. * of the right size available for rendering, and returns it.
* dx,dy are the x,y of wl_surface.attach. * dx,dy are the x,y of wl_surface.attach.
* width,height are the new surface size. * width,height are the new buffer size.
* If flags has SURFACE_HINT_RESIZE set, the user is * If flags has SURFACE_HINT_RESIZE set, the user is
* doing continuous resizing. * doing continuous resizing.
* Returns the Cairo surface to draw to. * Returns the Cairo surface to draw to.
@ -208,6 +208,7 @@ struct surface {
enum window_buffer_type buffer_type; enum window_buffer_type buffer_type;
enum wl_output_transform buffer_transform; enum wl_output_transform buffer_transform;
uint32_t buffer_scale;
cairo_surface_t *cairo_surface; cairo_surface_t *cairo_surface;
@ -1339,6 +1340,9 @@ surface_create_surface(struct surface *surface, int dx, int dy, uint32_t flags)
break; break;
} }
allocation.width *= surface->buffer_scale;
allocation.height *= surface->buffer_scale;
if (!surface->toysurface && display->dpy && if (!surface->toysurface && display->dpy &&
surface->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW) { surface->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW) {
surface->toysurface = surface->toysurface =
@ -1397,6 +1401,21 @@ window_set_buffer_transform(struct window *window,
transform); transform);
} }
void
window_set_buffer_scale(struct window *window,
uint32_t scale)
{
window->main_surface->buffer_scale = scale;
wl_surface_set_buffer_scale(window->main_surface->surface,
scale);
}
uint32_t
window_get_buffer_scale(struct window *window)
{
return window->main_surface->buffer_scale;
}
static void frame_destroy(struct frame *frame); static void frame_destroy(struct frame *frame);
static void static void
@ -1635,7 +1654,8 @@ widget_cairo_update_transform(struct widget *widget, cairo_t *cr)
surface_width = surface->allocation.width; surface_width = surface->allocation.width;
surface_height = surface->allocation.height; surface_height = surface->allocation.height;
transform = window_get_buffer_transform(widget->window); transform = surface->buffer_transform;
switch (transform) { switch (transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED: case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_FLIPPED_90: case WL_OUTPUT_TRANSFORM_FLIPPED_90:
@ -4071,6 +4091,7 @@ surface_create(struct window *window)
surface->window = window; surface->window = window;
surface->surface = wl_compositor_create_surface(display->compositor); surface->surface = wl_compositor_create_surface(display->compositor);
surface->buffer_scale = 1;
wl_surface_add_listener(surface->surface, &surface_listener, window); wl_surface_add_listener(surface->surface, &surface_listener, window);
wl_list_insert(&window->subsurface_list, &surface->link); wl_list_insert(&window->subsurface_list, &surface->link);

@ -253,6 +253,13 @@ void
window_set_buffer_transform(struct window *window, window_set_buffer_transform(struct window *window,
enum wl_output_transform transform); enum wl_output_transform transform);
uint32_t
window_get_buffer_scale(struct window *window);
void
window_set_buffer_scale(struct window *window,
uint32_t scale);
void void
window_destroy(struct window *window); window_destroy(struct window *window);

Loading…
Cancel
Save