[Spice-devel] [spice-protocol PATCH 19/46] qxlhw: qxl_surface: use init_drawable

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


---
 src/qxl_surface.c |  128 +++++++++++++++++++++++++----------------------------
 1 file changed, 61 insertions(+), 67 deletions(-)

diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 73a44b3..7554ca6 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -388,19 +388,15 @@ enum ROPDescriptor
     ROPD_INVERS_RES = (1 <<10),
 };
 
-static struct QXLDrawable *
-make_drawable (qxl_screen_t *qxl, int surface, uint8_t type,
+static void
+init_drawable (struct QXLDrawable *drawable,
+               qxl_screen_t *qxl, int surface, uint8_t type,
 	       const struct QXLRect *rect
 	       /* , pRegion clip */)
 {
-    struct QXLDrawable *drawable;
     struct QXLRom *rom = qxlhw_pci_get_rom(qxl->hw);
     int i;
 
-    drawable = qxl_allocnf (qxl, sizeof *drawable);
-
-    drawable->release_info.id = pointer_to_u64 (drawable);
-
     drawable->type = type;
 
     drawable->surface_id = surface;		/* Only primary for now */
@@ -426,8 +422,6 @@ make_drawable (qxl_screen_t *qxl, int surface, uint8_t type,
 	drawable->bbox = *rect;
 
     drawable->mm_time = rom->mm_clock;
-
-    return drawable;
 }
 
 static void
@@ -453,19 +447,19 @@ static void
 submit_fill (qxl_screen_t *qxl, int id,
 	     const struct QXLRect *rect, uint32_t color)
 {
-    struct QXLDrawable *drawable;
+    struct QXLDrawable drawable;
 
-    drawable = make_drawable (qxl, id, QXL_DRAW_FILL, rect);
+    init_drawable (&drawable, qxl, id, QXL_DRAW_FILL, rect);
 
-    drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;
-    drawable->u.fill.brush.u.color = color;
-    drawable->u.fill.rop_descriptor = ROPD_OP_PUT;
-    drawable->u.fill.mask.flags = 0;
-    drawable->u.fill.mask.pos.x = 0;
-    drawable->u.fill.mask.pos.y = 0;
-    drawable->u.fill.mask.bitmap = 0;
+    drawable.u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;
+    drawable.u.fill.brush.u.color = color;
+    drawable.u.fill.rop_descriptor = ROPD_OP_PUT;
+    drawable.u.fill.mask.flags = 0;
+    drawable.u.fill.mask.pos.x = 0;
+    drawable.u.fill.mask.pos.y = 0;
+    drawable.u.fill.mask.bitmap = 0;
 
-    push_drawable (qxl, drawable, NULL);
+    push_drawable (qxl, &drawable, NULL);
 }
 
 static qxl_surface_t *
@@ -870,7 +864,7 @@ static void
 real_upload_box (qxl_surface_t *surface, int x1, int y1, int x2, int y2)
 {
     struct QXLRect rect;
-    struct QXLDrawable *drawable;
+    struct QXLDrawable drawable;
     struct QXLImage *image;
     qxl_screen_t *qxl = surface->cache->qxl;
     uint32_t *data;
@@ -881,15 +875,15 @@ real_upload_box (qxl_surface_t *surface, int x1, int y1, int x2, int y2)
     rect.top = y1;
     rect.bottom = y2;
 
-    drawable = make_drawable (qxl, surface->id, QXL_DRAW_COPY, &rect);
-    drawable->u.copy.src_area = rect;
-    translate_rect (&drawable->u.copy.src_area);
-    drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
-    drawable->u.copy.scale_mode = 0;
-    drawable->u.copy.mask.flags = 0;
-    drawable->u.copy.mask.pos.x = 0;
-    drawable->u.copy.mask.pos.y = 0;
-    drawable->u.copy.mask.bitmap = 0;
+    init_drawable (&drawable, qxl, surface->id, QXL_DRAW_COPY, &rect);
+    drawable.u.copy.src_area = rect;
+    translate_rect (&drawable.u.copy.src_area);
+    drawable.u.copy.rop_descriptor = ROPD_OP_PUT;
+    drawable.u.copy.scale_mode = 0;
+    drawable.u.copy.mask.flags = 0;
+    drawable.u.copy.mask.pos.x = 0;
+    drawable.u.copy.mask.pos.y = 0;
+    drawable.u.copy.mask.bitmap = 0;
 
     data = pixman_image_get_data (surface->host_image);
     stride = pixman_image_get_stride (surface->host_image);
@@ -897,10 +891,10 @@ real_upload_box (qxl_surface_t *surface, int x1, int y1, int x2, int y2)
     image = qxl_image_create (
 	qxl, (const uint8_t *)data, x1, y1, x2 - x1, y2 - y1, stride,
 	surface->bpp == 24 ? 4 : surface->bpp / 8, TRUE);
-    drawable->u.copy.src_bitmap =
+    drawable.u.copy.src_bitmap =
 	physical_address (qxl, image, qxl->main_mem_slot);
 
-    push_drawable (qxl, drawable, image);
+    push_drawable (qxl, &drawable, image);
 }
 
 #define TILE_WIDTH 512
@@ -1150,7 +1144,7 @@ qxl_surface_copy (qxl_surface_t *dest,
 		  int width, int height)
 {
     qxl_screen_t *qxl = dest->cache->qxl;
-    struct QXLDrawable *drawable;
+    struct QXLDrawable drawable;
     struct QXLRect qrect;
     struct QXLImage *image = NULL;
 
@@ -1166,10 +1160,10 @@ qxl_surface_copy (qxl_surface_t *dest,
 
     if (dest->id == dest->u.copy_src->id)
     {
-	drawable = make_drawable (qxl, dest->id, QXL_COPY_BITS, &qrect);
+	init_drawable (&drawable, qxl, dest->id, QXL_COPY_BITS, &qrect);
 
-	drawable->u.copy_bits.src_pos.x = src_x1;
-	drawable->u.copy_bits.src_pos.y = src_y1;
+	drawable.u.copy_bits.src_pos.x = src_x1;
+	drawable.u.copy_bits.src_pos.y = src_y1;
     }
     else
     {
@@ -1183,22 +1177,22 @@ qxl_surface_copy (qxl_surface_t *dest,
 	image->descriptor.height = 0;
 	image->surface_image.surface_id = dest->u.copy_src->id;
 
-	drawable = make_drawable (qxl, dest->id, QXL_DRAW_COPY, &qrect);
-
-	drawable->u.copy.src_bitmap = physical_address (qxl, image, qxl->main_mem_slot);
-	drawable->u.copy.src_area.left = src_x1;
-	drawable->u.copy.src_area.top = src_y1;
-	drawable->u.copy.src_area.right = src_x1 + width;
-	drawable->u.copy.src_area.bottom = src_y1 + height;
-	drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
-	drawable->u.copy.scale_mode = 0;
-	drawable->u.copy.mask.flags = 0;
-	drawable->u.copy.mask.pos.x = 0;
-	drawable->u.copy.mask.pos.y = 0;
-	drawable->u.copy.mask.bitmap = 0;
-
-	drawable->surfaces_dest[0] = dest->u.copy_src->id;
-	drawable->surfaces_rects[0] = drawable->u.copy.src_area;
+	init_drawable (&drawable, qxl, dest->id, QXL_DRAW_COPY, &qrect);
+
+	drawable.u.copy.src_bitmap = physical_address (qxl, image, qxl->main_mem_slot);
+	drawable.u.copy.src_area.left = src_x1;
+	drawable.u.copy.src_area.top = src_y1;
+	drawable.u.copy.src_area.right = src_x1 + width;
+	drawable.u.copy.src_area.bottom = src_y1 + height;
+	drawable.u.copy.rop_descriptor = ROPD_OP_PUT;
+	drawable.u.copy.scale_mode = 0;
+	drawable.u.copy.mask.flags = 0;
+	drawable.u.copy.mask.pos.x = 0;
+	drawable.u.copy.mask.pos.y = 0;
+	drawable.u.copy.mask.bitmap = 0;
+
+	drawable.surfaces_dest[0] = dest->u.copy_src->id;
+	drawable.surfaces_rects[0] = drawable.u.copy.src_area;
  	
 	assert (src_x1 >= 0);
 	assert (src_y1 >= 0);
@@ -1213,7 +1207,7 @@ qxl_surface_copy (qxl_surface_t *dest,
 	assert (height <= pixman_image_get_height (dest->u.copy_src->host_image));
     }
 
-    push_drawable (qxl, drawable, image);
+    push_drawable (qxl, &drawable, image);
 }
 
 Bool
@@ -1221,7 +1215,7 @@ qxl_surface_put_image (qxl_surface_t *dest,
 		       int x, int y, int width, int height,
 		       const char *src, int src_pitch)
 {
-    struct QXLDrawable *drawable;
+    struct QXLDrawable drawable;
     qxl_screen_t *qxl = dest->cache->qxl;
     struct QXLRect rect;
     struct QXLImage *image;
@@ -1231,27 +1225,27 @@ qxl_surface_put_image (qxl_surface_t *dest,
     rect.top = y;
     rect.bottom = y + height;
 
-    drawable = make_drawable (qxl, dest->id, QXL_DRAW_COPY, &rect);
+    init_drawable (&drawable, qxl, dest->id, QXL_DRAW_COPY, &rect);
 
-    drawable->u.copy.src_area.top = 0;
-    drawable->u.copy.src_area.bottom = height;
-    drawable->u.copy.src_area.left = 0;
-    drawable->u.copy.src_area.right = width;
+    drawable.u.copy.src_area.top = 0;
+    drawable.u.copy.src_area.bottom = height;
+    drawable.u.copy.src_area.left = 0;
+    drawable.u.copy.src_area.right = width;
 
-    drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
-    drawable->u.copy.scale_mode = 0;
-    drawable->u.copy.mask.flags = 0;
-    drawable->u.copy.mask.pos.x = 0;
-    drawable->u.copy.mask.pos.y = 0;
-    drawable->u.copy.mask.bitmap = 0;
+    drawable.u.copy.rop_descriptor = ROPD_OP_PUT;
+    drawable.u.copy.scale_mode = 0;
+    drawable.u.copy.mask.flags = 0;
+    drawable.u.copy.mask.pos.x = 0;
+    drawable.u.copy.mask.pos.y = 0;
+    drawable.u.copy.mask.bitmap = 0;
 
     image = qxl_image_create (
 	qxl, (const uint8_t *)src, 0, 0, width, height, src_pitch,
 	dest->bpp == 24 ? 4 : dest->bpp / 8, FALSE);
-    drawable->u.copy.src_bitmap =
-	physical_address (qxl, image, qxl->main_mem_slot);
+    drawable.u.copy.src_bitmap =
+       physical_address (qxl, image, qxl->main_mem_slot);
 
-    push_drawable (qxl, drawable, image);
+    push_drawable (qxl, &drawable, image);
 
     return TRUE;
 }
-- 
1.7.9.3



More information about the Spice-devel mailing list