commit 6fb96f3
Michael Forney
·
2013-07-25 06:56:23 +0000 UTC
parent 3e011e5
Remove wld_wayland_create_buffer_from_drawables
+20,
-34
1@@ -187,54 +187,40 @@ struct wld_drawable * wld_wayland_create_drawable
2 uint32_t width, uint32_t height, enum wld_format format)
3 {
4 struct wayland_drawable * wayland;
5- struct wld_drawable * drawables[2];
6- struct wl_buffer * buffers[2];
7
8- drawables[0] = context->interface->create_drawable
9- (context->context, width, height, format, &buffers[0]);
10- drawables[1] = context->interface->create_drawable
11- (context->context, width, height, format, &buffers[1]);
12+ wayland = malloc(sizeof *wayland);
13
14- wayland = (void *) wld_wayland_create_drawable_from_buffers
15- (surface, buffers, drawables);
16+ if (!wayland)
17+ goto error0;
18
19 wayland->context = context;
20+ wayland->buffers[0].drawable = context->interface->create_drawable
21+ (context->context, width, height, format, &wayland->buffers[0].wl);
22
23- return &wayland->base;
24-}
25-
26-struct wld_drawable * wld_wayland_create_drawable_from_buffers
27- (struct wl_surface * surface,
28- struct wl_buffer * buffers[], struct wld_drawable * drawables[])
29-{
30- struct wayland_drawable * wayland;
31- uint32_t * data;
32-
33- if (drawables[0]->width != drawables[1]->width
34- || drawables[0]->height != drawables[1]->height)
35- {
36- DEBUG("Drawables aren't the same dimensions\n");
37- return NULL;
38- }
39+ if (!wayland->buffers[0].drawable)
40+ goto error1;
41
42- wayland = malloc(sizeof *wayland);
43+ wayland->buffers[1].drawable = context->interface->create_drawable
44+ (context->context, width, height, format, &wayland->buffers[1].wl);
45
46- if (!wayland)
47- return NULL;
48+ if (!wayland->buffers[1].drawable)
49+ goto error2;
50
51- wayland->context = NULL;
52- wayland->buffers[0].wl = buffers[0];
53- wayland->buffers[1].wl = buffers[1];
54- wayland->buffers[0].drawable = drawables[0];
55- wayland->buffers[1].drawable = drawables[1];
56 wayland->front_buffer = 0;
57 wayland->surface = surface;
58
59 wayland->base.interface = &wayland_draw;
60- wayland->base.width = drawables[0]->width;
61- wayland->base.height = drawables[0]->height;
62+ wayland->base.width = width;
63+ wayland->base.height = height;
64
65 return &wayland->base;
66+
67+ error2:
68+ wld_destroy_drawable(wayland->buffers[0].drawable);
69+ error1:
70+ free(wayland);
71+ error0:
72+ return NULL;
73 }
74
75 int wayland_roundtrip(struct wl_display * display,
+0,
-13
1@@ -77,18 +77,5 @@ struct wld_drawable * wld_wayland_create_drawable
2 (struct wld_wayland_context * context, struct wl_surface * surface,
3 uint32_t width, uint32_t height, enum wld_format format);
4
5-/**
6- * Create a new Wayland drawable for the given surface, using the given buffers
7- * and drawables as backing for the surface.
8- *
9- * You must pass exactly two buffers and drawables
10- *
11- * This method does not require a Wayland context to be created because buffers
12- * and drawables are passed to it explicitly.
13- */
14-struct wld_drawable * wld_wayland_create_drawable_from_buffers
15- (struct wl_surface * surface,
16- struct wl_buffer * buffers[], struct wld_drawable * drawables[]);
17-
18 #endif
19