[PATCH] Add a weston_surface_set_size function
Giulio Camuffo
giuliocamuffo at gmail.com
Mon Dec 9 12:16:07 PST 2013
2013/12/9 Bryce W. Harrington <b.harrington at samsung.com>:
> On Wed, Dec 04, 2013 at 08:32:03PM -0600, Jason Ekstrand wrote:
>> Surfaces that are created by clients get their size automatically updated
>> by the attach/commit. Surfaces created directly by shells (such as black
>> surfaces) sometimes need to be manually resized. This function allows you
>> to do that while being somewhat less messy than messing with the internals
>> of weston_surface manually.
>>
>> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
>> ---
>> desktop-shell/shell.c | 9 +++------
>> src/compositor.c | 15 +++++++++++----
>> src/compositor.h | 4 ++++
>> 3 files changed, 18 insertions(+), 10 deletions(-)
>>
>> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
>> index de54e37..56e0338 100644
>> --- a/desktop-shell/shell.c
>> +++ b/desktop-shell/shell.c
>> @@ -504,8 +504,7 @@ create_focus_surface(struct weston_compositor *ec,
>> fsurf->view = weston_view_create (surface);
>> fsurf->view->output = output;
>>
>> - surface->width = output->width;
>> - surface->height = output->height;
>> + weston_surface_set_size(surface, output->width, output->height);
>> weston_view_set_position(fsurf->view, output->x, output->y);
>> weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
>> pixman_region32_fini(&surface->opaque);
>> @@ -2452,8 +2451,7 @@ create_black_surface(struct weston_compositor *ec,
>> pixman_region32_fini(&surface->input);
>> pixman_region32_init_rect(&surface->input, 0, 0, w, h);
>>
>> - surface->width = w;
>> - surface->height = h;
>> + weston_surface_set_size(surface, w, y);
>> weston_view_set_position(view, x, y);
>>
>> return view;
>> @@ -4585,8 +4583,7 @@ shell_fade_create_surface(struct desktop_shell *shell)
>> return NULL;
>> }
>>
>> - surface->width = 8192;
>> - surface->height = 8192;
>> + weston_surface_set_size(surface, 8192, 8192);
>> weston_view_set_position(view, 0, 0);
>> weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
>> wl_list_insert(&compositor->fade_layer.view_list,
>> diff --git a/src/compositor.c b/src/compositor.c
>> index 8f4bdef..97c42b3 100644
>> --- a/src/compositor.c
>> +++ b/src/compositor.c
>> @@ -1133,8 +1133,7 @@ weston_surface_is_mapped(struct weston_surface *surface)
>> }
>>
>> static void
>> -weston_surface_set_size(struct weston_surface *surface,
>> - int32_t width, int32_t height)
>> +surface_set_size(struct weston_surface *surface, int32_t width, int32_t height)
>
> This is probably a stupid question so I'll apologize upfront. But is it
> actually necessary to have a separate surface_set_size() routine from
> weston_surface_set_size()? Couldn't the existing routine just be
> exported for the desktop shell to use?
>
>> {
>> struct weston_view *view;
>>
>> @@ -1148,13 +1147,21 @@ weston_surface_set_size(struct weston_surface *surface,
>> weston_view_geometry_dirty(view);
>> }
>>
>> +WL_EXPORT void
>> +weston_surface_set_size(struct weston_surface *surface,
>> + int32_t width, int32_t height)
>> +{
>> + assert(!surface->resource);
>
> I'm also confused why this assert is here; there isn't a deref of
> surface->resource here or in surface_set_size(). If surface->resource
> surface->is undefined does it trigger problems further down the stack?
The thing is that surfaces which have a client side and then have a
resource have their size set by their buffer size, and manually
changing the width or height on them produces artifacts.
This function is for surfaces without a client side, usually created
by the shell.
>
>> + surface_set_size(surface, width, height);
>> +}
>> +
>> static void
>> weston_surface_set_size_from_buffer(struct weston_surface *surface)
>> {
>> int32_t width, height;
>>
>> if (!surface->buffer_ref.buffer) {
>> - weston_surface_set_size(surface, 0, 0);
>> + surface_set_size(surface, 0, 0);
>> return;
>> }
>>
>> @@ -1174,7 +1181,7 @@ weston_surface_set_size_from_buffer(struct weston_surface *surface)
>>
>> width = width / surface->buffer_viewport.scale;
>> height = height / surface->buffer_viewport.scale;
>> - weston_surface_set_size(surface, width, height);
>> + surface_set_size(surface, width, height);
>> }
>>
>> WL_EXPORT uint32_t
>> diff --git a/src/compositor.h b/src/compositor.h
>> index 6bd637e..9f89d00 100644
>> --- a/src/compositor.h
>> +++ b/src/compositor.h
>> @@ -1138,6 +1138,10 @@ weston_view_schedule_repaint(struct weston_view *view);
>> int
>> weston_surface_is_mapped(struct weston_surface *surface);
>>
>> +WL_EXPORT void
>> +weston_surface_set_size(struct weston_surface *surface,
>> + int32_t width, int32_t height);
>> +
>> void
>> weston_surface_schedule_repaint(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
> _______________________________________________
> 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