[cairo] [PATCH v8 63/71] drm/intel: fixed unitialized variable warning and improved error handling

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Thu Jun 30 15:46:41 UTC 2016


Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/drm/cairo-drm-i915-private.h   |  2 +-
 src/drm/cairo-drm-i915-surface.c   | 13 +++++++------
 src/drm/cairo-drm-i965-shader.c    |  4 ++--
 src/drm/cairo-drm-i965-surface.c   |  2 +-
 src/drm/cairo-drm-intel-surface.c  | 24 +-----------------------
 src/drm/cairo-drm-private.h        |  4 ++++
 src/drm/cairo-drm-radeon-surface.c | 27 +--------------------------
 src/drm/cairo-drm-surface.c        | 25 +++++++++++++++++++++++++
 8 files changed, 42 insertions(+), 59 deletions(-)

diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h
index d3e8c72..779c9c3 100644
--- a/src/drm/cairo-drm-i915-private.h
+++ b/src/drm/cairo-drm-i915-private.h
@@ -1302,7 +1302,7 @@ i915_surface_fallback_flush (i915_surface_t *surface)
     cairo_status_t status;
 
     if (unlikely (surface->intel.drm.fallback != NULL))
-	return intel_surface_flush (&surface->intel, 0);
+	return _cairo_drm_surface_flush (&surface->intel.drm, 0);
 
     status = CAIRO_STATUS_SUCCESS;
     if (unlikely (surface->deferred_clear))
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 5d343d4..bc61617 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -741,7 +741,7 @@ i915_surface_flush (void *abstract_surface,
 	return i915_surface_batch_flush (surface);
     }
 
-    return intel_surface_flush (abstract_surface, flags);
+    return _cairo_drm_surface_flush (abstract_surface, flags);
 }
 
 /* rasterisation */
