[Spice-devel] [PATCH 14/18] worker: move spice_bitmap_get_line

Frediano Ziglio fziglio at redhat.com
Fri Nov 20 03:17:38 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
 server/spice_bitmap_utils.c | 27 +++++++++++++++++++++++++++
 server/spice_bitmap_utils.h |  3 +++
 2 files changed, 30 insertions(+)

diff --git a/server/spice_bitmap_utils.c b/server/spice_bitmap_utils.c
index ae3fc8b..3b992a7 100644
--- a/server/spice_bitmap_utils.c
+++ b/server/spice_bitmap_utils.c
@@ -186,3 +186,30 @@ void dump_bitmap(SpiceBitmap *bitmap)
     }
     fclose(f);
 }
+
+uint8_t *spice_bitmap_get_line(const SpiceBitmap *image, size_t *offset,
+                               int *chunk_nr, int stride)
+{
+    SpiceChunks *chunks = image->data;
+    uint8_t *ret;
+    SpiceChunk *chunk;
+
+    chunk = &chunks->chunk[*chunk_nr];
+
+    if (*offset == chunk->len) {
+        if (*chunk_nr == chunks->num_chunks - 1) {
+            return NULL; /* Last chunk */
+        }
+        *offset = 0;
+        (*chunk_nr)++;
+        chunk = &chunks->chunk[*chunk_nr];
+    }
+
+    if (chunk->len - *offset < stride) {
+        spice_warning("bad chunk alignment");
+        return NULL;
+    }
+    ret = chunk->data + *offset;
+    *offset += stride;
+    return ret;
+}
diff --git a/server/spice_bitmap_utils.h b/server/spice_bitmap_utils.h
index 69860e5..9d3a5ae 100644
--- a/server/spice_bitmap_utils.h
+++ b/server/spice_bitmap_utils.h
@@ -5,4 +5,7 @@ void dump_bitmap(SpiceBitmap *bitmap);
 
 int spice_bitmap_from_surface_type(uint32_t surface_format);
 
+uint8_t *spice_bitmap_get_line(const SpiceBitmap *image, size_t *offset,
+                               int *chunk_nr, int stride);
+
 #endif
-- 
2.4.3



More information about the Spice-devel mailing list