[cairo] [PATCH 05/36] drm: add helper for typecasting from abstract surface to drm surface type
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Sat Dec 12 10:51:33 PST 2015
Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
src/drm/cairo-drm-i915-glyphs.c | 2 +-
src/drm/cairo-drm-i915-private.h | 8 ++++++++
src/drm/cairo-drm-i915-shader.c | 2 +-
src/drm/cairo-drm-i915-surface.c | 6 +++---
src/drm/cairo-drm-i965-private.h | 8 ++++++++
src/drm/cairo-drm-i965-surface.c | 2 +-
src/drm/cairo-drm-intel-private.h | 9 +++++++++
src/drm/cairo-drm-intel-surface.c | 10 +++++-----
src/drm/cairo-drm-private.h | 6 ++++++
src/drm/cairo-drm-surface.c | 4 ++--
10 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/src/drm/cairo-drm-i915-glyphs.c b/src/drm/cairo-drm-i915-glyphs.c
index 9944f15..1e88605 100644
--- a/src/drm/cairo-drm-i915-glyphs.c
+++ b/src/drm/cairo-drm-i915-glyphs.c
@@ -282,7 +282,7 @@ i915_surface_glyphs (void *abstract_surface,
cairo_clip_t *clip,
int *num_remaining)
{
- i915_surface_t *surface = abstract_surface;
+ i915_surface_t *surface = cairo_abstract_surface_cast_i915(abstract_surface);
i915_surface_t *mask = NULL;
i915_device_t *device;
i915_shader_t shader;
diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h
index c750cf4..094caa5 100644
--- a/src/drm/cairo-drm-i915-private.h
+++ b/src/drm/cairo-drm-i915-private.h
@@ -764,6 +764,14 @@ struct i915_surface {
uint32_t stencil_offset;
};
+static inline i915_surface_t* cairo_abstract_surface_cast_i915(cairo_surface_t* surface)
+{
+ return cairo_container_of(
+ cairo_abstract_surface_cast_intel(surface),
+ i915_surface_t,
+ intel);
+}
+
typedef enum {
NONE = 0,
YUV_I420,
diff --git a/src/drm/cairo-drm-i915-shader.c b/src/drm/cairo-drm-i915-shader.c
index 85aa984..e423520 100644
--- a/src/drm/cairo-drm-i915-shader.c
+++ b/src/drm/cairo-drm-i915-shader.c
@@ -43,7 +43,7 @@
static cairo_status_t
i915_packed_pixel_surface_finish (void *abstract_surface)
{
- i915_packed_pixel_surface_t *surface = abstract_surface;
+ i915_packed_pixel_surface_t *surface = cairo_abstract_surface_cast_i915(abstract_surface);
i915_device_t *device;
device = i915_device_acquire (&surface->device->intel.base);
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index c1a0452..6990184 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -652,7 +652,7 @@ i915_surface_create_similar (void *abstract_other,
static cairo_status_t
i915_surface_finish (void *abstract_surface)
{
- i915_surface_t *surface = abstract_surface;
+ i915_surface_t *surface = cairo_abstract_surface_cast_i915(abstract_surface);
i915_device_t *device = i915_device (surface);
if (surface->stencil != NULL) {
@@ -719,7 +719,7 @@ static cairo_status_t
i915_surface_flush (void *abstract_surface,
unsigned flags)
{
- i915_surface_t *surface = abstract_surface;
+ i915_surface_t *surface = cairo_abstract_surface_cast_i915(abstract_surface);
cairo_status_t status;
if (flags)
@@ -2795,7 +2795,7 @@ i915_surface_create_from_cacheable_image (cairo_drm_device_t *device,
static cairo_status_t
i915_surface_enable_scan_out (void *abstract_surface)
{
- i915_surface_t *surface = abstract_surface;
+ i915_surface_t *surface = cairo_abstract_surface_cast_i915(abstract_surface);
intel_bo_t *bo;
cairo_status_t status;
diff --git a/src/drm/cairo-drm-i965-private.h b/src/drm/cairo-drm-i965-private.h
index 79568a6..ffd2ca9 100644
--- a/src/drm/cairo-drm-i965-private.h
+++ b/src/drm/cairo-drm-i965-private.h
@@ -315,6 +315,14 @@ struct i965_surface {
uint32_t offset;
};
+static inline i965_surface_t* cairo_abstract_surface_cast_i965(cairo_surface_t *surface)
+{
+ return cairo_container_of(
+ cairo_abstract_surface_cast_intel(surface),
+ i965_surface_t,
+ intel);
+}
+
struct i965_pending_relocation {
uint32_t offset;
uint32_t read_domains;
diff --git a/src/drm/cairo-drm-i965-surface.c b/src/drm/cairo-drm-i965-surface.c
index ec7b595..ffb5b38 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -1095,7 +1095,7 @@ i965_surface_paint (void *abstract_dst,
const cairo_pattern_t *source,
cairo_clip_t *clip)
{
- i965_surface_t *dst = abstract_dst;
+ i965_surface_t *dst = cairo_abstract_surface_cast_i965(abstract_dst);
cairo_composite_rectangles_t extents;
cairo_boxes_t boxes;
cairo_box_t *clip_boxes = boxes.boxes_embedded;
diff --git a/src/drm/cairo-drm-intel-private.h b/src/drm/cairo-drm-intel-private.h
index 343270a..5e95bc9 100644
--- a/src/drm/cairo-drm-intel-private.h
+++ b/src/drm/cairo-drm-intel-private.h
@@ -182,6 +182,15 @@ typedef struct _intel_surface {
cairo_cache_entry_t snapshot_cache_entry;
} intel_surface_t;
+static inline intel_surface_t*
+cairo_abstract_surface_cast_intel(cairo_surface_t* surface)
+{
+ return cairo_container_of(
+ cairo_abstract_surface_cast_drm(surface),
+ intel_surface_t,
+ drm);
+}
+
typedef void (*intel_reset_context_func_t) (void *device);
typedef struct _intel_device {
diff --git a/src/drm/cairo-drm-intel-surface.c b/src/drm/cairo-drm-intel-surface.c
index 88f5b8f..b642e88 100644
--- a/src/drm/cairo-drm-intel-surface.c
+++ b/src/drm/cairo-drm-intel-surface.c
@@ -52,7 +52,7 @@ intel_surface_create_similar (void *abstract_surface,
cairo_status_t
intel_surface_finish (void *abstract_surface)
{
- intel_surface_t *surface = abstract_surface;
+ intel_surface_t *surface = cairo_abstract_surface_cast_intel(abstract_surface);
intel_bo_in_flight_add (to_intel_device (surface->drm.base.device),
to_intel_bo (surface->drm.bo));
@@ -71,7 +71,7 @@ intel_surface_acquire_source_image (void *abstract_surface,
cairo_image_surface_t **image_out,
void **image_extra)
{
- intel_surface_t *surface = abstract_surface;
+ intel_surface_t *surface = cairo_abstract_surface_cast_intel(abstract_surface);
cairo_surface_t *image;
cairo_status_t status;
void *ptr;
@@ -124,7 +124,7 @@ intel_surface_release_source_image (void *abstract_surface,
cairo_surface_t *
intel_surface_map_to_image (void *abstract_surface)
{
- intel_surface_t *surface = abstract_surface;
+ intel_surface_t *surface = cairo_abstract_surface_cast_intel(abstract_surface);
if (surface->drm.fallback == NULL) {
cairo_surface_t *image;
@@ -159,7 +159,7 @@ intel_surface_map_to_image (void *abstract_surface)
cairo_status_t
intel_surface_flush (void *abstract_surface, unsigned flags)
{
- intel_surface_t *surface = abstract_surface;
+ intel_surface_t *surface = cairo_abstract_surface_cast_intel(abstract_surface);
cairo_status_t status;
if (flags)
@@ -386,7 +386,7 @@ intel_surface_create_for_name (cairo_drm_device_t *device,
static cairo_status_t
intel_surface_enable_scan_out (void *abstract_surface)
{
- intel_surface_t *surface = abstract_surface;
+ intel_surface_t *surface = cairo_abstract_surface_cast_intel(abstract_surface);
if (unlikely (surface->drm.bo == NULL))
return _cairo_error (CAIRO_STATUS_INVALID_SIZE);
diff --git a/src/drm/cairo-drm-private.h b/src/drm/cairo-drm-private.h
index 2db7f38..5e8d639 100644
--- a/src/drm/cairo-drm-private.h
+++ b/src/drm/cairo-drm-private.h
@@ -140,6 +140,12 @@ typedef struct _cairo_drm_surface {
uint32_t map_count;
} cairo_drm_surface_t;
+static inline cairo_drm_surface_t*
+cairo_abstract_surface_cast_drm(cairo_surface_t* surface)
+{
+ return cairo_container_of(surface, cairo_drm_surface_t, base);
+}
+
static inline cairo_drm_bo_t *
cairo_drm_bo_reference (cairo_drm_bo_t *bo)
{
diff --git a/src/drm/cairo-drm-surface.c b/src/drm/cairo-drm-surface.c
index 8c4dd0e..d2f993f 100644
--- a/src/drm/cairo-drm-surface.c
+++ b/src/drm/cairo-drm-surface.c
@@ -76,7 +76,7 @@ cairo_bool_t
_cairo_drm_surface_get_extents (void *abstract_surface,
cairo_rectangle_int_t *rectangle)
{
- cairo_drm_surface_t *surface = abstract_surface;
+ cairo_drm_surface_t *surface = cairo_abstract_surface_cast_drm(abstract_surface);
rectangle->x = 0;
rectangle->y = 0;
@@ -233,7 +233,7 @@ cairo_drm_surface_get_handle (cairo_surface_t *abstract_surface)
cairo_int_status_t
_cairo_drm_surface_flink (void *abstract_surface)
{
- cairo_drm_surface_t *surface = abstract_surface;
+ cairo_drm_surface_t *surface = cairo_abstract_surface_cast_drm(abstract_surface);
return _cairo_drm_bo_flink ((cairo_drm_device_t *) surface->base.device,
surface->bo);
--
2.6.4.442.g545299f
More information about the cairo
mailing list