diff options
author | Larsson@.(none) <Larsson@.(none)> | 2010-02-26 08:58:07 +0100 |
---|---|---|
committer | unknown <Alexander Larsson@.(none)> | 2010-03-01 15:12:35 +0100 |
commit | c28169976a9050a9a05cbb3dd4543edd34d3c82e (patch) | |
tree | 5295409e75f9cca7e483eda81cf2603e37be869c | |
parent | 98f7d96336d2e05f770918f8977f5909f2fac44a (diff) | |
download | spice-c28169976a9050a9a05cbb3dd4543edd34d3c82e.tar.gz spice-c28169976a9050a9a05cbb3dd4543edd34d3c82e.tar.xz spice-c28169976a9050a9a05cbb3dd4543edd34d3c82e.zip |
Make gdi canvas build in the new pixman world
-rw-r--r-- | client/red_gdi_canvas.cpp | 15 | ||||
-rw-r--r-- | common/canvas_utils.c | 8 | ||||
-rw-r--r-- | common/gdi_canvas.c | 31 | ||||
-rw-r--r-- | common/gdi_canvas.h | 4 |
4 files changed, 35 insertions, 23 deletions
diff --git a/client/red_gdi_canvas.cpp b/client/red_gdi_canvas.cpp index e30845e8..671fe82f 100644 --- a/client/red_gdi_canvas.cpp +++ b/client/red_gdi_canvas.cpp @@ -64,9 +64,18 @@ void GDICanvas::create_pixmap(int width, int height) void GDICanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc) { - for (int i = 0; i < (int)region.num_rects; i++) { - SpiceRect* r = ®ion.rects[i]; - dest_dc.copy_pixels(*_pixmap, r->left, r->top, *r); + pixman_box32_t *rects; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)®ion, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + dest_dc.copy_pixels(*_pixmap, r.left, r.top, r); } } diff --git a/common/canvas_utils.c b/common/canvas_utils.c index b70b17b3..89ebe121 100644 --- a/common/canvas_utils.c +++ b/common/canvas_utils.c @@ -173,7 +173,7 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig bitmap = CreateDIBSection(dc, &bitmap_info.inf, 0, (VOID **)&data, NULL, 0); if (!bitmap) { - CloseHandle(bitmap_cache->mutex); + CloseHandle(mutex); CANVAS_ERROR("Unable to CreateDIBSection"); } @@ -184,15 +184,15 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig nstride = -nstride; } - surface = pixman_image_create_bits(format, width, height, (uint32_t *)src, stride); + surface = pixman_image_create_bits(format, width, height, (uint32_t *)src, nstride); if (surface == NULL) { CloseHandle(mutex); DeleteObject(bitmap); CANVAS_ERROR("create surface failed, out of memory"); } pixman_data = pixman_image_add_data(surface); - pixman_data.bitmap = bitmap; - pixman_data.mutex = mutex; + pixman_data->bitmap = bitmap; + pixman_data->mutex = mutex; gdi_handlers++; return surface; } else { diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c index 83c5f05d..ae477db4 100644 --- a/common/gdi_canvas.c +++ b/common/gdi_canvas.c @@ -307,13 +307,13 @@ uint32_t raster_ops[] = { static inline void surface_to_image(pixman_image_t *surface, GdiImage *image) { - int depth = pixman_image_surface_get_depth(surface); + int depth = pixman_image_get_depth(surface); ASSERT(depth == 32 || depth == 24); image->width = pixman_image_get_width(surface); image->height = pixman_image_get_height(surface); image->stride = pixman_image_get_stride(surface); - image->pixels = pixman_image_get_data(surface); + image->pixels = (uint8_t *)pixman_image_get_data(surface); } static void set_path(GdiCanvas *canvas, void *addr) @@ -788,7 +788,7 @@ static struct BitmapData get_mask_bitmap(struct GdiCanvas *canvas, struct SpiceQ return bitmap; } - pixman_data = pixman_image_get_destroy_data (surface); + pixman_data = (PixmanData *)pixman_image_get_destroy_data (surface); if (pixman_data && (WaitForSingleObject(pixman_data->mutex, INFINITE) != WAIT_FAILED)) { bitmap.dc = create_compatible_dc(); bitmap.prev_hbitmap = (HBITMAP)SelectObject(bitmap.dc, pixman_data->bitmap); @@ -796,7 +796,7 @@ static struct BitmapData get_mask_bitmap(struct GdiCanvas *canvas, struct SpiceQ ReleaseMutex(pixman_data->mutex); bitmap.cache = 1; } else if (!create_bitmap(&bitmap.hbitmap, &bitmap.prev_hbitmap, &bitmap.dc, - pixman_image_get_data(surface), + (uint8_t *)pixman_image_get_data(surface), pixman_image_get_width(surface), pixman_image_get_height(surface), pixman_image_get_stride(surface), 1, 0)) { @@ -926,7 +926,7 @@ static void draw_str_mask_bitmap(struct GdiCanvas *canvas, unset_brush(bitmap.dc, prev_hbrush); - copy_bitmap_alpha(pixman_image_get_data(surface), + copy_bitmap_alpha((uint8_t *)pixman_image_get_data(surface), pixman_image_get_height(surface), pixman_image_get_width(surface), pixman_image_get_stride(surface), @@ -1045,28 +1045,31 @@ void gdi_canvas_put_image(GdiCanvas *canvas, HDC dc, const SpiceRect *dest, cons src.bottom = src_height; src.left = 0; src.right = src_width; + int num_rects; + pixman_box32_t *rects; Lock lock(*canvas->lock); set_scale_mode(canvas, SPICE_IMAGE_SCALE_MODE_NEAREST); if (clip) { - if (clip->num_rects == 0) { + rects = pixman_region32_rectangles((pixman_region32_t*)clip, &num_rects); + if (num_rects == 0) { return; } else { HRGN main_hrgn; - uint32_t i; + int i; - main_hrgn = CreateRectRgn(clip->rects[0].left, clip->rects[0].top, clip->rects[0].right, - clip->rects[0].bottom); + main_hrgn = CreateRectRgn(rects[0].x1, rects[0].y1, rects[0].x2, + rects[0].y2); if (!main_hrgn) { return; } - for (i = 1; i < clip->num_rects; i++) { + for (i = 1; i < num_rects; i++) { HRGN combaine_hrgn; - combaine_hrgn = CreateRectRgn(clip->rects[i].left, clip->rects[i].top, - clip->rects[i].right, - clip->rects[i].bottom); + combaine_hrgn = CreateRectRgn(rects[i].x1, rects[i].y1, + rects[i].x2, + rects[i].y2); if (!combaine_hrgn) { CANVAS_ERROR("CreateRectRgn failed"); DeleteObject(main_hrgn); @@ -1695,7 +1698,7 @@ void gdi_canvas_destroy(GdiCanvas *canvas) static int need_init = 1; #ifdef CAIRO_CANVAS_CACHE -GdiCanvas *gdi_canvas_create(HDC dc, Mutex* lock, int bits, void *bits_cache_opaque, +GdiCanvas *gdi_canvas_create(HDC dc, Mutex* lock, int bits, SpiceImageCache *bits_cache, SpicePaletteCache *palette_cache #elif defined(CAIRO_CANVAS_IMAGE_CACHE) diff --git a/common/gdi_canvas.h b/common/gdi_canvas.h index febd9675..d9b8d219 100644 --- a/common/gdi_canvas.h +++ b/common/gdi_canvas.h @@ -59,9 +59,9 @@ void gdi_canvas_set_access_params(GdiCanvas *canvas, unsigned long base, unsigne #endif -GdiCanvas *gdi_canvas_create(HDC dc, class Mutex *lock, int bits, void *bits_cache_opaque, +GdiCanvas *gdi_canvas_create(HDC dc, class Mutex *lock, int bits, SpiceImageCache *bits_cache, - SpicePaletteCache *palette_cache + SpicePaletteCache *palette_cache, void *glz_decoder_opaque, glz_decode_fn_t glz_decode); |