commit 226ac95
Michael Forney
·
2014-01-13 22:37:50 +0000 UTC
parent c253a00
Add drawable_initialize convenience function
4 files changed,
+26,
-16
+12,
-0
1@@ -60,6 +60,18 @@ void default_copy_region(struct wld_drawable * src, struct wld_drawable * dst,
2 }
3 }
4
5+void drawable_initialize(struct wld_drawable * drawable,
6+ const struct wld_drawable_impl * impl,
7+ uint32_t width, uint32_t height,
8+ uint32_t format, uint32_t pitch)
9+{
10+ *((const struct wld_drawable_impl **) &drawable->impl) = impl;
11+ drawable->width = width;
12+ drawable->height = height;
13+ drawable->format = format;
14+ drawable->pitch = pitch;
15+}
16+
17 EXPORT
18 void wld_fill_rectangle(struct wld_drawable * drawable, uint32_t color,
19 int32_t x, int32_t y, uint32_t width, uint32_t height)
M
intel.c
+2,
-4
1@@ -96,10 +96,8 @@ static struct intel_drawable * new_drawable(struct intel_context * context,
2 if (!(intel = malloc(sizeof *intel)))
3 return NULL;
4
5- intel->base.impl = &drawable_impl.base;
6- intel->base.width = width;
7- intel->base.height = height;
8- intel->base.format = format;
9+ drawable_initialize(&intel->base, &drawable_impl.base,
10+ width, height, format, 0);
11 intel->context = context;
12 intel->virtual = NULL;
13
M
pixman.c
+7,
-12
1@@ -68,12 +68,8 @@ bool pixman_initialize_drawable
2 uint32_t width, uint32_t height,
3 void * data, uint32_t pitch, uint32_t format)
4 {
5- drawable->base.impl = &drawable_impl;
6- drawable->base.width = width;
7- drawable->base.height = height;
8- drawable->base.format = format;
9- drawable->base.pitch = pitch;
10-
11+ drawable_initialize(&drawable->base, &drawable_impl,
12+ width, height, format, pitch);
13 drawable->context = (void *) context;
14 drawable->image = pixman_image_create_bits(format_wld_to_pixman(format),
15 width, height,
16@@ -90,12 +86,11 @@ struct wld_drawable * new_drawable(struct pixman_context * context,
17 if (!(drawable = malloc(sizeof *drawable)))
18 return NULL;
19
20- drawable->base.impl = &drawable_impl;
21- drawable->base.width = pixman_image_get_width(image);
22- drawable->base.height = pixman_image_get_height(image);
23- drawable->base.format = format_pixman_to_wld
24- (pixman_image_get_format(image));
25- drawable->base.pitch = pixman_image_get_stride(image);
26+ drawable_initialize(&drawable->base, &drawable_impl,
27+ pixman_image_get_width(image),
28+ pixman_image_get_height(image),
29+ format_pixman_to_wld(pixman_image_get_format(image)),
30+ pixman_image_get_stride(image));
31 drawable->context = context;
32 drawable->image = image;
33
+5,
-0
1@@ -180,5 +180,10 @@ void default_copy_region(struct wld_drawable * src, struct wld_drawable * dst,
2 void context_initialize(struct wld_context * context,
3 const struct wld_context_impl * impl);
4
5+void drawable_initialize(struct wld_drawable * drawable,
6+ const struct wld_drawable_impl * impl,
7+ uint32_t width, uint32_t height,
8+ uint32_t format, uint32_t pitch);
9+
10 #endif
11