[Spice-devel] [spice-protocol PATCH 24/46] qxlhw: add qxlhw_pci_image_free

Alon Levy alevy at redhat.com
Tue Apr 10 04:50:20 PDT 2012


---
 src/qxl_image.c |   16 +---------------
 src/qxlhw.c     |    6 ++++++
 src/qxlhw.h     |    2 ++
 src/qxlhw_pci.c |   21 +++++++++++++++++++++
 4 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/src/qxl_image.c b/src/qxl_image.c
index 1f057f7..adf4076 100644
--- a/src/qxl_image.c
+++ b/src/qxl_image.c
@@ -168,7 +168,6 @@ qxl_image_destroy (qxl_screen_t *qxl,
 		   struct QXLImage *image)
 {
     image_info_t *info;
-    uint64_t chunk;
 
     info = lookup_image_info (image->descriptor.id,
 			      image->descriptor.width,
@@ -188,20 +187,7 @@ qxl_image_destroy (qxl_screen_t *qxl,
 	remove_image_info (info);
     }
 
-
-    chunk = image->bitmap.data;
-    while (chunk)
-    {
-       struct QXLDataChunk *virtual;
-
-       virtual = virtual_address (qxl, u64_to_pointer (chunk), qxl->main_mem_slot);
-
-       chunk = virtual->next_chunk;
-
-       qxlhw_data_free (qxl->hw, virtual);
-    }
-
-    qxlhw_data_free (qxl->hw, image);
+    qxlhw_image_free(qxl->hw, image);
 }
 
 void
diff --git a/src/qxlhw.c b/src/qxlhw.c
index b099a25..5bcb175 100644
--- a/src/qxlhw.c
+++ b/src/qxlhw.c
@@ -108,3 +108,9 @@ qxlhw_image_alloc(struct qxlhw *base, const uint8_t *data,
 {
     return base->image_alloc(base, data, x, y, width, height, stride, Bpp, hash);
 }
+
+void
+qxlhw_image_free(struct qxlhw *base, struct QXLImage *image)
+{
+    base->image_free(base, image);
+}
diff --git a/src/qxlhw.h b/src/qxlhw.h
index f012aa2..eb51f26 100644
--- a/src/qxlhw.h
+++ b/src/qxlhw.h
@@ -29,6 +29,7 @@ struct qxlhw {
     struct QXLImage * (*image_alloc)(struct qxlhw *base, const uint8_t *data,
                                      int x, int y, int width, int height,
                                      int stride, int Bpp, uint32_t *hash);
+    void (*image_free)(struct qxlhw *base, struct QXLImage *image);
     void (*push_drawable)(struct qxlhw *base, struct QXLDrawable *base_cmd, struct QXLImage *image);
     /* tried to avoid this. but qxl_surface.c wants to check when failing to
      * find a surface in the free list, which it populates using
@@ -82,6 +83,7 @@ void qxlhw_push_surface_cmd(struct qxlhw *base, QXLSurfaceCmd *base_cmd);
 struct QXLImage *qxlhw_image_alloc(struct qxlhw *base, const uint8_t *data,
                                    int x, int y, int width, int height,
                                    int stride, int Bpp, uint32_t *hash);
+void qxlhw_image_free(struct qxlhw *base, struct QXLImage *image);
 
 void qxlhw_push_drawable(struct qxlhw *base, QXLDrawable *base_cmd, QXLImage *image);
 
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
index 6950093..ed2f554 100644
--- a/src/qxlhw_pci.c
+++ b/src/qxlhw_pci.c
@@ -858,6 +858,26 @@ qxlhw_pci_image_alloc(struct qxlhw *base, const uint8_t *data,
     return image;
 }
 
+static void
+qxlhw_pci_image_free(struct qxlhw *base, struct QXLImage *image)
+{
+    struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+    uint64_t chunk;
+
+    chunk = image->bitmap.data;
+    while (chunk)
+    {
+       struct QXLDataChunk *virtual;
+
+       virtual = qxlhw_virtual_address (hw, u64_to_pointer (chunk), hw->main_mem_slot);
+
+       chunk = virtual->next_chunk;
+
+       qxlhw_data_free (base, virtual);
+    }
+
+    qxlhw_data_free (base, image);
+}
 
 /* public entry point */
 struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
@@ -881,6 +901,7 @@ struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
     base->update_area = qxlhw_pci_update_area;
     base->push_cursor = qxlhw_pci_push_cursor;
     base->image_alloc = qxlhw_pci_image_alloc;
+    base->image_free = qxlhw_pci_image_free;
     base->push_drawable = qxlhw_pci_push_drawable;
     return base;
 }
-- 
1.7.9.3



More information about the Spice-devel mailing list