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>
This commit is contained in:
committed by
Kristian Høgsberg
parent
d4c1cd77c3
commit
a7af70436b
+13
-10
@@ -29,39 +29,42 @@ surface_to_from_global(void *data)
|
||||
{
|
||||
struct weston_compositor *compositor = data;
|
||||
struct weston_surface *surface;
|
||||
struct weston_view *view;
|
||||
float x, y;
|
||||
wl_fixed_t fx, fy;
|
||||
int32_t ix, iy;
|
||||
|
||||
surface = weston_surface_create(compositor);
|
||||
assert(surface);
|
||||
weston_surface_configure(surface, 5, 10, 50, 50);
|
||||
weston_surface_update_transform(surface);
|
||||
view = weston_view_create(surface);
|
||||
assert(view);
|
||||
weston_view_configure(view, 5, 10, 50, 50);
|
||||
weston_view_update_transform(view);
|
||||
|
||||
weston_surface_to_global_float(surface, 33, 22, &x, &y);
|
||||
weston_view_to_global_float(view, 33, 22, &x, &y);
|
||||
assert(x == 38 && y == 32);
|
||||
|
||||
weston_surface_to_global_float(surface, -8, -2, &x, &y);
|
||||
weston_view_to_global_float(view, -8, -2, &x, &y);
|
||||
assert(x == -3 && y == 8);
|
||||
|
||||
weston_surface_to_global_fixed(surface, wl_fixed_from_int(12),
|
||||
weston_view_to_global_fixed(view, wl_fixed_from_int(12),
|
||||
wl_fixed_from_int(5), &fx, &fy);
|
||||
assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));
|
||||
|
||||
weston_surface_from_global_float(surface, 38, 32, &x, &y);
|
||||
weston_view_from_global_float(view, 38, 32, &x, &y);
|
||||
assert(x == 33 && y == 22);
|
||||
|
||||
weston_surface_from_global_float(surface, 42, 5, &x, &y);
|
||||
weston_view_from_global_float(view, 42, 5, &x, &y);
|
||||
assert(x == 37 && y == -5);
|
||||
|
||||
weston_surface_from_global_fixed(surface, wl_fixed_from_int(21),
|
||||
weston_view_from_global_fixed(view, wl_fixed_from_int(21),
|
||||
wl_fixed_from_int(100), &fx, &fy);
|
||||
assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));
|
||||
|
||||
weston_surface_from_global(surface, 0, 0, &ix, &iy);
|
||||
weston_view_from_global(view, 0, 0, &ix, &iy);
|
||||
assert(ix == -5 && iy == -10);
|
||||
|
||||
weston_surface_from_global(surface, 5, 10, &ix, &iy);
|
||||
weston_view_from_global(view, 5, 10, &ix, &iy);
|
||||
assert(ix == 0 && iy == 0);
|
||||
|
||||
wl_display_terminate(compositor->wl_display);
|
||||
|
||||
@@ -31,20 +31,23 @@ surface_transform(void *data)
|
||||
{
|
||||
struct weston_compositor *compositor = data;
|
||||
struct weston_surface *surface;
|
||||
struct weston_view *view;
|
||||
float x, y;
|
||||
|
||||
surface = weston_surface_create(compositor);
|
||||
assert(surface);
|
||||
weston_surface_configure(surface, 100, 100, 200, 200);
|
||||
weston_surface_update_transform(surface);
|
||||
weston_surface_to_global_float(surface, 20, 20, &x, &y);
|
||||
view = weston_view_create(surface);
|
||||
assert(view);
|
||||
weston_view_configure(view, 100, 100, 200, 200);
|
||||
weston_view_update_transform(view);
|
||||
weston_view_to_global_float(view, 20, 20, &x, &y);
|
||||
|
||||
fprintf(stderr, "20,20 maps to %f, %f\n", x, y);
|
||||
assert(x == 120 && y == 120);
|
||||
|
||||
weston_surface_set_position(surface, 150, 300);
|
||||
weston_surface_update_transform(surface);
|
||||
weston_surface_to_global_float(surface, 50, 40, &x, &y);
|
||||
weston_view_set_position(view, 150, 300);
|
||||
weston_view_update_transform(view);
|
||||
weston_view_to_global_float(view, 50, 40, &x, &y);
|
||||
assert(x == 200 && y == 340);
|
||||
|
||||
wl_display_terminate(compositor->wl_display);
|
||||
|
||||
+25
-13
@@ -36,6 +36,7 @@ struct weston_test {
|
||||
|
||||
struct weston_test_surface {
|
||||
struct weston_surface *surface;
|
||||
struct weston_view *view;
|
||||
int32_t x, y;
|
||||
struct weston_test *test;
|
||||
};
|
||||
@@ -79,15 +80,16 @@ test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, i
|
||||
struct weston_test_surface *test_surface = surface->configure_private;
|
||||
struct weston_test *test = test_surface->test;
|
||||
|
||||
if (wl_list_empty(&surface->layer_link))
|
||||
wl_list_insert(&test->layer.surface_list,
|
||||
&surface->layer_link);
|
||||
if (wl_list_empty(&test_surface->view->layer_link))
|
||||
wl_list_insert(&test->layer.view_list,
|
||||
&test_surface->view->layer_link);
|
||||
|
||||
weston_surface_configure(surface, test_surface->x, test_surface->y,
|
||||
width, height);
|
||||
weston_view_configure(test_surface->view,
|
||||
test_surface->x, test_surface->y,
|
||||
width, height);
|
||||
|
||||
if (!weston_surface_is_mapped(surface))
|
||||
weston_surface_update_transform(surface);
|
||||
if (!weston_view_is_mapped(test_surface->view))
|
||||
weston_view_update_transform(test_surface->view);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -99,13 +101,23 @@ move_surface(struct wl_client *client, struct wl_resource *resource,
|
||||
wl_resource_get_user_data(surface_resource);
|
||||
struct weston_test_surface *test_surface;
|
||||
|
||||
surface->configure = test_surface_configure;
|
||||
if (surface->configure_private == NULL)
|
||||
surface->configure_private = malloc(sizeof *test_surface);
|
||||
test_surface = surface->configure_private;
|
||||
if (test_surface == NULL) {
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
if (!test_surface) {
|
||||
test_surface = malloc(sizeof *test_surface);
|
||||
if (!test_surface) {
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
|
||||
test_surface->view = weston_view_create(surface);
|
||||
if (!test_surface->view) {
|
||||
wl_resource_post_no_memory(resource);
|
||||
free(test_surface);
|
||||
return;
|
||||
}
|
||||
|
||||
surface->configure_private = test_surface;
|
||||
surface->configure = test_surface_configure;
|
||||
}
|
||||
|
||||
test_surface->surface = surface;
|
||||
|
||||
Reference in New Issue
Block a user