[cairo] [PATCH 20/43] drm: add helper for typecasting from abstract device to drm device type
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Tue Dec 15 11:50:00 PST 2015
Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
src/drm/cairo-drm-private.h | 9 +++++++++
src/drm/cairo-drm.c | 12 ++++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/drm/cairo-drm-private.h b/src/drm/cairo-drm-private.h
index 5e8d639..e6d9196 100644
--- a/src/drm/cairo-drm-private.h
+++ b/src/drm/cairo-drm-private.h
@@ -128,6 +128,15 @@ struct _cairo_drm_device {
cairo_drm_device_t *next, *prev;
};
+static inline cairo_drm_device_t*
+cairo_abstract_device_cast_drm(cairo_device_t* dev)
+{
+ return cairo_container_of(
+ dev,
+ cairo_drm_device_t,
+ base);
+}
+
typedef struct _cairo_drm_surface {
cairo_surface_t base;
diff --git a/src/drm/cairo-drm.c b/src/drm/cairo-drm.c
index 661e181..47741a3 100644
--- a/src/drm/cairo-drm.c
+++ b/src/drm/cairo-drm.c
@@ -63,7 +63,7 @@ get_udev_property(struct udev_device *device, const char *name)
static void
_device_flush (void *abstract_device)
{
- cairo_drm_device_t *device = abstract_device;
+ cairo_drm_device_t *device = cairo_abstract_device_cast_drm(abstract_device);
device->device.flush (device);
}
@@ -71,7 +71,7 @@ _device_flush (void *abstract_device)
static void
_device_finish (void *abstract_device)
{
- cairo_drm_device_t *device = abstract_device;
+ cairo_drm_device_t *device = cairo_abstract_device_cast_drm(abstract_device);
CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
if (device->prev != NULL)
@@ -93,7 +93,7 @@ _device_finish (void *abstract_device)
static void
_device_destroy (void *abstract_device)
{
- cairo_drm_device_t *device = abstract_device;
+ cairo_drm_device_t *device = cairo_abstract_device_cast_drm(abstract_device);
device->device.destroy (device);
}
@@ -344,7 +344,7 @@ _cairo_drm_device_reset_static_data (void)
int
cairo_drm_device_get_fd (cairo_device_t *abstract_device)
{
- cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
+ cairo_drm_device_t *device = cairo_abstract_device_cast_drm(abstract_device);
if (device->base.status)
return -1;
@@ -362,7 +362,7 @@ _cairo_drm_device_fini (cairo_drm_device_t *device)
void
cairo_drm_device_throttle (cairo_device_t *abstract_device)
{
- cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
+ cairo_drm_device_t *device = cairo_abstract_device_cast_drm(abstract_device);
cairo_status_t status;
if (unlikely (device->base.status))
@@ -380,7 +380,7 @@ cairo_bool_t
_cairo_drm_size_is_valid (cairo_device_t *abstract_device,
int width, int height)
{
- cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
+ cairo_drm_device_t *device = cairo_abstract_device_cast_drm(abstract_device);
if (unlikely (device->base.status))
return FALSE;
--
2.6.4.442.g545299f
More information about the cairo
mailing list