commit a36513f
Michael Forney
·
2014-01-17 02:22:13 +0000 UTC
parent 6797a55
view: Make functions take a view instead of a surface
3 files changed,
+40,
-44
+24,
-22
1@@ -23,6 +23,7 @@ struct view
2 {
3 struct swc_view base;
4 struct swc_compositor * compositor;
5+ struct swc_surface * surface;
6
7 /* The box that the surface covers (including it's border). */
8 pixman_box32_t extents;
9@@ -135,8 +136,7 @@ static void renderer_repaint(struct render_target * target,
10 wld_flush(swc.drm->renderer);
11 }
12
13-static void renderer_attach(struct swc_surface * surface,
14- struct swc_buffer * buffer)
15+static void renderer_attach(struct view * view, struct swc_buffer * buffer)
16 {
17 }
18
19@@ -241,7 +241,7 @@ static void update_outputs(struct swc_surface * surface)
20 surface->outputs = new_outputs;
21 }
22
23-static void update(struct swc_surface * surface);
24+static void update(struct swc_view * view);
25
26 static void handle_surface_event(struct wl_listener * listener, void * data)
27 {
28@@ -257,33 +257,33 @@ static void handle_surface_event(struct wl_listener * listener, void * data)
29 damage_below_surface(surface);
30
31 update_extents(surface);
32- update(surface);
33+ update(&view->base);
34 update_outputs(surface);
35
36 break;
37 }
38 }
39
40-static void remove_(struct swc_surface * surface)
41+static void remove_(struct swc_view * base)
42 {
43- struct view * view = (void *) surface->view;
44-
45- swc_compositor_surface_hide(surface);
46+ struct view * view = (void *) base;
47
48+ swc_compositor_surface_hide(view->surface);
49 wl_list_remove(&view->surface_event_listener.link);
50 pixman_region32_fini(&view->clip);
51-
52 free(view);
53 }
54
55-static void attach(struct swc_surface * surface, struct swc_buffer * buffer)
56+static void attach(struct swc_view * base, struct swc_buffer * buffer)
57 {
58- renderer_attach(surface, buffer);
59+ struct view * view = (void *) base;
60+
61+ renderer_attach(view, buffer);
62 }
63
64-static void update(struct swc_surface * surface)
65+static void update(struct swc_view * base)
66 {
67- struct view * view = (void *) surface->view;
68+ struct view * view = (void *) base;
69 struct swc_compositor * compositor = view->compositor;
70 struct swc_output * output;
71
72@@ -292,14 +292,15 @@ static void update(struct swc_surface * surface)
73
74 wl_list_for_each(output, &compositor->outputs, link)
75 {
76- if (surface->outputs & SWC_OUTPUT_MASK(output))
77+ if (view->surface->outputs & SWC_OUTPUT_MASK(output))
78 swc_compositor_schedule_update(compositor, output);
79 }
80 }
81
82-static void move(struct swc_surface * surface, int32_t x, int32_t y)
83+static void move(struct swc_view * base, int32_t x, int32_t y)
84 {
85- struct view * view = (void *) surface->view;
86+ struct view * view = (void *) base;
87+ struct swc_surface * surface = view->surface;
88
89 if (x == surface->geometry.x && y == surface->geometry.y)
90 return;
91@@ -319,9 +320,9 @@ static void move(struct swc_surface * surface, int32_t x, int32_t y)
92 pixman_region32_init(&view->clip);
93
94 damage_below_surface(surface);
95- update(surface);
96+ update(&view->base);
97 update_outputs(surface);
98- update(surface);
99+ update(&view->base);
100 }
101 }
102
103@@ -344,6 +345,7 @@ bool swc_compositor_add_surface(struct swc_compositor * compositor,
104
105 swc_view_initialize(&view->base, &view_impl);
106 view->compositor = compositor;
107+ view->surface = surface;
108 view->mapped = false;
109 view->extents.x1 = surface->geometry.x;
110 view->extents.y1 = surface->geometry.y;
111@@ -381,7 +383,7 @@ void swc_compositor_surface_show(struct swc_surface * surface)
112
113 damage_surface(surface);
114 update_outputs(surface);
115- update(surface);
116+ update(&view->base);
117 wl_list_insert(&compositor->surfaces, &surface->link);
118 }
119
120@@ -396,7 +398,7 @@ void swc_compositor_surface_hide(struct swc_surface * surface)
121 return;
122
123 /* Update all the outputs the surface was on. */
124- update(surface);
125+ update(&view->base);
126
127 view->mapped = false;
128
129@@ -419,7 +421,7 @@ void swc_compositor_surface_set_border_width(struct swc_surface * surface,
130 /* XXX: Damage above surface for transparent surfaces? */
131
132 update_extents(surface);
133- update(surface);
134+ update(&view->base);
135 }
136
137 void swc_compositor_surface_set_border_color(struct swc_surface * surface,
138@@ -435,7 +437,7 @@ void swc_compositor_surface_set_border_color(struct swc_surface * surface,
139
140 /* XXX: Damage above surface for transparent surfaces? */
141
142- update(surface);
143+ update(&view->base);
144 }
145
146 /* }}} */
+8,
-8
1@@ -293,8 +293,8 @@ static void commit(struct wl_client * client, struct wl_resource * resource)
2 if (surface->view)
3 {
4 if (surface->pending.commit & SWC_SURFACE_COMMIT_ATTACH)
5- surface->view->impl->attach(surface, surface->state.buffer);
6- surface->view->impl->update(surface);
7+ surface->view->impl->attach(surface->view, surface->state.buffer);
8+ surface->view->impl->update(surface->view);
9 }
10
11 surface->pending.commit = 0;
12@@ -329,7 +329,7 @@ static void surface_destroy(struct wl_resource * resource)
13 struct swc_surface * surface = wl_resource_get_user_data(resource);
14
15 if (surface->view && surface->view->impl->remove)
16- surface->view->impl->remove(surface);
17+ surface->view->impl->remove(surface->view);
18
19 /* Finish the surface. */
20 state_finish(&surface->state);
21@@ -416,7 +416,7 @@ void swc_surface_set_view(struct swc_surface * surface, struct swc_view * view)
22 if (surface->view)
23 {
24 if (surface->view->impl->remove)
25- surface->view->impl->remove(surface);
26+ surface->view->impl->remove(surface->view);
27 wl_list_remove(&surface->view_listener.link);
28 }
29
30@@ -425,20 +425,20 @@ void swc_surface_set_view(struct swc_surface * surface, struct swc_view * view)
31 if (view)
32 {
33 wl_signal_add(&view->event_signal, &surface->view_listener);
34- surface->view->impl->attach(surface, surface->state.buffer);
35- surface->view->impl->update(surface);
36+ surface->view->impl->attach(surface->view, surface->state.buffer);
37+ surface->view->impl->update(surface->view);
38 }
39 }
40
41 void swc_surface_update(struct swc_surface * surface)
42 {
43 if (surface->view)
44- surface->view->impl->update(surface);
45+ surface->view->impl->update(surface->view);
46 }
47
48 void swc_surface_move(struct swc_surface * surface, int32_t x, int32_t y)
49 {
50 if (surface->view)
51- surface->view->impl->move(surface, x, y);
52+ surface->view->impl->move(surface->view, x, y);
53 }
54
+8,
-14
1@@ -26,7 +26,6 @@
2
3 #include "swc.h"
4
5-struct swc_surface;
6 struct swc_buffer;
7
8 enum swc_view_event
9@@ -54,24 +53,19 @@ struct swc_view
10 struct wl_signal event_signal;
11 };
12
13-/**
14- * A view is a set of operations that can be performed on a surface. This
15- * gives the compositor the ability to classify surfaces, treating some
16- * specially (for example, a cursor surface).
17- */
18 struct swc_view_impl
19 {
20- /* Called when a surface is removed from the view. */
21- void (* remove)(struct swc_surface * surface);
22+ /* Called when a source is removed from the view. */
23+ void (* remove)(struct swc_view * view);
24
25- /* Called when a new buffer is attached to a surface. */
26- void (* attach)(struct swc_surface * surface, struct swc_buffer * buffer);
27+ /* Called when a new buffer is attached to the view. */
28+ void (* attach)(struct swc_view * view, struct swc_buffer * buffer);
29
30- /* Called after a surface requests a commit. */
31- void (* update)(struct swc_surface * surface);
32+ /* Called when the view should present a new frame. */
33+ void (* update)(struct swc_view * view);
34
35- /* Moves the surface to the specified coordinates. */
36- void (* move)(struct swc_surface * surface, int32_t x, int32_t y);
37+ /* Move the view to the specified coordinates. */
38+ void (* move)(struct swc_view * view, int32_t x, int32_t y);
39 };
40
41 void swc_view_initialize(struct swc_view * view,