compositor: introduce weston_surface_geometry_dirty()
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 a following patch. Also add comments to weston_surface fields, whose modification causes transform state to become outdated. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
f1f48cfa35
commit
c3ce738653
+2
-2
@@ -116,7 +116,7 @@ weston_surface_animation_destroy(struct weston_surface_animation *animation)
|
|||||||
wl_list_remove(&animation->animation.link);
|
wl_list_remove(&animation->animation.link);
|
||||||
wl_list_remove(&animation->listener.link);
|
wl_list_remove(&animation->listener.link);
|
||||||
wl_list_remove(&animation->transform.link);
|
wl_list_remove(&animation->transform.link);
|
||||||
animation->surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(animation->surface);
|
||||||
if (animation->done)
|
if (animation->done)
|
||||||
animation->done(animation, animation->data);
|
animation->done(animation, animation->data);
|
||||||
free(animation);
|
free(animation);
|
||||||
@@ -153,7 +153,7 @@ weston_surface_animation_frame(struct weston_animation *base,
|
|||||||
if (animation->frame)
|
if (animation->frame)
|
||||||
animation->frame(animation);
|
animation->frame(animation);
|
||||||
|
|
||||||
animation->surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(animation->surface);
|
||||||
weston_compositor_schedule_repaint(animation->surface->compositor);
|
weston_compositor_schedule_repaint(animation->surface->compositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-6
@@ -304,7 +304,7 @@ weston_surface_create(struct weston_compositor *compositor)
|
|||||||
&surface->transform.position.link);
|
&surface->transform.position.link);
|
||||||
weston_matrix_init(&surface->transform.position.matrix);
|
weston_matrix_init(&surface->transform.position.matrix);
|
||||||
pixman_region32_init(&surface->transform.boundingbox);
|
pixman_region32_init(&surface->transform.boundingbox);
|
||||||
surface->geometry.dirty = 1;
|
surface->transform.dirty = 1;
|
||||||
|
|
||||||
surface->pending.buffer_destroy_listener.notify =
|
surface->pending.buffer_destroy_listener.notify =
|
||||||
surface_handle_pending_buffer_destroy;
|
surface_handle_pending_buffer_destroy;
|
||||||
@@ -657,10 +657,10 @@ weston_surface_update_transform_enable(struct weston_surface *surface)
|
|||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
weston_surface_update_transform(struct weston_surface *surface)
|
weston_surface_update_transform(struct weston_surface *surface)
|
||||||
{
|
{
|
||||||
if (!surface->geometry.dirty)
|
if (!surface->transform.dirty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
surface->geometry.dirty = 0;
|
surface->transform.dirty = 0;
|
||||||
|
|
||||||
weston_surface_damage_below(surface);
|
weston_surface_damage_below(surface);
|
||||||
|
|
||||||
@@ -684,6 +684,12 @@ weston_surface_update_transform(struct weston_surface *surface)
|
|||||||
weston_surface_assign_output(surface);
|
weston_surface_assign_output(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
weston_surface_geometry_dirty(struct weston_surface *surface)
|
||||||
|
{
|
||||||
|
surface->transform.dirty = 1;
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
weston_surface_to_global_fixed(struct weston_surface *surface,
|
weston_surface_to_global_fixed(struct weston_surface *surface,
|
||||||
wl_fixed_t sx, wl_fixed_t sy,
|
wl_fixed_t sx, wl_fixed_t sy,
|
||||||
@@ -779,7 +785,7 @@ weston_surface_configure(struct weston_surface *surface,
|
|||||||
surface->geometry.y = y;
|
surface->geometry.y = y;
|
||||||
surface->geometry.width = width;
|
surface->geometry.width = width;
|
||||||
surface->geometry.height = height;
|
surface->geometry.height = height;
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
@@ -788,7 +794,7 @@ weston_surface_set_position(struct weston_surface *surface,
|
|||||||
{
|
{
|
||||||
surface->geometry.x = x;
|
surface->geometry.x = x;
|
||||||
surface->geometry.y = y;
|
surface->geometry.y = y;
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
@@ -1441,7 +1447,7 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
|
|||||||
|
|
||||||
if (!pixman_region32_equal(&opaque, &surface->opaque)) {
|
if (!pixman_region32_equal(&opaque, &surface->opaque)) {
|
||||||
pixman_region32_copy(&surface->opaque, &opaque);
|
pixman_region32_copy(&surface->opaque, &opaque);
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(&opaque);
|
pixman_region32_fini(&opaque);
|
||||||
|
|||||||
+10
-7
@@ -370,8 +370,8 @@ struct weston_region {
|
|||||||
* To add a transformation to a surface, create a struct weston_transform, and
|
* To add a transformation to a surface, create a struct weston_transform, and
|
||||||
* add it to the list surface->geometry.transformation_list. Whenever you
|
* add it to the list surface->geometry.transformation_list. Whenever you
|
||||||
* change the list, anything under surface->geometry, or anything in the
|
* change the list, anything under surface->geometry, or anything in the
|
||||||
* weston_transforms linked into the list, you must set
|
* weston_transforms linked into the list, you must call
|
||||||
* surface->geometry.dirty = 1.
|
* weston_surface_geometry_dirty().
|
||||||
*
|
*
|
||||||
* The order in the list defines the order of transformations. Let the list
|
* The order in the list defines the order of transformations. Let the list
|
||||||
* contain the transformation matrices M1, ..., Mn as head to tail. The
|
* contain the transformation matrices M1, ..., Mn as head to tail. The
|
||||||
@@ -395,17 +395,17 @@ struct weston_surface {
|
|||||||
struct weston_compositor *compositor;
|
struct weston_compositor *compositor;
|
||||||
pixman_region32_t clip;
|
pixman_region32_t clip;
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
pixman_region32_t opaque;
|
pixman_region32_t opaque; /* part of geometry, see below */
|
||||||
pixman_region32_t input;
|
pixman_region32_t input;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_list layer_link;
|
struct wl_list layer_link;
|
||||||
float alpha;
|
float alpha; /* part of geometry, see below */
|
||||||
struct weston_plane *plane;
|
struct weston_plane *plane;
|
||||||
|
|
||||||
void *renderer_state;
|
void *renderer_state;
|
||||||
|
|
||||||
/* Surface geometry state, mutable.
|
/* 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.
|
* That includes the transformations referenced from the list.
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
@@ -414,14 +414,14 @@ struct weston_surface {
|
|||||||
|
|
||||||
/* struct weston_transform */
|
/* struct weston_transform */
|
||||||
struct wl_list transformation_list;
|
struct wl_list transformation_list;
|
||||||
|
|
||||||
int dirty;
|
|
||||||
} geometry;
|
} geometry;
|
||||||
|
|
||||||
/* State derived from geometry state, read-only.
|
/* State derived from geometry state, read-only.
|
||||||
* This is updated by weston_surface_update_transform().
|
* This is updated by weston_surface_update_transform().
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
|
int dirty;
|
||||||
|
|
||||||
pixman_region32_t boundingbox;
|
pixman_region32_t boundingbox;
|
||||||
pixman_region32_t opaque;
|
pixman_region32_t opaque;
|
||||||
|
|
||||||
@@ -499,6 +499,9 @@ weston_version(int *major, int *minor, int *micro);
|
|||||||
void
|
void
|
||||||
weston_surface_update_transform(struct weston_surface *surface);
|
weston_surface_update_transform(struct weston_surface *surface);
|
||||||
|
|
||||||
|
void
|
||||||
|
weston_surface_geometry_dirty(struct weston_surface *surface);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_surface_to_global_fixed(struct weston_surface *surface,
|
weston_surface_to_global_fixed(struct weston_surface *surface,
|
||||||
wl_fixed_t sx, wl_fixed_t sy,
|
wl_fixed_t sx, wl_fixed_t sy,
|
||||||
|
|||||||
+10
-14
@@ -610,7 +610,7 @@ surface_translate(struct weston_surface *surface, double d)
|
|||||||
weston_matrix_init(&shsurf->workspace_transform.matrix);
|
weston_matrix_init(&shsurf->workspace_transform.matrix);
|
||||||
weston_matrix_translate(&shsurf->workspace_transform.matrix,
|
weston_matrix_translate(&shsurf->workspace_transform.matrix,
|
||||||
0.0, d, 0.0);
|
0.0, d, 0.0);
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -686,7 +686,7 @@ workspace_deactivate_transforms(struct workspace *ws)
|
|||||||
wl_list_remove(&shsurf->workspace_transform.link);
|
wl_list_remove(&shsurf->workspace_transform.link);
|
||||||
wl_list_init(&shsurf->workspace_transform.link);
|
wl_list_init(&shsurf->workspace_transform.link);
|
||||||
}
|
}
|
||||||
shsurf->surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1530,7 +1530,7 @@ set_surface_type(struct shell_surface *shsurf)
|
|||||||
if (!wl_list_empty(&shsurf->rotation.transform.link)) {
|
if (!wl_list_empty(&shsurf->rotation.transform.link)) {
|
||||||
wl_list_remove(&shsurf->rotation.transform.link);
|
wl_list_remove(&shsurf->rotation.transform.link);
|
||||||
wl_list_init(&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;
|
shsurf->saved_rotation_valid = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2480,7 +2480,7 @@ surface_opacity_binding(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
|||||||
if (surface->alpha < step)
|
if (surface->alpha < step)
|
||||||
surface->alpha = step;
|
surface->alpha = step;
|
||||||
|
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
weston_surface_damage(surface);
|
weston_surface_damage(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2574,7 +2574,7 @@ rotate_grab_motion(struct wl_pointer_grab *grab,
|
|||||||
r = sqrtf(dx * dx + dy * dy);
|
r = sqrtf(dx * dx + dy * dy);
|
||||||
|
|
||||||
wl_list_remove(&shsurf->rotation.transform.link);
|
wl_list_remove(&shsurf->rotation.transform.link);
|
||||||
shsurf->surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(shsurf->surface);
|
||||||
|
|
||||||
if (r > 20.0f) {
|
if (r > 20.0f) {
|
||||||
struct weston_matrix *matrix =
|
struct weston_matrix *matrix =
|
||||||
@@ -2939,7 +2939,7 @@ show_input_panels(struct wl_listener *listener, void *data)
|
|||||||
ws = surface->surface;
|
ws = surface->surface;
|
||||||
wl_list_insert(&shell->input_panel_layer.surface_list,
|
wl_list_insert(&shell->input_panel_layer.surface_list,
|
||||||
&ws->layer_link);
|
&ws->layer_link);
|
||||||
ws->geometry.dirty = 1;
|
weston_surface_geometry_dirty(ws);
|
||||||
weston_surface_update_transform(ws);
|
weston_surface_update_transform(ws);
|
||||||
weston_surface_damage(ws);
|
weston_surface_damage(ws);
|
||||||
weston_slide_run(ws, ws->geometry.height, 0, NULL, NULL);
|
weston_slide_run(ws, ws->geometry.height, 0, NULL, NULL);
|
||||||
@@ -3056,7 +3056,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
|
|||||||
|
|
||||||
surface->geometry.width = width;
|
surface->geometry.width = width;
|
||||||
surface->geometry.height = height;
|
surface->geometry.height = height;
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
|
|
||||||
/* initial positioning, see also configure() */
|
/* initial positioning, see also configure() */
|
||||||
switch (surface_type) {
|
switch (surface_type) {
|
||||||
@@ -3150,11 +3150,7 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
|
|||||||
if (shsurf)
|
if (shsurf)
|
||||||
surface_type = shsurf->type;
|
surface_type = shsurf->type;
|
||||||
|
|
||||||
surface->geometry.x = x;
|
weston_surface_configure(surface, x, y, width, height);
|
||||||
surface->geometry.y = y;
|
|
||||||
surface->geometry.width = width;
|
|
||||||
surface->geometry.height = height;
|
|
||||||
surface->geometry.dirty = 1;
|
|
||||||
|
|
||||||
switch (surface_type) {
|
switch (surface_type) {
|
||||||
case SHELL_SURFACE_FULLSCREEN:
|
case SHELL_SURFACE_FULLSCREEN:
|
||||||
@@ -3586,7 +3582,7 @@ switcher_next(struct switcher *switcher)
|
|||||||
next = surface;
|
next = surface;
|
||||||
prev = surface;
|
prev = surface;
|
||||||
surface->alpha = 0.25;
|
surface->alpha = 0.25;
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
weston_surface_damage(surface);
|
weston_surface_damage(surface);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -3595,7 +3591,7 @@ switcher_next(struct switcher *switcher)
|
|||||||
|
|
||||||
if (is_black_surface(surface, NULL)) {
|
if (is_black_surface(surface, NULL)) {
|
||||||
surface->alpha = 0.25;
|
surface->alpha = 0.25;
|
||||||
surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(surface);
|
||||||
weston_surface_damage(surface);
|
weston_surface_damage(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -823,7 +823,7 @@ weston_wm_window_draw_decoration(void *data)
|
|||||||
x - 1, y - 1,
|
x - 1, y - 1,
|
||||||
window->width + 2,
|
window->width + 2,
|
||||||
window->height + 2);
|
window->height + 2);
|
||||||
window->surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(window->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->surface && !window->fullscreen) {
|
if (window->surface && !window->fullscreen) {
|
||||||
@@ -847,7 +847,7 @@ weston_wm_window_schedule_repaint(struct weston_wm_window *window)
|
|||||||
pixman_region32_fini(&window->surface->pending.opaque);
|
pixman_region32_fini(&window->surface->pending.opaque);
|
||||||
pixman_region32_init_rect(&window->surface->pending.opaque, 0, 0,
|
pixman_region32_init_rect(&window->surface->pending.opaque, 0, 0,
|
||||||
width, height);
|
width, height);
|
||||||
window->surface->geometry.dirty = 1;
|
weston_surface_geometry_dirty(window->surface);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -83,11 +83,8 @@ test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, i
|
|||||||
wl_list_insert(&test->layer.surface_list,
|
wl_list_insert(&test->layer.surface_list,
|
||||||
&surface->layer_link);
|
&surface->layer_link);
|
||||||
|
|
||||||
surface->geometry.x = test_surface->x;
|
weston_surface_configure(surface, test_surface->x, test_surface->y,
|
||||||
surface->geometry.y = test_surface->y;
|
width, height);
|
||||||
surface->geometry.width = width;
|
|
||||||
surface->geometry.height = height;
|
|
||||||
surface->geometry.dirty = 1;
|
|
||||||
|
|
||||||
if (!weston_surface_is_mapped(surface))
|
if (!weston_surface_is_mapped(surface))
|
||||||
weston_surface_update_transform(surface);
|
weston_surface_update_transform(surface);
|
||||||
|
|||||||
Reference in New Issue
Block a user