[cairo] [PATCH 54/71] drm/i915: split image_caches array into struct for better readability

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Mon Apr 17 16:57:33 UTC 2017


Instead of using an array with unnamed index numbers, move to an
struct with named fields for the individual image cache instances.

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/drm/cairo-drm-i915-private.h | 5 ++++-
 src/drm/cairo-drm-i915-surface.c | 8 ++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h
index fee7e08fe..d3e8c7266 100644
--- a/src/drm/cairo-drm-i915-private.h
+++ b/src/drm/cairo-drm-i915-private.h
@@ -704,7 +704,10 @@ struct i915_device {
     uint32_t last_source_fragment;
     uint32_t clear_alpha;
 
-    cairo_list_t image_caches[2];
+    struct {
+	cairo_list_t argb32;
+	cairo_list_t a8;
+    } image_caches;
 
     uint32_t batch_header[13];
     uint32_t batch_base[I915_BATCH_SIZE / sizeof (uint32_t)];
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 57e1b3e46..c5b66e4fb 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -2663,13 +2663,13 @@ i915_surface_create_from_cacheable_image_internal (i915_device_t *device,
     case CAIRO_FORMAT_RGB24:
     case CAIRO_FORMAT_RGB16_565:
     case CAIRO_FORMAT_RGB30:
-	caches = &device->image_caches[0];
+	caches = &device->image_caches.argb32;
 	format = CAIRO_FORMAT_ARGB32;
 	bpp = 4;
 	break;
     case CAIRO_FORMAT_A8:
     case CAIRO_FORMAT_A1:
-	caches = &device->image_caches[1];
+	caches = &device->image_caches.a8;
 	format = CAIRO_FORMAT_A8;
 	bpp = 1;
 	break;
@@ -2908,8 +2908,8 @@ _cairo_drm_i915_device_create (int fd, dev_t dev_id, int vendor_id, int chip_id)
     device->vertex_count = 0;
     device->last_vbo = NULL;
 
-    for (n = 0; n < ARRAY_LENGTH (device->image_caches); n++)
-	cairo_list_init (&device->image_caches[n]);
+    cairo_list_init (&device->image_caches.argb32);
+    cairo_list_init (&device->image_caches.a8);
 
     device->intel.base.surface.create = i915_surface_create;
     device->intel.base.surface.create_for_name = i915_surface_create_for_name;
-- 
2.11.0.rc0.7.gbe5a750



More information about the cairo mailing list