--- src/qxl_surface.c | 134 ++++++++++++++++++++++++++--------------------------- 1 file changed, 67 insertions(+), 67 deletions(-)
diff --git a/src/qxl_surface.c b/src/qxl_surface.c index 137c1c7..96cfb5a 100644 --- a/src/qxl_surface.c +++ b/src/qxl_surface.c @@ -35,7 +35,7 @@ * A 'dead' surface is one that the X server is no using any more, but * is still allocated in the device. These surfaces may be stored in the * cache, from where they can be resurrected. The cache holds a ref on the - * surfaces. + * surfaces. * * A 'destroyed' surface is one whose ref count has reached 0. It is no * longer being referenced by either the server or the device or the cache. @@ -59,7 +59,7 @@ typedef struct evacuated_surface_t evacuated_surface_t; struct qxl_surface_t { surface_cache_t *cache; - + uint32_t id; pixman_image_t * dev_image; @@ -70,7 +70,7 @@ struct qxl_surface_t void * address; void * end; - + qxl_surface_t * next; qxl_surface_t * prev; /* Only used in the 'live' * chain in the surface cache @@ -81,7 +81,7 @@ struct qxl_surface_t int ref_count; PixmapPtr pixmap; - + union { qxl_surface_t *copy_src; @@ -106,7 +106,7 @@ struct evacuated_surface_t struct surface_cache_t { qxl_screen_t *qxl; - + /* Array of surfaces (not a linked list). * All surfaces, excluding the primary one, indexed by surface id. */ @@ -137,10 +137,10 @@ surface_cache_init (surface_cache_t *cache, qxl_screen_t *qxl) memset (cache->all_surfaces, 0, n_surfaces * sizeof (qxl_surface_t)); memset (cache->cached_surfaces, 0, N_CACHED_SURFACES * sizeof (qxl_surface_t *)); - + cache->free_surfaces = NULL; cache->live_surfaces = NULL; - + for (i = 0; i < n_surfaces; ++i) { cache->all_surfaces[i].id = i; @@ -253,7 +253,7 @@ get_formats (int bpp, SpiceBitmapFmt *format, pixman_format_code_t *pformat) break; } } - + static qxl_surface_t * surface_get_from_cache (surface_cache_t *cache, int width, int height, int bpp) { @@ -267,7 +267,7 @@ surface_get_from_cache (surface_cache_t *cache, int width, int height, int bpp) { int w = pixman_image_get_width (s->host_image); int h = pixman_image_get_height (s->host_image); - + if (width <= w && width * 4 > w && height <= h && height * 4 > h) { cache->cached_surfaces[i] = NULL; @@ -337,7 +337,7 @@ qxl_surface_cache_create_primary (surface_cache_t *cache, dev_image = pixman_image_create_bits (format, mode->x_res, mode->y_res, (uint32_t *)dev_addr, -mode->stride); - host_image = pixman_image_create_bits (format, + host_image = pixman_image_create_bits (format, qxl->virtual_x, qxl->virtual_y, qxl->fb, qxl->stride); @@ -349,10 +349,10 @@ qxl_surface_cache_create_primary (surface_cache_t *cache, surface->bpp = mode->bits; surface->next = NULL; surface->prev = NULL; - + REGION_INIT (NULL, &(surface->access_region), (BoxPtr)NULL, 0); surface->access_type = UXA_ACCESS_RO; - + return surface; } @@ -396,13 +396,13 @@ make_drawable (qxl_screen_t *qxl, int surface, uint8_t type, 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 */ drawable->effect = QXL_EFFECT_OPAQUE; drawable->self_bitmap = 0; @@ -412,7 +412,7 @@ make_drawable (qxl_screen_t *qxl, int surface, uint8_t type, drawable->self_bitmap_area.right = 0; /* FIXME: add clipping */ drawable->clip.type = SPICE_CLIP_TYPE_NONE; - + /* * surfaces_dest[i] should apparently be filled out with the * surfaces that we depend on, and surface_rects should be @@ -421,12 +421,12 @@ make_drawable (qxl_screen_t *qxl, int surface, uint8_t type, */ for (i = 0; i < 3; ++i) drawable->surfaces_dest[i] = -1; - + if (rect) drawable->bbox = *rect; - + drawable->mm_time = rom->mm_clock; - + return drawable; } @@ -434,11 +434,11 @@ static void push_drawable (qxl_screen_t *qxl, struct QXLDrawable *drawable) { struct QXLCommand cmd; - - /* When someone runs "init 3", the device will be + + /* When someone runs "init 3", the device will be * switched into VGA mode and there is nothing we * can do about it. We get no notification. - * + * * However, if commands are submitted when the device * is in VGA mode, they will be queued up, and then * the next time a mode set set, an assertion in the @@ -458,9 +458,9 @@ submit_fill (qxl_screen_t *qxl, int id, const struct QXLRect *rect, uint32_t color) { struct QXLDrawable *drawable; - + drawable = make_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; @@ -468,7 +468,7 @@ submit_fill (qxl_screen_t *qxl, int id, drawable->u.fill.mask.pos.x = 0; drawable->u.fill.mask.pos.y = 0; drawable->u.fill.mask.bitmap = 0; - + push_drawable (qxl, drawable); } @@ -498,7 +498,7 @@ surface_get_from_free_list (surface_cache_t *cache) assert (s->id != result->id); } } - + return result; } @@ -525,10 +525,10 @@ surface_send_create (surface_cache_t *cache, void *address; get_formats (bpp, &format, &pformat); - + width = align (width); height = align (height); - + stride = width * PIXMAN_FORMAT_BPP (pformat) / 8; stride = (stride + 3) & ~3; @@ -601,7 +601,7 @@ retry: surface->bpp = bpp; n_live++; - + return surface; } @@ -615,7 +615,7 @@ qxl_surface_create (surface_cache_t * cache, if (!cache->qxl->enable_surfaces) return NULL; - + if ((bpp & 3) != 0) { ErrorF (" Bad bpp: %d (%d)\n", bpp, bpp & 7); @@ -633,7 +633,7 @@ qxl_surface_create (surface_cache_t * cache, return NULL; } - + if (bpp != 8 && bpp != 16 && bpp != 32 && bpp != 24) { ErrorF (" Unknown bpp\n"); @@ -649,13 +649,13 @@ qxl_surface_create (surface_cache_t * cache, if (!(surface = surface_get_from_cache (cache, width, height, bpp))) if (!(surface = surface_send_create (cache, width, height, bpp))) return NULL; - + surface->next = cache->live_surfaces; surface->prev = NULL; if (cache->live_surfaces) cache->live_surfaces->prev = surface; cache->live_surfaces = surface; - + return surface; } @@ -674,12 +674,12 @@ unlink_surface (qxl_surface_t *surface) surface->prev->next = surface->next; else surface->cache->live_surfaces = surface->next; - + if (surface->next) surface->next->prev = surface->prev; surface->pixmap = NULL; - + surface->prev = NULL; surface->next = NULL; } @@ -693,9 +693,9 @@ send_destroy (qxl_surface_t *surface) pixman_image_unref (surface->dev_image); if (surface->host_image) pixman_image_unref (surface->host_image); - + init_surface_cmd (&cmd, surface->cache, surface->id, QXL_SURFACE_CMD_DESTROY); - + push_surface_cmd (surface->cache, &cmd); } @@ -710,7 +710,7 @@ surface_add_to_cache (qxl_surface_t *surface) qxl_surface_t *destroy_surface = NULL; surface->ref_count++; - + for (i = 0; i < N_CACHED_SURFACES; ++i) { if (cache->cached_surfaces[i]) @@ -719,7 +719,7 @@ surface_add_to_cache (qxl_surface_t *surface) n_surfaces++; } } - + if (n_surfaces == N_CACHED_SURFACES) { destroy_id = cache->cached_surfaces[oldest]->id; @@ -732,7 +732,7 @@ surface_add_to_cache (qxl_surface_t *surface) assert (!cache->cached_surfaces[i] || cache->cached_surfaces[i]->id != destroy_id); } - + delta = 0; for (i = N_CACHED_SURFACES - 1; i >= 0; i--) { @@ -753,11 +753,11 @@ surface_add_to_cache (qxl_surface_t *surface) delta++; } } - + assert (delta > 0); - + cache->cached_surfaces[i + delta] = surface; - + for (i = 0; i < N_CACHED_SURFACES; ++i) assert (!cache->cached_surfaces[i] || cache->cached_surfaces[i]->id != destroy_id); @@ -792,7 +792,7 @@ qxl_surface_kill (qxl_surface_t *surface) { surface_add_to_cache (surface); } - + qxl_surface_unref (surface->cache, surface->id); } @@ -844,9 +844,9 @@ qxl_surface_prepare_access (qxl_surface_t *surface, if (access == UXA_ACCESS_RW) surface->access_type = UXA_ACCESS_RW; - + region = &new; - + n_boxes = REGION_NUM_RECTS (region); boxes = REGION_RECTS (region); @@ -860,7 +860,7 @@ qxl_surface_prepare_access (qxl_surface_t *surface, while (n_boxes--) { download_box (surface, boxes->x1, boxes->y1, boxes->x2, boxes->y2); - + boxes++; } } @@ -870,14 +870,14 @@ qxl_surface_prepare_access (qxl_surface_t *surface, surface, new.extents.x1, new.extents.y1, new.extents.x2, new.extents.y2); } - + REGION_UNION (pScreen, &(surface->access_region), &(surface->access_region), region); - + REGION_UNINIT (NULL, &new); - + pScreen->ModifyPixmapHeader( pixmap, pixmap->drawable.width, @@ -886,7 +886,7 @@ qxl_surface_prepare_access (qxl_surface_t *surface, pixman_image_get_data (surface->host_image)); pixmap->devKind = pixman_image_get_stride (surface->host_image); - + return TRUE; } @@ -907,12 +907,12 @@ real_upload_box (qxl_surface_t *surface, int x1, int y1, int x2, int y2) qxl_screen_t *qxl = surface->cache->qxl; uint32_t *data; int stride; - + rect.left = x1; rect.right = x2; 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); @@ -925,13 +925,13 @@ real_upload_box (qxl_surface_t *surface, int x1, int y1, int x2, int y2) data = pixman_image_get_data (surface->host_image); stride = pixman_image_get_stride (surface->host_image); - + image = qxl_image_create ( - qxl, (const uint8_t *)data, x1, y1, x2 - x1, y2 - y1, stride, + 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 = physical_address (qxl, image, qxl->main_mem_slot); - + push_drawable (qxl, drawable); } @@ -995,7 +995,7 @@ qxl_surface_finish_access (qxl_surface_t *surface, PixmapPtr pixmap) REGION_EMPTY (pScreen, &surface->access_region); surface->access_type = UXA_ACCESS_RO; - + pScreen->ModifyPixmapHeader(pixmap, w, h, -1, -1, 0, NULL); } @@ -1048,7 +1048,7 @@ qxl_surface_cache_evacuate_all (surface_cache_t *cache) cache->all_surfaces = NULL; cache->live_surfaces = NULL; cache->free_surfaces = NULL; - + return evacuated_surfaces; } @@ -1062,7 +1062,7 @@ qxl_surface_cache_replace_all (surface_cache_t *cache, void *data) /* FIXME: report the error */ return; } - + ev = data; while (ev != NULL) { @@ -1100,14 +1100,14 @@ print_region (const char *header, RegionPtr pRegion) { int nbox = REGION_NUM_RECTS (pRegion); BoxPtr pbox = REGION_RECTS (pRegion); - + ErrorF ("%s", header); if (nbox == 0) ErrorF (" (empty)\n"); else ErrorF ("\n"); - + while (nbox--) { ErrorF (" %d %d %d %d (size: %d %d)\n", @@ -1132,7 +1132,7 @@ qxl_surface_prepare_solid (qxl_surface_t *destination, #ifdef DEBUG_REGIONS print_region ("prepare solid", &(destination->access_region)); #endif - + destination->u.solid_pixel = fg; // ^ (rand() >> 16); return TRUE; @@ -1155,7 +1155,7 @@ qxl_surface_solid (qxl_surface_t *destination, qrect.right = x2; p = destination->u.solid_pixel; - + submit_fill (qxl, destination->id, &qrect, p); } @@ -1194,7 +1194,7 @@ qxl_surface_copy (qxl_surface_t *dest, qrect.bottom = dest_y1 + height; qrect.left = dest_x1; qrect.right = dest_x1 + width; - + if (dest->id == dest->u.copy_src->id) { drawable = make_drawable (qxl, dest->id, QXL_COPY_BITS, &qrect); @@ -1256,7 +1256,7 @@ qxl_surface_put_image (qxl_surface_t *dest, qxl_screen_t *qxl = dest->cache->qxl; struct QXLRect rect; struct QXLImage *image; - + rect.left = x; rect.right = x + width; rect.top = y; @@ -1281,7 +1281,7 @@ qxl_surface_put_image (qxl_surface_t *dest, dest->bpp == 24 ? 4 : dest->bpp / 8, FALSE); drawable->u.copy.src_bitmap = physical_address (qxl, image, qxl->main_mem_slot); - + push_drawable (qxl, drawable); return TRUE; -- 1.7.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel