commit 130ed43
Michael Forney
·
2013-07-19 06:26:06 +0000 UTC
parent 9e78642
Use drm_drawable base for drm drawable info
4 files changed,
+34,
-50
+10,
-3
1@@ -24,14 +24,14 @@
2 #ifndef WLD_DRM_PRIVATE_H
3 #define WLD_DRM_PRIVATE_H 1
4
5+#include "wld-private.h"
6+
7 typedef bool (* drm_device_supported_func_t)(uint32_t vendor_id,
8 uint32_t device_id);
9 typedef void * (* drm_create_context_func_t)(int drm_fd);
10 typedef void (* drm_destroy_context_func_t)(void * context);
11 typedef struct wld_drawable * (* drm_create_drawable_func_t)
12 (void * context, uint32_t width, uint32_t height, uint32_t format);
13-typedef void (* drm_get_drawable_info_func_t)
14- (struct wld_drawable * drawable, uint32_t * name, uint32_t * pitch);
15
16 struct wld_drm_interface
17 {
18@@ -39,7 +39,14 @@ struct wld_drm_interface
19 drm_create_context_func_t create_context;
20 drm_destroy_context_func_t destroy_context;
21 drm_create_drawable_func_t create_drawable;
22- drm_get_drawable_info_func_t get_drawable_info;
23+};
24+
25+struct drm_drawable
26+{
27+ struct wld_drawable base;
28+
29+ unsigned long pitch;
30+ uint32_t name;
31 };
32
33 #if ENABLE_INTEL
M
intel.c
+13,
-27
1@@ -39,12 +39,9 @@ struct wld_intel_context
2
3 struct intel_drawable
4 {
5- struct wld_drawable base;
6+ struct drm_drawable drm;
7
8 struct wld_intel_context * context;
9- uint32_t name;
10- unsigned long pitch;
11-
12 drm_intel_bo * bo;
13 };
14
15@@ -70,7 +67,6 @@ const struct wld_drm_interface intel_drm = {
16 .create_context = (drm_create_context_func_t) &wld_intel_create_context,
17 .destroy_context = (drm_destroy_context_func_t) &wld_intel_destroy_context,
18 .create_drawable = (drm_create_drawable_func_t) &wld_intel_create_drawable,
19- .get_drawable_info = &wld_intel_get_drawable_info
20 };
21
22 bool wld_intel_device_supported(uint32_t vendor_id, uint32_t device_id)
23@@ -111,28 +107,18 @@ struct wld_drawable * wld_intel_create_drawable
24 if (!intel)
25 return NULL;
26
27- intel->base.interface = &intel_draw;
28- intel->base.width = width;
29- intel->base.height = height;
30+ intel->drm.base.interface = &intel_draw;
31+ intel->drm.base.width = width;
32+ intel->drm.base.height = height;
33
34 intel->context = context;
35 intel->bo = drm_intel_bo_alloc_tiled(context->bufmgr, "drawable",
36 width, height, 4,
37- &tiling_mode, &intel->pitch, 0);
38-
39- drm_intel_bo_flink(intel->bo, &intel->name);
40-
41- return &intel->base;
42-}
43+ &tiling_mode, &intel->drm.pitch, 0);
44
45-void wld_intel_get_drawable_info(struct wld_drawable * drawable,
46- uint32_t * name, uint32_t * pitch)
47-{
48- struct intel_drawable * intel;
49+ drm_intel_bo_flink(intel->bo, &intel->drm.name);
50
51- intel = container_of(drawable, typeof(*intel), base);
52- *name = intel->name;
53- *pitch = intel->pitch;
54+ return &intel->drm.base;
55 }
56
57 void intel_fill_rectangle(struct wld_drawable * drawable, uint32_t color,
58@@ -140,8 +126,8 @@ void intel_fill_rectangle(struct wld_drawable * drawable, uint32_t color,
59 {
60 struct intel_drawable * intel;
61
62- intel = container_of(drawable, typeof(*intel), base);
63- xy_color_blt(&intel->context->batch, intel->bo, intel->pitch,
64+ intel = container_of(drawable, typeof(*intel), drm.base);
65+ xy_color_blt(&intel->context->batch, intel->bo, intel->drm.pitch,
66 rectangle->x, rectangle->y,
67 rectangle->x + rectangle->width,
68 rectangle->y + rectangle->height, color);
69@@ -162,14 +148,14 @@ void intel_draw_text_utf8(struct wld_drawable * drawable,
70 uint8_t * byte;
71 uint8_t byte_index;
72
73- intel = container_of(drawable, typeof(*intel), base);
74+ intel = container_of(drawable, typeof(*intel), drm.base);
75
76 /* For some reason the text doesn't render if we don't flush the command
77 * buffer first. */
78 intel_batch_flush(&intel->context->batch);
79
80 xy_setup_blt(&intel->context->batch, true, INTEL_BLT_RASTER_OPERATION_SRC,
81- 0, color, intel->bo, intel->pitch);
82+ 0, color, intel->bo, intel->drm.pitch);
83
84 while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
85 {
86@@ -211,7 +197,7 @@ void intel_flush(struct wld_drawable * drawable)
87 {
88 struct intel_drawable * intel;
89
90- intel = container_of(drawable, typeof(*intel), base);
91+ intel = container_of(drawable, typeof(*intel), drm.base);
92 intel_batch_flush(&intel->context->batch);
93 }
94
95@@ -219,7 +205,7 @@ void intel_destroy(struct wld_drawable * drawable)
96 {
97 struct intel_drawable * intel;
98
99- intel = container_of(drawable, typeof(*intel), base);
100+ intel = container_of(drawable, typeof(*intel), drm.base);
101 drm_intel_bo_unreference(intel->bo);
102 free(intel);
103 }
M
intel.h
+0,
-6
1@@ -55,11 +55,5 @@ struct wld_drawable * wld_intel_create_drawable
2 (struct wld_intel_context * context, uint32_t width, uint32_t height,
3 enum wld_format format);
4
5-/**
6- * Get the name and pitch of the underlying BO for this Intel drawable.
7- */
8-void wld_intel_get_drawable_info(struct wld_drawable * drawable,
9- uint32_t * name, uint32_t * pitch);
10-
11 #endif
12
+11,
-14
1@@ -232,29 +232,26 @@ struct wld_drawable * wld_drm_create_drawable(struct wld_drm_context * drm,
2 uint32_t width, uint32_t height,
3 uint32_t format)
4 {
5- struct wld_drawable * drawable0, * drawable1;
6+ struct drm_drawable * drawable0, * drawable1;
7 uint32_t name0, name1, pitch0, pitch1;
8 struct wl_buffer * buffer0, * buffer1;
9
10 if (!wld_drm_has_format(drm, format))
11 return NULL;
12
13- drawable0 = drm->interface->create_drawable(drm->context, width, height,
14- format);
15- drawable1 = drm->interface->create_drawable(drm->context, width, height,
16- format);
17+ drawable0 = (void *) drm->interface->create_drawable(drm->context,
18+ width, height, format);
19+ drawable1 = (void *) drm->interface->create_drawable(drm->context,
20+ width, height, format);
21
22- drm->interface->get_drawable_info(drawable0, &name0, &pitch0);
23- drm->interface->get_drawable_info(drawable1, &name1, &pitch1);
24-
25- buffer0 = wl_drm_create_buffer(drm->wl, name0, width, height,
26- pitch0, format);
27- buffer1 = wl_drm_create_buffer(drm->wl, name1, width, height,
28- pitch1, format);
29+ buffer0 = wl_drm_create_buffer(drm->wl, drawable0->name, width, height,
30+ drawable0->pitch, format);
31+ buffer1 = wl_drm_create_buffer(drm->wl, drawable1->name, width, height,
32+ drawable1->pitch, format);
33
34 return wld_wayland_create_drawable_from_buffers(surface,
35- buffer0, drawable0,
36- buffer1, drawable1);
37+ buffer0, &drawable0->base,
38+ buffer1, &drawable1->base);
39 }
40
41 void registry_global(void * data, struct wl_registry * registry, uint32_t name,