[PATCH 14/18] worker: move spice_bitmap_get_line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>

---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]