mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 20:28:03 +02:00
compositor: move weston_surface::width,height into geometry
weston_surface::transform.boundingbox depends on width and height, and therefore geometry.dirty flag, so move width and height into geometry. Fix all users and check that the dirty flag is set. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
parent
6720d8f3bd
commit
60921e5787
5 changed files with 74 additions and 54 deletions
|
|
@ -99,15 +99,16 @@ drm_output_prepare_scanout_surface(struct drm_output *output)
|
|||
if (es->visual != WESTON_RGB_VISUAL ||
|
||||
es->geometry.x != output->base.x ||
|
||||
es->geometry.y != output->base.y ||
|
||||
es->width != output->base.current->width ||
|
||||
es->height != output->base.current->height ||
|
||||
es->geometry.width != output->base.current->width ||
|
||||
es->geometry.height != output->base.current->height ||
|
||||
es->transform.enabled ||
|
||||
es->image == EGL_NO_IMAGE_KHR)
|
||||
return -1;
|
||||
|
||||
bo = gbm_bo_create_from_egl_image(c->gbm,
|
||||
c->base.display, es->image,
|
||||
es->width, es->height,
|
||||
es->geometry.width,
|
||||
es->geometry.height,
|
||||
GBM_BO_USE_SCANOUT);
|
||||
|
||||
handle = gbm_bo_get_handle(bo).s32;
|
||||
|
|
@ -234,7 +235,8 @@ drm_output_set_cursor(struct weston_output *output_base,
|
|||
pixman_region32_init_rect(&cursor_region,
|
||||
eid->sprite->geometry.x,
|
||||
eid->sprite->geometry.y,
|
||||
eid->sprite->width, eid->sprite->height);
|
||||
eid->sprite->geometry.width,
|
||||
eid->sprite->geometry.height);
|
||||
|
||||
pixman_region32_intersect_rect(&cursor_region, &cursor_region,
|
||||
output->base.x, output->base.y,
|
||||
|
|
@ -247,7 +249,8 @@ drm_output_set_cursor(struct weston_output *output_base,
|
|||
if (eid->sprite->image == EGL_NO_IMAGE_KHR)
|
||||
goto out;
|
||||
|
||||
if (eid->sprite->width > 64 || eid->sprite->height > 64)
|
||||
if (eid->sprite->geometry.width > 64 ||
|
||||
eid->sprite->geometry.height > 64)
|
||||
goto out;
|
||||
|
||||
bo = gbm_bo_create_from_egl_image(c->gbm,
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ weston_surface_create(struct weston_compositor *compositor,
|
|||
surface->image = EGL_NO_IMAGE_KHR;
|
||||
surface->geometry.x = x;
|
||||
surface->geometry.y = y;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->geometry.width = width;
|
||||
surface->geometry.height = height;
|
||||
surface->alpha = 255;
|
||||
|
||||
surface->fullscreen_output = NULL;
|
||||
|
|
@ -289,7 +289,8 @@ weston_surface_update_transform(struct weston_surface *surface)
|
|||
pixman_region32_init_rect(&surface->transform.boundingbox,
|
||||
surface->geometry.x,
|
||||
surface->geometry.y,
|
||||
surface->width, surface->height);
|
||||
surface->geometry.width,
|
||||
surface->geometry.height);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +310,8 @@ weston_surface_update_transform(struct weston_surface *surface)
|
|||
" transformation not invertible.\n", surface);
|
||||
}
|
||||
|
||||
surface_compute_bbox(surface, 0, 0, surface->width, surface->height,
|
||||
surface_compute_bbox(surface, 0, 0, surface->geometry.width,
|
||||
surface->geometry.height,
|
||||
&surface->transform.boundingbox);
|
||||
}
|
||||
|
||||
|
|
@ -399,7 +401,8 @@ WL_EXPORT void
|
|||
weston_surface_damage(struct weston_surface *surface)
|
||||
{
|
||||
weston_surface_damage_rectangle(surface, 0, 0,
|
||||
surface->width, surface->height);
|
||||
surface->geometry.width,
|
||||
surface->geometry.height);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
|
|
@ -418,7 +421,8 @@ weston_surface_damage_below(struct weston_surface *surface)
|
|||
pixman_region32_union_rect(&below->damage,
|
||||
&below->damage,
|
||||
surface->geometry.x, surface->geometry.y,
|
||||
surface->width, surface->height);
|
||||
surface->geometry.width,
|
||||
surface->geometry.height);
|
||||
weston_compositor_schedule_repaint(surface->compositor);
|
||||
}
|
||||
|
||||
|
|
@ -445,8 +449,8 @@ weston_surface_configure(struct weston_surface *surface,
|
|||
|
||||
surface->geometry.x = x;
|
||||
surface->geometry.y = y;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->geometry.width = width;
|
||||
surface->geometry.height = height;
|
||||
surface->geometry.dirty = 1;
|
||||
|
||||
weston_surface_assign_output(surface);
|
||||
|
|
@ -457,7 +461,8 @@ weston_surface_configure(struct weston_surface *surface,
|
|||
pixman_region32_init_rect(&surface->opaque,
|
||||
surface->geometry.x,
|
||||
surface->geometry.y,
|
||||
surface->width, surface->height);
|
||||
surface->geometry.width,
|
||||
surface->geometry.height);
|
||||
else
|
||||
pixman_region32_init(&surface->opaque);
|
||||
}
|
||||
|
|
@ -592,7 +597,7 @@ weston_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
|
|||
ec->image_target_texture_2d(GL_TEXTURE_2D, es->image);
|
||||
|
||||
es->visual = WESTON_ARGB_VISUAL;
|
||||
es->pitch = es->width;
|
||||
es->pitch = es->geometry.width;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -610,7 +615,7 @@ texture_region(struct weston_surface *es, pixman_region32_t *region)
|
|||
v = wl_array_add(&ec->vertices, n * 16 * sizeof *v);
|
||||
p = wl_array_add(&ec->indices, n * 6 * sizeof *p);
|
||||
inv_width = 1.0 / es->pitch;
|
||||
inv_height = 1.0 / es->height;
|
||||
inv_height = 1.0 / es->geometry.height;
|
||||
|
||||
for (i = 0; i < n; i++, v += 16, p += 6) {
|
||||
surface_from_global_float(es, rectangles[i].x1,
|
||||
|
|
@ -663,7 +668,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output)
|
|||
|
||||
pixman_region32_init_rect(&repaint,
|
||||
es->geometry.x, es->geometry.y,
|
||||
es->width, es->height);
|
||||
es->geometry.width, es->geometry.height);
|
||||
pixman_region32_intersect(&repaint, &repaint, &output->region);
|
||||
pixman_region32_intersect(&repaint, &repaint, &es->damage);
|
||||
|
||||
|
|
@ -701,7 +706,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output)
|
|||
|
||||
if (es->shader->texwidth_uniform != GL_NONE)
|
||||
glUniform1f(es->shader->texwidth_uniform,
|
||||
(GLfloat)es->width / es->pitch);
|
||||
(GLfloat)es->geometry.width / es->pitch);
|
||||
|
||||
weston_surface_update_transform(es);
|
||||
if (es->transform.enabled)
|
||||
|
|
@ -842,8 +847,8 @@ weston_output_set_cursor(struct weston_output *output,
|
|||
pixman_region32_init_rect(&cursor_region,
|
||||
device->sprite->geometry.x,
|
||||
device->sprite->geometry.y,
|
||||
device->sprite->width,
|
||||
device->sprite->height);
|
||||
device->sprite->geometry.width,
|
||||
device->sprite->geometry.height);
|
||||
|
||||
pixman_region32_intersect(&cursor_region, &cursor_region, &output->region);
|
||||
|
||||
|
|
@ -898,12 +903,14 @@ weston_output_repaint(struct weston_output *output, int msecs)
|
|||
pixman_region32_intersect_rect(&surface_overlap,
|
||||
&overlap,
|
||||
es->geometry.x, es->geometry.y,
|
||||
es->width, es->height);
|
||||
es->geometry.width,
|
||||
es->geometry.height);
|
||||
es->overlapped = pixman_region32_not_empty(&surface_overlap);
|
||||
pixman_region32_fini(&surface_overlap);
|
||||
pixman_region32_union_rect(&overlap, &overlap,
|
||||
es->geometry.x, es->geometry.y,
|
||||
es->width, es->height);
|
||||
es->geometry.width,
|
||||
es->geometry.height);
|
||||
}
|
||||
|
||||
weston_output_set_cursor(output, ec->input_device);
|
||||
|
|
@ -1034,7 +1041,8 @@ weston_surface_assign_output(struct weston_surface *es)
|
|||
wl_list_for_each(output, &ec->output_list, link) {
|
||||
pixman_region32_init_rect(®ion,
|
||||
es->geometry.x, es->geometry.y,
|
||||
es->width, es->height);
|
||||
es->geometry.width,
|
||||
es->geometry.height);
|
||||
pixman_region32_intersect(®ion, ®ion, &output->region);
|
||||
|
||||
e = pixman_region32_extents(®ion);
|
||||
|
|
@ -1078,8 +1086,8 @@ surface_attach(struct wl_client *client,
|
|||
if (es->visual == WESTON_NONE_VISUAL) {
|
||||
shell->map(shell, es, buffer->width, buffer->height);
|
||||
} else if (x != 0 || y != 0 ||
|
||||
es->width != buffer->width ||
|
||||
es->height != buffer->height) {
|
||||
es->geometry.width != buffer->width ||
|
||||
es->geometry.height != buffer->height) {
|
||||
/* FIXME: the x,y delta should be in surface-local coords */
|
||||
shell->configure(shell, es, es->geometry.x + x,
|
||||
es->geometry.y + y,
|
||||
|
|
@ -1182,8 +1190,8 @@ weston_compositor_pick_surface(struct weston_compositor *compositor,
|
|||
if (surface->surface.resource.client == NULL)
|
||||
continue;
|
||||
weston_surface_from_global(surface, x, y, sx, sy);
|
||||
if (0 <= *sx && *sx < surface->width &&
|
||||
0 <= *sy && *sy < surface->height)
|
||||
if (0 <= *sx && *sx < surface->geometry.width &&
|
||||
0 <= *sy && *sy < surface->geometry.height)
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
@ -1645,8 +1653,8 @@ input_device_attach(struct wl_client *client,
|
|||
|
||||
device->hotspot_x = x;
|
||||
device->hotspot_y = y;
|
||||
device->sprite->width = buffer->width;
|
||||
device->sprite->height = buffer->height;
|
||||
device->sprite->geometry.width = buffer->width;
|
||||
device->sprite->geometry.height = buffer->height;
|
||||
device->sprite->geometry.x = device->input_device.x - device->hotspot_x;
|
||||
device->sprite->geometry.y = device->input_device.y - device->hotspot_y;
|
||||
device->sprite->geometry.dirty = 1;
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ struct weston_surface {
|
|||
GLuint texture;
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_t opaque;
|
||||
int32_t width, height;
|
||||
int32_t pitch;
|
||||
struct wl_list link;
|
||||
struct wl_list buffer_link;
|
||||
|
|
@ -230,6 +229,7 @@ struct weston_surface {
|
|||
*/
|
||||
struct {
|
||||
int32_t x, y; /* surface translation on display */
|
||||
int32_t width, height;
|
||||
|
||||
/* struct weston_transform */
|
||||
struct wl_list transformation_list;
|
||||
|
|
|
|||
51
src/shell.c
51
src/shell.c
|
|
@ -166,7 +166,7 @@ move_grab_motion(struct wl_grab *grab,
|
|||
weston_surface_configure(es,
|
||||
device->x + move->dx,
|
||||
device->y + move->dy,
|
||||
es->width, es->height);
|
||||
es->geometry.width, es->geometry.height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -298,8 +298,8 @@ weston_surface_resize(struct shell_surface *shsurf,
|
|||
resize->edges = edges;
|
||||
resize->dx = es->geometry.x - wd->input_device.grab_x;
|
||||
resize->dy = es->geometry.y - wd->input_device.grab_y;
|
||||
resize->width = es->width;
|
||||
resize->height = es->height;
|
||||
resize->width = es->geometry.width;
|
||||
resize->height = es->geometry.height;
|
||||
resize->shsurf = shsurf;
|
||||
|
||||
if (edges == 0 || edges > 15 ||
|
||||
|
|
@ -434,8 +434,8 @@ shell_surface_set_fullscreen(struct wl_client *client,
|
|||
|
||||
shsurf->saved_x = es->geometry.x;
|
||||
shsurf->saved_y = es->geometry.y;
|
||||
es->geometry.x = (output->current->width - es->width) / 2;
|
||||
es->geometry.y = (output->current->height - es->height) / 2;
|
||||
es->geometry.x = (output->current->width - es->geometry.width) / 2;
|
||||
es->geometry.y = (output->current->height - es->geometry.height) / 2;
|
||||
es->geometry.dirty = 1;
|
||||
es->fullscreen_output = output;
|
||||
weston_surface_damage(es);
|
||||
|
|
@ -696,8 +696,8 @@ show_screensaver(struct wl_shell *shell, struct shell_surface *surface)
|
|||
weston_surface_configure(surface->surface,
|
||||
surface->surface->geometry.x,
|
||||
surface->surface->geometry.y,
|
||||
surface->surface->width,
|
||||
surface->surface->height);
|
||||
surface->surface->geometry.width,
|
||||
surface->surface->geometry.height);
|
||||
surface->surface->output = surface->output;
|
||||
}
|
||||
|
||||
|
|
@ -838,7 +838,8 @@ resume_desktop(struct wl_shell *shell)
|
|||
wl_list_for_each(surface, &shell->hidden_surface_list, link)
|
||||
weston_surface_configure(surface, surface->geometry.x,
|
||||
surface->geometry.y,
|
||||
surface->width, surface->height);
|
||||
surface->geometry.width,
|
||||
surface->geometry.height);
|
||||
|
||||
if (wl_list_empty(&shell->backgrounds)) {
|
||||
list = &shell->compositor->surface_list;
|
||||
|
|
@ -939,19 +940,20 @@ resize_binding(struct wl_input_device *device, uint32_t time,
|
|||
break;
|
||||
}
|
||||
|
||||
/* FIXME: convert properly to surface coordinates */
|
||||
x = device->grab_x - surface->geometry.x;
|
||||
y = device->grab_y - surface->geometry.y;
|
||||
|
||||
if (x < surface->width / 3)
|
||||
if (x < surface->geometry.width / 3)
|
||||
edges |= WL_SHELL_SURFACE_RESIZE_LEFT;
|
||||
else if (x < 2 * surface->width / 3)
|
||||
else if (x < 2 * surface->geometry.width / 3)
|
||||
edges |= 0;
|
||||
else
|
||||
edges |= WL_SHELL_SURFACE_RESIZE_RIGHT;
|
||||
|
||||
if (y < surface->height / 3)
|
||||
if (y < surface->geometry.height / 3)
|
||||
edges |= WL_SHELL_SURFACE_RESIZE_TOP;
|
||||
else if (y < 2 * surface->height / 3)
|
||||
else if (y < 2 * surface->geometry.height / 3)
|
||||
edges |= 0;
|
||||
else
|
||||
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
||||
|
|
@ -1070,8 +1072,8 @@ rotate_binding(struct wl_input_device *device, uint32_t time,
|
|||
rotate->surface = surface;
|
||||
|
||||
weston_surface_to_global(surface->surface,
|
||||
surface->surface->width / 2,
|
||||
surface->surface->height / 2,
|
||||
surface->surface->geometry.width / 2,
|
||||
surface->surface->geometry.height / 2,
|
||||
&rotate->center.x, &rotate->center.y);
|
||||
|
||||
wl_input_device_start_grab(device, &rotate->grab, time);
|
||||
|
|
@ -1230,8 +1232,10 @@ center_on_output(struct weston_surface *surface, struct weston_output *output)
|
|||
{
|
||||
struct weston_mode *mode = output->current;
|
||||
|
||||
surface->geometry.x = output->x + (mode->width - surface->width) / 2;
|
||||
surface->geometry.y = output->y + (mode->height - surface->height) / 2;
|
||||
surface->geometry.x =
|
||||
output->x + (mode->width - surface->geometry.width) / 2;
|
||||
surface->geometry.y =
|
||||
output->y + (mode->height - surface->geometry.height) / 2;
|
||||
surface->geometry.dirty = 1;
|
||||
}
|
||||
|
||||
|
|
@ -1258,8 +1262,9 @@ map(struct weston_shell *base,
|
|||
do_configure = 1;
|
||||
}
|
||||
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->geometry.width = width;
|
||||
surface->geometry.height = height;
|
||||
surface->geometry.dirty = 1;
|
||||
|
||||
/* initial positioning, see also configure() */
|
||||
switch (surface_type) {
|
||||
|
|
@ -1334,8 +1339,9 @@ map(struct weston_shell *base,
|
|||
break;
|
||||
}
|
||||
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->geometry.width = width;
|
||||
surface->geometry.height = height;
|
||||
surface->geometry.dirty = 1;
|
||||
if (do_configure) {
|
||||
weston_surface_configure(surface, surface->geometry.x,
|
||||
surface->geometry.y,
|
||||
|
|
@ -1374,8 +1380,9 @@ configure(struct weston_shell *base, struct weston_surface *surface,
|
|||
if (shsurf)
|
||||
surface_type = shsurf->type;
|
||||
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->geometry.width = width;
|
||||
surface->geometry.height = height;
|
||||
surface->geometry.dirty = 1;
|
||||
|
||||
switch (surface_type) {
|
||||
case SHELL_SURFACE_SCREENSAVER:
|
||||
|
|
|
|||
|
|
@ -135,10 +135,12 @@ weston_zoom_frame(struct weston_animation *animation,
|
|||
(zoom->stop - zoom->start) * zoom->spring.current;
|
||||
weston_matrix_init(&zoom->transform.matrix);
|
||||
weston_matrix_translate(&zoom->transform.matrix,
|
||||
-0.5f * es->width, -0.5f * es->height, 0);
|
||||
-0.5f * es->geometry.width,
|
||||
-0.5f * es->geometry.height, 0);
|
||||
weston_matrix_scale(&zoom->transform.matrix, scale, scale, scale);
|
||||
weston_matrix_translate(&zoom->transform.matrix,
|
||||
0.5f * es->width, 0.5f * es->height, 0);
|
||||
0.5f * es->geometry.width,
|
||||
0.5f * es->geometry.height, 0);
|
||||
|
||||
es->alpha = zoom->spring.current * 255;
|
||||
if (es->alpha > 255)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue