<p dir="ltr">This one is a nice cleanup.<br>
--Jason Ekstrand</p>
<p dir="ltr">Kristian,<br>
I would recommend pushing the first three right away as they will help with removing weston_view.width/height.<br>
--Jason Ekstrand</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<div class="gmail_quote">On Nov 26, 2013 11:20 AM, "Jonny Lamb" <<a href="mailto:jonny.lamb@collabora.co.uk">jonny.lamb@collabora.co.uk</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Pekka Paalanen <<a href="mailto:pekka.paalanen@collabora.co.uk">pekka.paalanen@collabora.co.uk</a>><br>
<br>
Gather the variables affecting the coordinate transformations between<br>
buffer and local coordinates into a new struct weston_buffer_viewport.<br>
<br>
This will be more useful later, when the crop & scale extension is<br>
implemented.<br>
---<br>
src/compositor-drm.c | 11 ++++++-----<br>
src/compositor.c | 42 ++++++++++++++++++------------------------<br>
src/compositor.h | 19 +++++++++++--------<br>
src/gl-renderer.c | 2 +-<br>
src/pixman-renderer.c | 10 +++++-----<br>
src/shell.c | 6 +++---<br>
6 files changed, 44 insertions(+), 46 deletions(-)<br>
<br>
diff --git a/src/compositor-drm.c b/src/compositor-drm.c<br>
index a1d9d59..c34fc1c 100644<br>
--- a/src/compositor-drm.c<br>
+++ b/src/compositor-drm.c<br>
@@ -463,7 +463,7 @@ drm_output_prepare_scanout_view(struct weston_output *_output,<br>
buffer == NULL || c->gbm == NULL ||<br>
buffer->width != output->base.current_mode->width ||<br>
buffer->height != output->base.current_mode->height ||<br>
- output->base.transform != ev->surface->buffer_transform ||<br>
+ output->base.transform != ev->surface->buffer_viewport.transform ||<br>
ev->transform.enabled)<br>
return NULL;<br>
<br>
@@ -818,10 +818,10 @@ drm_output_prepare_overlay_view(struct weston_output *output_base,<br>
if (c->gbm == NULL)<br>
return NULL;<br>
<br>
- if (ev->surface->buffer_transform != output_base->transform)<br>
+ if (ev->surface->buffer_viewport.transform != output_base->transform)<br>
return NULL;<br>
<br>
- if (ev->surface->buffer_scale != output_base->current_scale)<br>
+ if (ev->surface->buffer_viewport.scale != output_base->current_scale)<br>
return NULL;<br>
<br>
if (c->sprites_are_broken)<br>
@@ -931,8 +931,9 @@ drm_output_prepare_overlay_view(struct weston_output *output_base,<br>
<br>
tbox = weston_transformed_rect(wl_fixed_from_int(ev->geometry.width),<br>
wl_fixed_from_int(ev->geometry.height),<br>
- ev->surface->buffer_transform,<br>
- ev->surface->buffer_scale, tbox);<br>
+ ev->surface->buffer_viewport.transform,<br>
+ ev->surface->buffer_viewport.scale,<br>
+ tbox);<br>
<br>
s->src_x = tbox.x1 << 8;<br>
s->src_y = tbox.y1 << 8;<br>
diff --git a/src/compositor.c b/src/compositor.c<br>
index cfcb273..b6f2966 100644<br>
--- a/src/compositor.c<br>
+++ b/src/compositor.c<br>
@@ -400,10 +400,9 @@ weston_surface_create(struct weston_compositor *compositor)<br>
surface->compositor = compositor;<br>
surface->ref_count = 1;<br>
<br>
- surface->buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;<br>
- surface->buffer_scale = 1;<br>
- surface->pending.buffer_transform = surface->buffer_transform;<br>
- surface->pending.buffer_scale = surface->buffer_scale;<br>
+ surface->buffer_viewport.transform = WL_OUTPUT_TRANSFORM_NORMAL;<br>
+ surface->buffer_viewport.scale = 1;<br>
+ surface->pending.buffer_viewport = surface->buffer_viewport;<br>
surface->output = NULL;<br>
surface->pending.newly_attached = 0;<br>
<br>
@@ -639,8 +638,8 @@ weston_surface_to_buffer_float(struct weston_surface *surface,<br>
{<br>
weston_transformed_coord(surface->width,<br>
surface->height,<br>
- surface->buffer_transform,<br>
- surface->buffer_scale,<br>
+ surface->buffer_viewport.transform,<br>
+ surface->buffer_viewport.scale,<br>
sx, sy, bx, by);<br>
}<br>
<br>
@@ -652,8 +651,8 @@ weston_surface_to_buffer(struct weston_surface *surface,<br>
<br>
weston_transformed_coord(surface->width,<br>
surface->height,<br>
- surface->buffer_transform,<br>
- surface->buffer_scale,<br>
+ surface->buffer_viewport.transform,<br>
+ surface->buffer_viewport.scale,<br>
sx, sy, &bxf, &byf);<br>
*bx = floorf(bxf);<br>
*by = floorf(byf);<br>
@@ -665,8 +664,8 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,<br>
{<br>
return weston_transformed_rect(surface->width,<br>
surface->height,<br>
- surface->buffer_transform,<br>
- surface->buffer_scale,<br>
+ surface->buffer_viewport.transform,<br>
+ surface->buffer_viewport.scale,<br>
rect);<br>
}<br>
<br>
@@ -1146,7 +1145,7 @@ WL_EXPORT int32_t<br>
weston_surface_buffer_width(struct weston_surface *surface)<br>
{<br>
int32_t width;<br>
- switch (surface->buffer_transform) {<br>
+ switch (surface->buffer_viewport.transform) {<br>
case WL_OUTPUT_TRANSFORM_90:<br>
case WL_OUTPUT_TRANSFORM_270:<br>
case WL_OUTPUT_TRANSFORM_FLIPPED_90:<br>
@@ -1157,14 +1156,14 @@ weston_surface_buffer_width(struct weston_surface *surface)<br>
width = surface->buffer_ref.buffer->width;<br>
break;<br>
}<br>
- return width / surface->buffer_scale;<br>
+ return width / surface->buffer_viewport.scale;<br>
}<br>
<br>
WL_EXPORT int32_t<br>
weston_surface_buffer_height(struct weston_surface *surface)<br>
{<br>
int32_t height;<br>
- switch (surface->buffer_transform) {<br>
+ switch (surface->buffer_viewport.transform) {<br>
case WL_OUTPUT_TRANSFORM_90:<br>
case WL_OUTPUT_TRANSFORM_270:<br>
case WL_OUTPUT_TRANSFORM_FLIPPED_90:<br>
@@ -1175,7 +1174,7 @@ weston_surface_buffer_height(struct weston_surface *surface)<br>
height = surface->buffer_ref.buffer->height;<br>
break;<br>
}<br>
- return height / surface->buffer_scale;<br>
+ return height / surface->buffer_viewport.scale;<br>
}<br>
<br>
WL_EXPORT uint32_t<br>
@@ -1964,10 +1963,8 @@ weston_surface_commit(struct weston_surface *surface)<br>
pixman_region32_t opaque;<br>
<br>
/* wl_surface.set_buffer_transform */<br>
- surface->buffer_transform = surface->pending.buffer_transform;<br>
-<br>
/* wl_surface.set_buffer_scale */<br>
- surface->buffer_scale = surface->pending.buffer_scale;<br>
+ surface->buffer_viewport = surface->pending.buffer_viewport;<br>
<br>
/* wl_surface.attach */<br>
if (surface->pending.buffer || surface->pending.newly_attached)<br>
@@ -2067,7 +2064,7 @@ surface_set_buffer_transform(struct wl_client *client,<br>
{<br>
struct weston_surface *surface = wl_resource_get_user_data(resource);<br>
<br>
- surface->pending.buffer_transform = transform;<br>
+ surface->pending.buffer_viewport.transform = transform;<br>
}<br>
<br>
static void<br>
@@ -2077,7 +2074,7 @@ surface_set_buffer_scale(struct wl_client *client,<br>
{<br>
struct weston_surface *surface = wl_resource_get_user_data(resource);<br>
<br>
- surface->pending.buffer_scale = scale;<br>
+ surface->pending.buffer_viewport.scale = scale;<br>
}<br>
<br>
static const struct wl_surface_interface surface_interface = {<br>
@@ -2198,10 +2195,8 @@ weston_subsurface_commit_from_cache(struct weston_subsurface *sub)<br>
pixman_region32_t opaque;<br>
<br>
/* wl_surface.set_buffer_transform */<br>
- surface->buffer_transform = sub->cached.buffer_transform;<br>
-<br>
/* wl_surface.set_buffer_scale */<br>
- surface->buffer_scale = sub->cached.buffer_scale;<br>
+ surface->buffer_viewport = sub->cached.buffer_viewport;<br>
<br>
/* wl_surface.attach */<br>
if (sub->cached.buffer_ref.buffer || sub->cached.newly_attached)<br>
@@ -2294,8 +2289,7 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub)<br>
surface-><a href="http://pending.sy" target="_blank">pending.sy</a> = 0;<br>
surface->pending.newly_attached = 0;<br>
<br>
- sub->cached.buffer_transform = surface->pending.buffer_transform;<br>
- sub->cached.buffer_scale = surface->pending.buffer_scale;<br>
+ sub->cached.buffer_viewport = surface->pending.buffer_viewport;<br>
<br>
pixman_region32_copy(&sub->cached.opaque, &surface->pending.opaque);<br>
<br>
diff --git a/src/compositor.h b/src/compositor.h<br>
index 8c19619..e445dc3 100644<br>
--- a/src/compositor.h<br>
+++ b/src/compositor.h<br>
@@ -647,6 +647,14 @@ struct weston_buffer_reference {<br>
struct wl_listener destroy_listener;<br>
};<br>
<br>
+struct weston_buffer_viewport {<br>
+ /* wl_surface.set_buffer_transform */<br>
+ uint32_t transform;<br>
+<br>
+ /* wl_surface.set_scaling_factor */<br>
+ int32_t scale;<br>
+};<br>
+<br>
struct weston_region {<br>
struct wl_resource *resource;<br>
pixman_region32_t region;<br>
@@ -693,10 +701,8 @@ struct weston_subsurface {<br>
struct wl_list frame_callback_list;<br>
<br>
/* wl_surface.set_buffer_transform */<br>
- uint32_t buffer_transform;<br>
-<br>
/* wl_surface.set_buffer_scale */<br>
- int32_t buffer_scale;<br>
+ struct weston_buffer_viewport buffer_viewport;<br>
} cached;<br>
<br>
int synchronized;<br>
@@ -835,8 +841,7 @@ struct weston_surface {<br>
struct wl_list frame_callback_list;<br>
<br>
struct weston_buffer_reference buffer_ref;<br>
- uint32_t buffer_transform;<br>
- int32_t buffer_scale;<br>
+ struct weston_buffer_viewport buffer_viewport;<br>
int keep_buffer; /* bool for backends to prevent early release */<br>
<br>
/* All the pending state, that wl_surface.commit will apply. */<br>
@@ -861,10 +866,8 @@ struct weston_surface {<br>
struct wl_list frame_callback_list;<br>
<br>
/* wl_surface.set_buffer_transform */<br>
- uint32_t buffer_transform;<br>
-<br>
/* wl_surface.set_scaling_factor */<br>
- int32_t buffer_scale;<br>
+ struct weston_buffer_viewport buffer_viewport;<br>
} pending;<br>
<br>
/*<br>
diff --git a/src/gl-renderer.c b/src/gl-renderer.c<br>
index 218fca4..799fba1 100644<br>
--- a/src/gl-renderer.c<br>
+++ b/src/gl-renderer.c<br>
@@ -536,7 +536,7 @@ draw_view(struct weston_view *ev, struct weston_output *output,<br>
shader_uniforms(gs->shader, ev, output);<br>
<br>
if (ev->transform.enabled || output->zoom.active ||<br>
- output->current_scale != ev->surface->buffer_scale)<br>
+ output->current_scale != ev->surface->buffer_viewport.scale)<br>
filter = GL_LINEAR;<br>
else<br>
filter = GL_NEAREST;<br>
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c<br>
index b719829..5961965 100644<br>
--- a/src/pixman-renderer.c<br>
+++ b/src/pixman-renderer.c<br>
@@ -260,7 +260,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output,<br>
fw = pixman_int_to_fixed(ev->geometry.width);<br>
fh = pixman_int_to_fixed(ev->geometry.height);<br>
<br>
- switch (ev->surface->buffer_transform) {<br>
+ switch (ev->surface->buffer_viewport.transform) {<br>
case WL_OUTPUT_TRANSFORM_FLIPPED:<br>
case WL_OUTPUT_TRANSFORM_FLIPPED_90:<br>
case WL_OUTPUT_TRANSFORM_FLIPPED_180:<br>
@@ -272,7 +272,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output,<br>
break;<br>
}<br>
<br>
- switch (ev->surface->buffer_transform) {<br>
+ switch (ev->surface->buffer_viewport.transform) {<br>
default:<br>
case WL_OUTPUT_TRANSFORM_NORMAL:<br>
case WL_OUTPUT_TRANSFORM_FLIPPED:<br>
@@ -295,12 +295,12 @@ repaint_region(struct weston_view *ev, struct weston_output *output,<br>
}<br>
<br>
pixman_transform_scale(&transform, NULL,<br>
- pixman_double_to_fixed ((double)ev->surface->buffer_scale),<br>
- pixman_double_to_fixed ((double)ev->surface->buffer_scale));<br>
+ pixman_double_to_fixed ((double)ev->surface->buffer_viewport.scale),<br>
+ pixman_double_to_fixed ((double)ev->surface->buffer_viewport.scale));<br>
<br>
pixman_image_set_transform(ps->image, &transform);<br>
<br>
- if (ev->transform.enabled || output->current_scale != ev->surface->buffer_scale)<br>
+ if (ev->transform.enabled || output->current_scale != ev->surface->buffer_viewport.scale)<br>
pixman_image_set_filter(ps->image, PIXMAN_FILTER_BILINEAR, NULL, 0);<br>
else<br>
pixman_image_set_filter(ps->image, PIXMAN_FILTER_NEAREST, NULL, 0);<br>
diff --git a/src/shell.c b/src/shell.c<br>
index f102e9a..5227cbe 100644<br>
--- a/src/shell.c<br>
+++ b/src/shell.c<br>
@@ -2330,11 +2330,11 @@ shell_configure_fullscreen(struct shell_surface *shsurf)<br>
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER:<br>
if (shell_surface_is_top_fullscreen(shsurf)) {<br>
struct weston_mode mode = {0,<br>
- surf_width * surface->buffer_scale,<br>
- surf_height * surface->buffer_scale,<br>
+ surf_width * surface->buffer_viewport.scale,<br>
+ surf_height * surface->buffer_viewport.scale,<br>
shsurf->fullscreen.framerate};<br>
<br>
- if (weston_output_switch_mode(output, &mode, surface->buffer_scale,<br>
+ if (weston_output_switch_mode(output, &mode, surface->buffer_viewport.scale,<br>
WESTON_MODE_SWITCH_SET_TEMPORARY) == 0) {<br>
weston_view_set_position(shsurf->view,<br>
output->x - surf_x,<br>
--<br>
1.8.4.2<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div>