[PATCH weston 3/8] compositor: merge surface size from buffer size funcs
Kristian Høgsberg
hoegsberg at gmail.com
Thu Nov 28 14:14:56 PST 2013
On Tue, Nov 26, 2013 at 06:19:43PM +0100, Jonny Lamb wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
>
> Replace the two functions getting the intended surface dimensions from
> the surface's buffer and buffer transformation parameters by a single
> function that just set the surface size according to all the buffer
> state.
>
> The old functions were always called in pairs, and always assigned to
> the surface dimension variables.
>
> This function also deals with a NULL buffer by setting the dimensions to
> zero, just like the callers used to do.
>
> The new function has no users outside this source file, so do not export
> it. This basically unexports the old functions.
> ---
> src/compositor.c | 52 +++++++++++++++++-----------------------------------
> src/compositor.h | 4 ----
> 2 files changed, 17 insertions(+), 39 deletions(-)
Applied patches 1-3 for now, will review the rest later. Nice cleanups.
Kristian
> diff --git a/src/compositor.c b/src/compositor.c
> index b6f2966..bead369 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1141,40 +1141,33 @@ weston_surface_is_mapped(struct weston_surface *surface)
> return 0;
> }
>
> -WL_EXPORT int32_t
> -weston_surface_buffer_width(struct weston_surface *surface)
> +static void
> +weston_surface_set_size_from_buffer(struct weston_surface *surface)
> {
> - int32_t width;
> - switch (surface->buffer_viewport.transform) {
> - case WL_OUTPUT_TRANSFORM_90:
> - case WL_OUTPUT_TRANSFORM_270:
> - case WL_OUTPUT_TRANSFORM_FLIPPED_90:
> - case WL_OUTPUT_TRANSFORM_FLIPPED_270:
> - width = surface->buffer_ref.buffer->height;
> - break;
> - default:
> - width = surface->buffer_ref.buffer->width;
> - break;
> + int32_t width, height;
> +
> + if (!surface->buffer_ref.buffer) {
> + surface->width = 0;
> + surface->height = 0;
> + return;
> }
> - return width / surface->buffer_viewport.scale;
> -}
>
> -WL_EXPORT int32_t
> -weston_surface_buffer_height(struct weston_surface *surface)
> -{
> - int32_t height;
> switch (surface->buffer_viewport.transform) {
> case WL_OUTPUT_TRANSFORM_90:
> case WL_OUTPUT_TRANSFORM_270:
> case WL_OUTPUT_TRANSFORM_FLIPPED_90:
> case WL_OUTPUT_TRANSFORM_FLIPPED_270:
> + width = surface->buffer_ref.buffer->height;
> height = surface->buffer_ref.buffer->width;
> - break;
> + break;
> default:
> + width = surface->buffer_ref.buffer->width;
> height = surface->buffer_ref.buffer->height;
> - break;
> + break;
> }
> - return height / surface->buffer_viewport.scale;
> +
> + surface->width = width / surface->buffer_viewport.scale;
> + surface->height = height / surface->buffer_viewport.scale;
> }
>
> WL_EXPORT uint32_t
> @@ -1970,13 +1963,7 @@ weston_surface_commit(struct weston_surface *surface)
> if (surface->pending.buffer || surface->pending.newly_attached)
> weston_surface_attach(surface, surface->pending.buffer);
>
> - surface->width = 0;
> - surface->height = 0;
> - if (surface->buffer_ref.buffer) {
> - /* This already includes the buffer scale */
> - surface->width = weston_surface_buffer_width(surface);
> - surface->height = weston_surface_buffer_height(surface);
> - }
> + weston_surface_set_size_from_buffer(surface);
>
> if (surface->configure && surface->pending.newly_attached)
> surface->configure(surface,
> @@ -2203,12 +2190,7 @@ weston_subsurface_commit_from_cache(struct weston_subsurface *sub)
> weston_surface_attach(surface, sub->cached.buffer_ref.buffer);
> weston_buffer_reference(&sub->cached.buffer_ref, NULL);
>
> - surface->width = 0;
> - surface->height = 0;
> - if (surface->buffer_ref.buffer) {
> - surface->width = weston_surface_buffer_width(surface);
> - surface->height = weston_surface_buffer_height(surface);
> - }
> + weston_surface_set_size_from_buffer(surface);
>
> if (surface->configure && sub->cached.newly_attached)
> surface->configure(surface, sub->cached.sx, sub->cached.sy,
> diff --git a/src/compositor.h b/src/compositor.h
> index e445dc3..e31d7db 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -918,10 +918,6 @@ void
> weston_view_from_global_fixed(struct weston_view *view,
> wl_fixed_t x, wl_fixed_t y,
> wl_fixed_t *vx, wl_fixed_t *vy);
> -int32_t
> -weston_surface_buffer_width(struct weston_surface *surface);
> -int32_t
> -weston_surface_buffer_height(struct weston_surface *surface);
>
> WL_EXPORT void
> weston_surface_to_buffer_float(struct weston_surface *surface,
> --
> 1.8.4.2
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list