[PATCH weston 2/4] compositor: introduce weston_surface_geometry_dirty()
Scott Moreau
oreaus at gmail.com
Tue Dec 18 06:31:10 PST 2012
On Tue, Dec 18, 2012 at 7:24 AM, Scott Moreau <oreaus at gmail.com> wrote:
> On Tue, Dec 18, 2012 at 4:58 AM, Pekka Paalanen <ppaalanen at gmail.com>wrote:
>
>> Instead of directly setting the dirty flag on weston_surface geometry,
>> use a function for that.
>>
>> This allows us to hook into geometry dirtying in following patches.
>>
>> Also add comments to weston_surface fields, whose modification causes
>> transform state to become outdated.
>>
>> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
>> ---
>> src/compositor.c | 20 +++++++++++++-------
>> src/compositor.h | 17 ++++++++++-------
>> src/shell.c | 24 ++++++++++--------------
>> src/util.c | 4 ++--
>> src/xwayland/window-manager.c | 4 ++--
>> tests/weston-test.c | 2 +-
>> 6 files changed, 38 insertions(+), 33 deletions(-)
>>
>> diff --git a/src/compositor.c b/src/compositor.c
>> index 0b37e63..24ae6e3 100644
>> --- a/src/compositor.c
>> +++ b/src/compositor.c
>> @@ -297,7 +297,7 @@ weston_surface_create(struct weston_compositor
>> *compositor)
>> &surface->transform.position.link);
>> weston_matrix_init(&surface->transform.position.matrix);
>> pixman_region32_init(&surface->transform.boundingbox);
>> - surface->geometry.dirty = 1;
>> + surface->transform.dirty = 1;
>>
>> surface->pending.buffer_destroy_listener.notify =
>> surface_handle_pending_buffer_destroy;
>> @@ -568,10 +568,10 @@ weston_surface_update_transform_enable(struct
>> weston_surface *surface)
>> WL_EXPORT void
>> weston_surface_update_transform(struct weston_surface *surface)
>> {
>> - if (!surface->geometry.dirty)
>> + if (!surface->transform.dirty)
>> return;
>>
>> - surface->geometry.dirty = 0;
>> + surface->transform.dirty = 0;
>>
>> weston_surface_damage_below(surface);
>>
>> @@ -596,6 +596,12 @@ weston_surface_update_transform(struct
>> weston_surface *surface)
>> }
>>
>> WL_EXPORT void
>> +weston_surface_geometry_dirty(struct weston_surface *surface)
>> +{
>> + surface->transform.dirty = 1;
>> +}
>> +
>> +WL_EXPORT void
>> weston_surface_to_global_fixed(struct weston_surface *surface,
>> wl_fixed_t sx, wl_fixed_t sy,
>> wl_fixed_t *x, wl_fixed_t *y)
>> @@ -690,7 +696,7 @@ weston_surface_configure(struct weston_surface
>> *surface,
>> surface->geometry.y = y;
>> surface->geometry.width = width;
>> surface->geometry.height = height;
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> }
>>
>> WL_EXPORT void
>> @@ -699,7 +705,7 @@ weston_surface_set_position(struct weston_surface
>> *surface,
>> {
>> surface->geometry.x = x;
>> surface->geometry.y = y;
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> }
>>
>> WL_EXPORT int
>> @@ -1393,7 +1399,7 @@ surface_commit(struct wl_client *client, struct
>> wl_resource *resource)
>> if (surface->pending.sx || surface->pending.sy ||
>> (surface->pending.buffer &&
>> surface_pending_buffer_has_different_size(surface)))
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>>
>> /* wl_surface.set_buffer_rotation */
>> surface->buffer_transform = surface->pending.buffer_transform;
>> @@ -1426,7 +1432,7 @@ surface_commit(struct wl_client *client, struct
>> wl_resource *resource)
>>
>> if (!pixman_region32_equal(&opaque, &surface->opaque)) {
>> pixman_region32_copy(&surface->opaque, &opaque);
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> }
>>
>> pixman_region32_fini(&opaque);
>> diff --git a/src/compositor.h b/src/compositor.h
>> index 1d790d3..3a3580a 100644
>> --- a/src/compositor.h
>> +++ b/src/compositor.h
>> @@ -360,8 +360,8 @@ struct weston_region {
>> * To add a transformation to a surface, create a struct
>> weston_transform, and
>> * add it to the list surface->geometry.transformation_list. Whenever you
>> * change the list, anything under surface->geometry, or anything in the
>> - * weston_transforms linked into the list, you must set
>> - * surface->geometry.dirty = 1.
>> + * weston_transforms linked into the list, you must call
>> + * weston_surface_geometry_dirty().
>> *
>> * The order in the list defines the order of transformations. Let the
>> list
>> * contain the transformation matrices M1, ..., Mn as head to tail. The
>> @@ -385,17 +385,17 @@ struct weston_surface {
>> struct weston_compositor *compositor;
>> pixman_region32_t clip;
>> pixman_region32_t damage;
>> - pixman_region32_t opaque;
>> + pixman_region32_t opaque; /* geometry dirty */
>>
>
> I'm not sure what this comment is supposed to convey.
>
>
>> pixman_region32_t input;
>> struct wl_list link;
>> struct wl_list layer_link;
>> - float alpha;
>> + float alpha; /* geometry dirty */
>>
>
> This one as well.
>
>
>> struct weston_plane *plane;
>>
>> void *renderer_state;
>>
>> /* Surface geometry state, mutable.
>> - * If you change anything, set dirty = 1.
>> + * If you change anything, call weston_surface_geometry_dirty().
>> * That includes the transformations referenced from the list.
>> */
>> struct {
>> @@ -404,14 +404,14 @@ struct weston_surface {
>>
>> /* struct weston_transform */
>> struct wl_list transformation_list;
>> -
>> - int dirty;
>>
>
> Why are we changing whitespace here?
>
>
>> } geometry;
>>
>> /* State derived from geometry state, read-only.
>> * This is updated by weston_surface_update_transform().
>> */
>> struct {
>> + int dirty;
>> +
>> pixman_region32_t boundingbox;
>> pixman_region32_t opaque;
>>
>
> And here?
>
I see now the whitespace wasn't changed per se, the variable was moved to a
different part of the struct.
>
>
>>
>> @@ -489,6 +489,9 @@ void
>> weston_surface_update_transform(struct weston_surface *surface);
>>
>> void
>> +weston_surface_geometry_dirty(struct weston_surface *surface);
>> +
>> +void
>> weston_surface_to_global_fixed(struct weston_surface *surface,
>> wl_fixed_t sx, wl_fixed_t sy,
>> wl_fixed_t *x, wl_fixed_t *y);
>> diff --git a/src/shell.c b/src/shell.c
>> index aa1c7c1..5b9acd7 100644
>> --- a/src/shell.c
>> +++ b/src/shell.c
>> @@ -594,7 +594,7 @@ surface_translate(struct weston_surface *surface,
>> double d)
>> weston_matrix_init(&shsurf->workspace_transform.matrix);
>> weston_matrix_translate(&shsurf->workspace_transform.matrix,
>> 0.0, d, 0.0);
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> }
>>
>> static void
>> @@ -670,7 +670,7 @@ workspace_deactivate_transforms(struct workspace *ws)
>> wl_list_remove(&shsurf->workspace_transform.link);
>> wl_list_init(&shsurf->workspace_transform.link);
>> }
>> - shsurf->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> }
>> }
>>
>> @@ -1511,7 +1511,7 @@ set_surface_type(struct shell_surface *shsurf)
>> if (!wl_list_empty(&shsurf->rotation.transform.link)) {
>> wl_list_remove(&shsurf->rotation.transform.link);
>> wl_list_init(&shsurf->rotation.transform.link);
>> - shsurf->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(shsurf->surface);
>> shsurf->saved_rotation_valid = true;
>> }
>> break;
>> @@ -2404,7 +2404,7 @@ surface_opacity_binding(struct wl_seat *seat,
>> uint32_t time, uint32_t axis,
>> if (surface->alpha < step)
>> surface->alpha = step;
>>
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> weston_surface_damage(surface);
>> }
>>
>> @@ -2498,7 +2498,7 @@ rotate_grab_motion(struct wl_pointer_grab *grab,
>> r = sqrtf(dx * dx + dy * dy);
>>
>> wl_list_remove(&shsurf->rotation.transform.link);
>> - shsurf->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(shsurf->surface);
>>
>> if (r > 20.0f) {
>> struct weston_matrix *matrix =
>> @@ -2789,7 +2789,7 @@ show_input_panels(struct wl_listener *listener,
>> void *data)
>> ws = surface->surface;
>> wl_list_insert(&shell->input_panel_layer.surface_list,
>> &ws->layer_link);
>> - ws->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(ws);
>> weston_surface_update_transform(ws);
>> weston_surface_damage(ws);
>> weston_slide_run(ws, ws->geometry.height, 0, NULL, NULL);
>> @@ -2903,7 +2903,7 @@ map(struct desktop_shell *shell, struct
>> weston_surface *surface,
>>
>> surface->geometry.width = width;
>> surface->geometry.height = height;
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>>
>> /* initial positioning, see also configure() */
>> switch (surface_type) {
>> @@ -2997,11 +2997,7 @@ configure(struct desktop_shell *shell, struct
>> weston_surface *surface,
>> if (shsurf)
>> surface_type = shsurf->type;
>>
>> - surface->geometry.x = x;
>> - surface->geometry.y = y;
>> - surface->geometry.width = width;
>> - surface->geometry.height = height;
>> - surface->geometry.dirty = 1;
>> + weston_surface_configure(surface, x, y, width, height);
>>
>> switch (surface_type) {
>> case SHELL_SURFACE_FULLSCREEN:
>> @@ -3342,7 +3338,7 @@ switcher_next(struct switcher *switcher)
>> next = surface;
>> prev = surface;
>> surface->alpha = 0.25;
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> weston_surface_damage(surface);
>> break;
>> default:
>> @@ -3351,7 +3347,7 @@ switcher_next(struct switcher *switcher)
>>
>> if (is_black_surface(surface, NULL)) {
>> surface->alpha = 0.25;
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>> weston_surface_damage(surface);
>> }
>> }
>> diff --git a/src/util.c b/src/util.c
>> index 5f8e9c8..bae1bb9 100644
>> --- a/src/util.c
>> +++ b/src/util.c
>> @@ -116,7 +116,7 @@ weston_surface_animation_destroy(struct
>> weston_surface_animation *animation)
>> wl_list_remove(&animation->animation.link);
>> wl_list_remove(&animation->listener.link);
>> wl_list_remove(&animation->transform.link);
>> - animation->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(animation->surface);
>> if (animation->done)
>> animation->done(animation, animation->data);
>> free(animation);
>> @@ -153,7 +153,7 @@ weston_surface_animation_frame(struct
>> weston_animation *base,
>> if (animation->frame)
>> animation->frame(animation);
>>
>> - animation->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(animation->surface);
>>
>> weston_compositor_schedule_repaint(animation->surface->compositor);
>> }
>>
>> diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
>> index 303ef15..168c717 100644
>> --- a/src/xwayland/window-manager.c
>> +++ b/src/xwayland/window-manager.c
>> @@ -757,7 +757,7 @@ weston_wm_window_draw_decoration(void *data)
>> x - 1, y - 1,
>> window->width + 2,
>> window->height + 2);
>> - window->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(window->surface);
>>
>> pixman_region32_init_rect(&window->surface->input,
>> t->margin, t->margin,
>> @@ -778,7 +778,7 @@ weston_wm_window_schedule_repaint(struct
>> weston_wm_window *window)
>>
>> pixman_region32_fini(&window->surface->pending.opaque);
>>
>> pixman_region32_init_rect(&window->surface->pending.opaque, 0, 0,
>> width, height);
>> - window->surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(window->surface);
>> }
>> return;
>> }
>> diff --git a/tests/weston-test.c b/tests/weston-test.c
>> index be635fa..e89f104 100644
>> --- a/tests/weston-test.c
>> +++ b/tests/weston-test.c
>> @@ -87,7 +87,7 @@ test_surface_configure(struct weston_surface *surface,
>> int32_t sx, int32_t sy)
>> surface->geometry.y = test_surface->y;
>> surface->geometry.width = surface->buffer_ref.buffer->width;
>> surface->geometry.height = surface->buffer_ref.buffer->height;
>> - surface->geometry.dirty = 1;
>> + weston_surface_geometry_dirty(surface);
>>
>> if (!weston_surface_is_mapped(surface))
>> weston_surface_update_transform(surface);
>> --
>> 1.7.8.6
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20121218/40c4f8f1/attachment-0001.html>
More information about the wayland-devel
mailing list