Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 987c539..85fcd4c 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -223,16 +223,16 @@
#define D2F(v) pixman_double_to_fixed((double)v)
static void
-repaint_region(struct weston_surface *es, struct weston_output *output,
+repaint_region(struct weston_view *ev, struct weston_output *output,
pixman_region32_t *region, pixman_region32_t *surf_region,
pixman_op_t pixman_op)
{
struct pixman_renderer *pr =
(struct pixman_renderer *) output->compositor->renderer;
- struct pixman_surface_state *ps = get_surface_state(es);
+ struct pixman_surface_state *ps = get_surface_state(ev->surface);
struct pixman_output_state *po = get_output_state(output);
pixman_region32_t final_region;
- float surface_x, surface_y;
+ float view_x, view_y;
pixman_transform_t transform;
pixman_fixed_t fw, fh;
@@ -246,11 +246,11 @@
pixman_region32_copy(&final_region, surf_region);
/* Convert from surface to global coordinates */
- if (!es->transform.enabled) {
- pixman_region32_translate(&final_region, es->geometry.x, es->geometry.y);
+ if (!ev->transform.enabled) {
+ pixman_region32_translate(&final_region, ev->geometry.x, ev->geometry.y);
} else {
- weston_surface_to_global_float(es, 0, 0, &surface_x, &surface_y);
- pixman_region32_translate(&final_region, (int)surface_x, (int)surface_y);
+ weston_view_to_global_float(ev, 0, 0, &view_x, &view_y);
+ pixman_region32_translate(&final_region, (int)view_x, (int)view_y);
}
/* We need to paint the intersection */
@@ -314,22 +314,22 @@
pixman_double_to_fixed (output->x),
pixman_double_to_fixed (output->y));
- if (es->transform.enabled) {
+ if (ev->transform.enabled) {
/* Pixman supports only 2D transform matrix, but Weston uses 3D,
* so we're omitting Z coordinate here
*/
pixman_transform_t surface_transform = {{
- { D2F(es->transform.matrix.d[0]),
- D2F(es->transform.matrix.d[4]),
- D2F(es->transform.matrix.d[12]),
+ { D2F(ev->transform.matrix.d[0]),
+ D2F(ev->transform.matrix.d[4]),
+ D2F(ev->transform.matrix.d[12]),
},
- { D2F(es->transform.matrix.d[1]),
- D2F(es->transform.matrix.d[5]),
- D2F(es->transform.matrix.d[13]),
+ { D2F(ev->transform.matrix.d[1]),
+ D2F(ev->transform.matrix.d[5]),
+ D2F(ev->transform.matrix.d[13]),
},
- { D2F(es->transform.matrix.d[3]),
- D2F(es->transform.matrix.d[7]),
- D2F(es->transform.matrix.d[15]),
+ { D2F(ev->transform.matrix.d[3]),
+ D2F(ev->transform.matrix.d[7]),
+ D2F(ev->transform.matrix.d[15]),
}
}};
@@ -337,15 +337,15 @@
pixman_transform_multiply (&transform, &surface_transform, &transform);
} else {
pixman_transform_translate(&transform, NULL,
- pixman_double_to_fixed ((double)-es->geometry.x),
- pixman_double_to_fixed ((double)-es->geometry.y));
+ pixman_double_to_fixed ((double)-ev->geometry.x),
+ pixman_double_to_fixed ((double)-ev->geometry.y));
}
- fw = pixman_int_to_fixed(es->geometry.width);
- fh = pixman_int_to_fixed(es->geometry.height);
+ fw = pixman_int_to_fixed(ev->geometry.width);
+ fh = pixman_int_to_fixed(ev->geometry.height);
- switch (es->buffer_transform) {
+ switch (ev->surface->buffer_transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
@@ -357,7 +357,7 @@
break;
}
- switch (es->buffer_transform) {
+ switch (ev->surface->buffer_transform) {
default:
case WL_OUTPUT_TRANSFORM_NORMAL:
case WL_OUTPUT_TRANSFORM_FLIPPED:
@@ -380,12 +380,12 @@
}
pixman_transform_scale(&transform, NULL,
- pixman_double_to_fixed ((double)es->buffer_scale),
- pixman_double_to_fixed ((double)es->buffer_scale));
+ pixman_double_to_fixed ((double)ev->surface->buffer_scale),
+ pixman_double_to_fixed ((double)ev->surface->buffer_scale));
pixman_image_set_transform(ps->image, &transform);
- if (es->transform.enabled || output->current_scale != es->buffer_scale)
+ if (ev->transform.enabled || output->current_scale != ev->surface->buffer_scale)
pixman_image_set_filter(ps->image, PIXMAN_FILTER_BILINEAR, NULL, 0);
else
pixman_image_set_filter(ps->image, PIXMAN_FILTER_NEAREST, NULL, 0);
@@ -417,10 +417,10 @@
}
static void
-draw_surface(struct weston_surface *es, struct weston_output *output,
- pixman_region32_t *damage) /* in global coordinates */
+draw_view(struct weston_view *ev, struct weston_output *output,
+ pixman_region32_t *damage) /* in global coordinates */
{
- struct pixman_surface_state *ps = get_surface_state(es);
+ struct pixman_surface_state *ps = get_surface_state(ev->surface);
/* repaint bounding region in global coordinates: */
pixman_region32_t repaint;
/* non-opaque region in surface coordinates: */
@@ -432,8 +432,8 @@
pixman_region32_init(&repaint);
pixman_region32_intersect(&repaint,
- &es->transform.boundingbox, damage);
- pixman_region32_subtract(&repaint, &repaint, &es->clip);
+ &ev->transform.boundingbox, damage);
+ pixman_region32_subtract(&repaint, &repaint, &ev->clip);
if (!pixman_region32_not_empty(&repaint))
goto out;
@@ -444,21 +444,21 @@
}
/* TODO: Implement repaint_region_complex() using pixman_composite_trapezoids() */
- if (es->transform.enabled &&
- es->transform.matrix.type != WESTON_MATRIX_TRANSFORM_TRANSLATE) {
- repaint_region(es, output, &repaint, NULL, PIXMAN_OP_OVER);
+ if (ev->transform.enabled &&
+ ev->transform.matrix.type != WESTON_MATRIX_TRANSFORM_TRANSLATE) {
+ repaint_region(ev, output, &repaint, NULL, PIXMAN_OP_OVER);
} else {
/* blended region is whole surface minus opaque region: */
pixman_region32_init_rect(&surface_blend, 0, 0,
- es->geometry.width, es->geometry.height);
- pixman_region32_subtract(&surface_blend, &surface_blend, &es->opaque);
+ ev->geometry.width, ev->geometry.height);
+ pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
- if (pixman_region32_not_empty(&es->opaque)) {
- repaint_region(es, output, &repaint, &es->opaque, PIXMAN_OP_SRC);
+ if (pixman_region32_not_empty(&ev->surface->opaque)) {
+ repaint_region(ev, output, &repaint, &ev->surface->opaque, PIXMAN_OP_SRC);
}
if (pixman_region32_not_empty(&surface_blend)) {
- repaint_region(es, output, &repaint, &surface_blend, PIXMAN_OP_OVER);
+ repaint_region(ev, output, &repaint, &surface_blend, PIXMAN_OP_OVER);
}
pixman_region32_fini(&surface_blend);
}
@@ -471,11 +471,11 @@
repaint_surfaces(struct weston_output *output, pixman_region32_t *damage)
{
struct weston_compositor *compositor = output->compositor;
- struct weston_surface *surface;
+ struct weston_view *view;
- wl_list_for_each_reverse(surface, &compositor->surface_list, link)
- if (surface->plane == &compositor->primary_plane)
- draw_surface(surface, output, damage);
+ wl_list_for_each_reverse(view, &compositor->view_list, link)
+ if (view->plane == &compositor->primary_plane)
+ draw_view(view, output, damage);
}
static void