compositor: gather buffer_transform and _scale into a struct

Gather the variables affecting the coordinate transformations between
buffer and local coordinates into a new struct weston_buffer_viewport.

This will be more useful later, when the crop & scale extension is
implemented.
dev
Pekka Paalanen 11 years ago committed by Kristian Høgsberg
parent 40ee921fff
commit 1fd9c0f81a
  1. 11
      src/compositor-drm.c
  2. 42
      src/compositor.c
  3. 19
      src/compositor.h
  4. 2
      src/gl-renderer.c
  5. 10
      src/pixman-renderer.c
  6. 6
      src/shell.c

@ -463,7 +463,7 @@ drm_output_prepare_scanout_view(struct weston_output *_output,
buffer == NULL || c->gbm == NULL ||
buffer->width != output->base.current_mode->width ||
buffer->height != output->base.current_mode->height ||
output->base.transform != ev->surface->buffer_transform ||
output->base.transform != ev->surface->buffer_viewport.transform ||
ev->transform.enabled)
return NULL;
@ -818,10 +818,10 @@ drm_output_prepare_overlay_view(struct weston_output *output_base,
if (c->gbm == NULL)
return NULL;
if (ev->surface->buffer_transform != output_base->transform)
if (ev->surface->buffer_viewport.transform != output_base->transform)
return NULL;
if (ev->surface->buffer_scale != output_base->current_scale)
if (ev->surface->buffer_viewport.scale != output_base->current_scale)
return NULL;
if (c->sprites_are_broken)
@ -931,8 +931,9 @@ drm_output_prepare_overlay_view(struct weston_output *output_base,
tbox = weston_transformed_rect(wl_fixed_from_int(ev->geometry.width),
wl_fixed_from_int(ev->geometry.height),
ev->surface->buffer_transform,
ev->surface->buffer_scale, tbox);
ev->surface->buffer_viewport.transform,
ev->surface->buffer_viewport.scale,
tbox);
s->src_x = tbox.x1 << 8;
s->src_y = tbox.y1 << 8;

@ -399,10 +399,9 @@ weston_surface_create(struct weston_compositor *compositor)
surface->compositor = compositor;
surface->ref_count = 1;
surface->buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;
surface->buffer_scale = 1;
surface->pending.buffer_transform = surface->buffer_transform;
surface->pending.buffer_scale = surface->buffer_scale;
surface->buffer_viewport.transform = WL_OUTPUT_TRANSFORM_NORMAL;
surface->buffer_viewport.scale = 1;
surface->pending.buffer_viewport = surface->buffer_viewport;
surface->output = NULL;
surface->pending.newly_attached = 0;
@ -638,8 +637,8 @@ weston_surface_to_buffer_float(struct weston_surface *surface,
{
weston_transformed_coord(surface->width,
surface->height,
surface->buffer_transform,
surface->buffer_scale,
surface->buffer_viewport.transform,
surface->buffer_viewport.scale,
sx, sy, bx, by);
}
@ -651,8 +650,8 @@ weston_surface_to_buffer(struct weston_surface *surface,
weston_transformed_coord(surface->width,
surface->height,
surface->buffer_transform,
surface->buffer_scale,
surface->buffer_viewport.transform,
surface->buffer_viewport.scale,
sx, sy, &bxf, &byf);
*bx = floorf(bxf);
*by = floorf(byf);
@ -664,8 +663,8 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
{
return weston_transformed_rect(surface->width,
surface->height,
surface->buffer_transform,
surface->buffer_scale,
surface->buffer_viewport.transform,
surface->buffer_viewport.scale,
rect);
}
@ -1145,7 +1144,7 @@ WL_EXPORT int32_t
weston_surface_buffer_width(struct weston_surface *surface)
{
int32_t width;
switch (surface->buffer_transform) {
switch (surface->buffer_viewport.transform) {
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
@ -1156,14 +1155,14 @@ weston_surface_buffer_width(struct weston_surface *surface)
width = surface->buffer_ref.buffer->width;
break;
}
return width / surface->buffer_scale;
return width / surface->buffer_viewport.scale;
}
WL_EXPORT int32_t
weston_surface_buffer_height(struct weston_surface *surface)
{
int32_t height;
switch (surface->buffer_transform) {
switch (surface->buffer_viewport.transform) {
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
@ -1174,7 +1173,7 @@ weston_surface_buffer_height(struct weston_surface *surface)
height = surface->buffer_ref.buffer->height;
break;
}
return height / surface->buffer_scale;
return height / surface->buffer_viewport.scale;
}
WL_EXPORT uint32_t
@ -1963,10 +1962,8 @@ weston_surface_commit(struct weston_surface *surface)
pixman_region32_t opaque;
/* wl_surface.set_buffer_transform */
surface->buffer_transform = surface->pending.buffer_transform;
/* wl_surface.set_buffer_scale */
surface->buffer_scale = surface->pending.buffer_scale;
surface->buffer_viewport = surface->pending.buffer_viewport;
/* wl_surface.attach */
if (surface->pending.buffer || surface->pending.newly_attached)
@ -2066,7 +2063,7 @@ surface_set_buffer_transform(struct wl_client *client,
{
struct weston_surface *surface = wl_resource_get_user_data(resource);
surface->pending.buffer_transform = transform;
surface->pending.buffer_viewport.transform = transform;
}
static void
@ -2076,7 +2073,7 @@ surface_set_buffer_scale(struct wl_client *client,
{
struct weston_surface *surface = wl_resource_get_user_data(resource);
surface->pending.buffer_scale = scale;
surface->pending.buffer_viewport.scale = scale;
}
static const struct wl_surface_interface surface_interface = {
@ -2197,10 +2194,8 @@ weston_subsurface_commit_from_cache(struct weston_subsurface *sub)
pixman_region32_t opaque;
/* wl_surface.set_buffer_transform */
surface->buffer_transform = sub->cached.buffer_transform;
/* wl_surface.set_buffer_scale */
surface->buffer_scale = sub->cached.buffer_scale;
surface->buffer_viewport = sub->cached.buffer_viewport;
/* wl_surface.attach */
if (sub->cached.buffer_ref.buffer || sub->cached.newly_attached)
@ -2293,8 +2288,7 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
surface->pending.sy = 0;
surface->pending.newly_attached = 0;
sub->cached.buffer_transform = surface->pending.buffer_transform;
sub->cached.buffer_scale = surface->pending.buffer_scale;
sub->cached.buffer_viewport = surface->pending.buffer_viewport;
pixman_region32_copy(&sub->cached.opaque, &surface->pending.opaque);

@ -647,6 +647,14 @@ struct weston_buffer_reference {
struct wl_listener destroy_listener;
};
struct weston_buffer_viewport {
/* wl_surface.set_buffer_transform */
uint32_t transform;
/* wl_surface.set_scaling_factor */
int32_t scale;
};
struct weston_region {
struct wl_resource *resource;
pixman_region32_t region;
@ -693,10 +701,8 @@ struct weston_subsurface {
struct wl_list frame_callback_list;
/* wl_surface.set_buffer_transform */
uint32_t buffer_transform;
/* wl_surface.set_buffer_scale */
int32_t buffer_scale;
struct weston_buffer_viewport buffer_viewport;
} cached;
int synchronized;
@ -835,8 +841,7 @@ struct weston_surface {
struct wl_list frame_callback_list;
struct weston_buffer_reference buffer_ref;
uint32_t buffer_transform;
int32_t buffer_scale;
struct weston_buffer_viewport buffer_viewport;
int keep_buffer; /* bool for backends to prevent early release */
/* All the pending state, that wl_surface.commit will apply. */
@ -861,10 +866,8 @@ struct weston_surface {
struct wl_list frame_callback_list;
/* wl_surface.set_buffer_transform */
uint32_t buffer_transform;
/* wl_surface.set_scaling_factor */
int32_t buffer_scale;
struct weston_buffer_viewport buffer_viewport;
} pending;
/*

@ -536,7 +536,7 @@ draw_view(struct weston_view *ev, struct weston_output *output,
shader_uniforms(gs->shader, ev, output);
if (ev->transform.enabled || output->zoom.active ||
output->current_scale != ev->surface->buffer_scale)
output->current_scale != ev->surface->buffer_viewport.scale)
filter = GL_LINEAR;
else
filter = GL_NEAREST;

@ -260,7 +260,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
fw = pixman_int_to_fixed(ev->geometry.width);
fh = pixman_int_to_fixed(ev->geometry.height);
switch (ev->surface->buffer_transform) {
switch (ev->surface->buffer_viewport.transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
@ -272,7 +272,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
break;
}
switch (ev->surface->buffer_transform) {
switch (ev->surface->buffer_viewport.transform) {
default:
case WL_OUTPUT_TRANSFORM_NORMAL:
case WL_OUTPUT_TRANSFORM_FLIPPED:
@ -295,12 +295,12 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
}
pixman_transform_scale(&transform, NULL,
pixman_double_to_fixed ((double)ev->surface->buffer_scale),
pixman_double_to_fixed ((double)ev->surface->buffer_scale));
pixman_double_to_fixed ((double)ev->surface->buffer_viewport.scale),
pixman_double_to_fixed ((double)ev->surface->buffer_viewport.scale));
pixman_image_set_transform(ps->image, &transform);
if (ev->transform.enabled || output->current_scale != ev->surface->buffer_scale)
if (ev->transform.enabled || output->current_scale != ev->surface->buffer_viewport.scale)
pixman_image_set_filter(ps->image, PIXMAN_FILTER_BILINEAR, NULL, 0);
else
pixman_image_set_filter(ps->image, PIXMAN_FILTER_NEAREST, NULL, 0);

@ -2333,11 +2333,11 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER:
if (shell_surface_is_top_fullscreen(shsurf)) {
struct weston_mode mode = {0,
surf_width * surface->buffer_scale,
surf_height * surface->buffer_scale,
surf_width * surface->buffer_viewport.scale,
surf_height * surface->buffer_viewport.scale,
shsurf->fullscreen.framerate};
if (weston_output_switch_mode(output, &mode, surface->buffer_scale,
if (weston_output_switch_mode(output, &mode, surface->buffer_viewport.scale,
WESTON_MODE_SWITCH_SET_TEMPORARY) == 0) {
weston_view_set_position(shsurf->view,
output->x - surf_x,

Loading…
Cancel
Save