@@ -2519,11 +2519,6 @@ i915_buffer_cache_init (intel_buffer_cache_t *cache,
     cache->buffer.height = height;
 
     switch (format) {
-    case CAIRO_FORMAT_INVALID:
-    case CAIRO_FORMAT_A1:
-    case CAIRO_FORMAT_RGB24:
-    case CAIRO_FORMAT_RGB16_565:
-	ASSERT_NOT_REACHED;
     case CAIRO_FORMAT_RGB30:
 	cache->buffer.map0 = MAPSURF_32BIT | MT_32BIT_ARGB2101010;
 	stride = width * 4;
@@ -2536,6 +2531,12 @@ i915_buffer_cache_init (intel_buffer_cache_t *cache,
 	cache->buffer.map0 = MAPSURF_8BIT | MT_8BIT_I8;
 	stride = width;
 	break;
+    case CAIRO_FORMAT_INVALID:
+    case CAIRO_FORMAT_A1:
+    case CAIRO_FORMAT_RGB24:
+    case CAIRO_FORMAT_RGB16_565:
+    default:
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     }
     assert ((stride & 7) == 0);
     assert (i915_tiling_stride (tiling, stride) == stride);
diff --git a/src/drm/cairo-drm-i965-shader.c b/src/drm/cairo-drm-i965-shader.c
index d5eca79..56ff429 100644
--- a/src/drm/cairo-drm-i965-shader.c
+++ b/src/drm/cairo-drm-i965-shader.c
@@ -415,7 +415,7 @@ i965_shader_acquire_surface (i965_shader_t *shader,
 		    int x;
 
 		    if (s->intel.drm.fallback != NULL) {
-			status = intel_surface_flush (s, 0);
+			status = _cairo_drm_surface_flush (&s->intel.drm, 0);
 			if (unlikely (status))
 			    return status;
 		    }
@@ -489,7 +489,7 @@ i965_shader_acquire_surface (i965_shader_t *shader,
 	    if (s->intel.drm.base.device == shader->target->intel.drm.base.device) {
 		if (s != shader->target) {
 		    if (s->intel.drm.fallback != NULL) {
-			status = intel_surface_flush (s, 0);
+			status = _cairo_surface_drm_surface_flush (&s->intel.drm, 0);
 			if (unlikely (status))
 			    return status;
 		    }
diff --git a/src/drm/cairo-drm-i965-surface.c b/src/drm/cairo-drm-i965-surface.c
index 5a84b37..e1ac38a 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -703,7 +703,7 @@ i965_surface_flush (void *abstract_surface, unsigned flags)
 	return CAIRO_STATUS_SUCCESS;
 
     if (surface->intel.drm.fallback != NULL)
-	return intel_surface_flush (&surface->intel, flags);
+	return _cairo_drm_surface_flush (&surface->intel.drm, flags);
 
     /* Forgo flushing on finish as the user cannot access the surface directly. */
     if (! surface->intel.drm.base.finished &&
diff --git a/src/drm/cairo-drm-intel-surface.c b/src/drm/cairo-drm-intel-surface.c
index d9958d6..43d9c34 100644
--- a/src/drm/cairo-drm-intel-surface.c
+++ b/src/drm/cairo-drm-intel-surface.c
@@ -61,28 +61,6 @@ intel_surface_finish (void *abstract_surface)
     return _cairo_drm_surface_finish (&surface->drm);
 }
 
-cairo_status_t
-intel_surface_flush (void *abstract_surface, unsigned flags)
-{
-    intel_surface_t *surface = cairo_abstract_surface_cast_intel(abstract_surface);
-    cairo_status_t status;
-
-    if (flags)
-	return CAIRO_STATUS_SUCCESS;
-
-    if (surface->drm.fallback == NULL)
-	return CAIRO_STATUS_SUCCESS;
-
-    /* kill any outstanding maps */
-    cairo_surface_finish (surface->drm.fallback);
-
-    status = cairo_surface_status (surface->drm.fallback);
-    cairo_surface_destroy (surface->drm.fallback);
-    surface->drm.fallback = NULL;
-
-    return status;
-}
-
 static const cairo_surface_backend_t intel_surface_backend = {
     .type			= CAIRO_SURFACE_TYPE_DRM,
     .create_context		= _cairo_default_context_create,
@@ -92,7 +70,7 @@ static const cairo_surface_backend_t intel_surface_backend = {
     .release_source_image	= _cairo_drm_surface_release_source_image,
     .get_extents		= _cairo_drm_surface_get_extents,
     .get_font_options		= _cairo_drm_surface_get_font_options,
-    .flush			= intel_surface_flush,
+    .flush			= _cairo_drm_surface_flush,
     .paint			= _cairo_drm_surface_paint,
     .mask			= _cairo_drm_surface_mask,
     .stroke			= _cairo_drm_surface_stroke,
diff --git a/src/drm/cairo-drm-private.h b/src/drm/cairo-drm-private.h
index 740b7f6..c49264f 100644
--- a/src/drm/cairo-drm-private.h
+++ b/src/drm/cairo-drm-private.h
@@ -292,6 +292,10 @@ _cairo_drm_surface_init (cairo_drm_surface_t *surface,
 			 int width, int height);
 
 cairo_private cairo_status_t
+_cairo_drm_surface_flush (void *abstact_interface,
+			  unsigned flags);
+
+cairo_private cairo_status_t
 _cairo_drm_surface_finish (void *surface);
 
 cairo_private void
diff --git a/src/drm/cairo-drm-radeon-surface.c b/src/drm/cairo-drm-radeon-surface.c
index 578f5e7..61fad9b 100644
--- a/src/drm/cairo-drm-radeon-surface.c
+++ b/src/drm/cairo-drm-radeon-surface.c
@@ -54,31 +54,6 @@ radeon_surface_create_similar (void			*abstract_surface,
 				       width, height);
 }
 
-static cairo_status_t
-radeon_surface_flush (void *abstract_surface,
-		      unsigned flags)
-{
-    radeon_surface_t *surface = _cairo_surface_cast_radeon(abstract_surface);
-    cairo_status_t status;
-
-    if (flags)
-	return CAIRO_STATUS_SUCCESS;
-
-    if (surface->base.fallback == NULL)
-	return CAIRO_STATUS_SUCCESS;
-
-    /* kill any outstanding maps */
-    cairo_surface_finish (surface->base.fallback);
-
-    status = cairo_surface_status (surface->base.fallback);
-    cairo_surface_destroy (surface->base.fallback);
-    surface->base.fallback = NULL;
-
-    _cairo_drm_bo_unmap (surface->base.bo);
-
-    return status;
-}
-
 static const cairo_surface_backend_t radeon_surface_backend = {
     .type			= CAIRO_SURFACE_TYPE_DRM,
     .create_context		= _cairo_default_context_create,
@@ -88,7 +63,7 @@ static const cairo_surface_backend_t radeon_surface_backend = {
     .release_source_image	= _cairo_drm_surface_release_source_image,
     .get_extents		= _cairo_drm_surface_get_extents,
     .get_font_options		= _cairo_drm_surface_get_font_options,
-    .flush			= radeon_surface_flush,
+    .flush			= _cairo_drm_surface_flush,
     .paint			= _cairo_drm_surface_paint,
     .mask			= _cairo_drm_surface_mask,
     .stroke			= _cairo_drm_surface_stroke,
diff --git a/src/drm/cairo-drm-surface.c b/src/drm/cairo-drm-surface.c
index 08515c3..9742e55 100644
--- a/src/drm/cairo-drm-surface.c
+++ b/src/drm/cairo-drm-surface.c
@@ -580,3 +580,28 @@ void _cairo_drm_surface_release_source_image (void *abstract_surface,
 {
     cairo_surface_destroy (&image->base);
 }
+
+cairo_status_t
+_cairo_drm_surface_flush (void *abstract_surface,
+			  unsigned flags)
+{
+    cairo_drm_surface_t *surface = _cairo_surface_cast_drm (abstract_surface);
+    cairo_status_t status;
+
+    if (flags)
+	return CAIRO_STATUS_SUCCESS;
+
+    if (surface->fallback == NULL)
+	return CAIRO_STATUS_SUCCESS;
+
+    /* kill any outstanding maps */
+    cairo_surface_finish (surface->fallback);
+
+    status = cairo_surface_status (surface->fallback);
+    cairo_surface_destroy (surface->fallback);
+    surface->fallback = NULL;
+
+    _cairo_drm_bo_unmap (surface->bo);
+
+    return status;
+}
-- 
2.6.4.442.g545299f



More information about the cairo mailing list