summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-04-19 16:19:43 +0200
committerAlexander Larsson <alexl@redhat.com>2010-04-23 16:36:35 +0200
commit98d91203c5d2f6f7249f38941466857b6a566f5d (patch)
treecdc2b54152f0be3d668ed49b903a35886fcc1c99 /common
parent619c37af17406f77c7cb76f3b72bbfc268383d91 (diff)
downloadspice-98d91203c5d2f6f7249f38941466857b6a566f5d.tar.gz
spice-98d91203c5d2f6f7249f38941466857b6a566f5d.tar.xz
spice-98d91203c5d2f6f7249f38941466857b6a566f5d.zip
Make client canvas and pixmaps handle more formats and simplify
We now support 16bit format pixmaps as well as the old ones. Including both 555 and 565 modes. We drop the palette argument for pixmap construction as it was only used for black/white anyway. Canvas creation is simplified so that there is no separate set_mode state. Canvases are already created in the right mode and never change.
Diffstat (limited to 'common')
-rw-r--r--common/cairo_canvas.c76
-rw-r--r--common/cairo_canvas.h17
-rw-r--r--common/canvas_base.c8
-rw-r--r--common/canvas_utils.c9
-rw-r--r--common/gdi_canvas.c4
-rw-r--r--common/gdi_canvas.h2
-rw-r--r--common/gl_canvas.c4
-rw-r--r--common/gl_canvas.h2
8 files changed, 110 insertions, 12 deletions
diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c
index 38a7081e..fde43d7f 100644
--- a/common/cairo_canvas.c
+++ b/common/cairo_canvas.c
@@ -1074,7 +1074,8 @@ static void canvas_destroy(SpiceCanvas *spice_canvas)
static int need_init = 1;
static SpiceCanvasOps cairo_canvas_ops;
-SpiceCanvas *canvas_create(pixman_image_t *image, int bits
+static SpiceCanvas *canvas_create_common(pixman_image_t *image,
+ uint32_t format
#ifdef CAIRO_CANVAS_CACHE
, SpiceImageCache *bits_cache
, SpicePaletteCache *palette_cache
@@ -1098,7 +1099,7 @@ SpiceCanvas *canvas_create(pixman_image_t *image, int bits
init_ok = canvas_base_init(&canvas->base, &cairo_canvas_ops,
pixman_image_get_width (image),
pixman_image_get_height (image),
- bits
+ format
#ifdef CAIRO_CANVAS_CACHE
, bits_cache
, palette_cache
@@ -1114,11 +1115,80 @@ SpiceCanvas *canvas_create(pixman_image_t *image, int bits
canvas->private_data = NULL;
canvas->private_data_size = 0;
- canvas->image = pixman_image_ref(image);
+ canvas->image = image;
return (SpiceCanvas *)canvas;
}
+SpiceCanvas *canvas_create(int width, int height, uint32_t format
+#ifdef CAIRO_CANVAS_CACHE
+ , SpiceImageCache *bits_cache
+ , SpicePaletteCache *palette_cache
+#elif defined(CAIRO_CANVAS_IMAGE_CACHE)
+ , SpiceImageCache *bits_cache
+#endif
+ , SpiceImageSurfaces *surfaces
+ , SpiceGlzDecoder *glz_decoder
+#ifndef CAIRO_CANVAS_NO_CHUNKS
+ , SpiceVirtMapping *virt_mapping
+#endif
+ )
+{
+ pixman_image_t *image;
+
+ image = pixman_image_create_bits(spice_surface_format_to_pixman (format),
+ width, height, NULL, 0);
+
+ return canvas_create_common(image, format
+#ifdef CAIRO_CANVAS_CACHE
+ , bits_cache
+ , palette_cache
+#elif defined(CAIRO_CANVAS_IMAGE_CACHE)
+ , bits_cache
+#endif
+ , surfaces
+ , glz_decoder
+#ifndef CAIRO_CANVAS_NO_CHUNKS
+ , virt_mapping
+#endif
+ );
+}
+
+SpiceCanvas *canvas_create_for_data(int width, int height, uint32_t format,
+ uint8_t *data, size_t stride
+#ifdef CAIRO_CANVAS_CACHE
+ , SpiceImageCache *bits_cache
+ , SpicePaletteCache *palette_cache
+#elif defined(CAIRO_CANVAS_IMAGE_CACHE)
+ , SpiceImageCache *bits_cache
+#endif
+ , SpiceImageSurfaces *surfaces
+ , SpiceGlzDecoder *glz_decoder
+#ifndef CAIRO_CANVAS_NO_CHUNKS
+ , SpiceVirtMapping *virt_mapping
+#endif
+ )
+{
+ pixman_image_t *image;
+
+ image = pixman_image_create_bits(spice_surface_format_to_pixman (format),
+ width, height, (uint32_t *)data, stride);
+
+ return canvas_create_common(image, format
+#ifdef CAIRO_CANVAS_CACHE
+ , bits_cache
+ , palette_cache
+#elif defined(CAIRO_CANVAS_IMAGE_CACHE)
+ , bits_cache
+#endif
+ , surfaces
+ , glz_decoder
+#ifndef CAIRO_CANVAS_NO_CHUNKS
+ , virt_mapping
+#endif
+ );
+}
+
void cairo_canvas_init() //unsafe global function
{
if (!need_init) {
diff --git a/common/cairo_canvas.h b/common/cairo_canvas.h
index 7f882b2a..c97380e2 100644
--- a/common/cairo_canvas.h
+++ b/common/cairo_canvas.h
@@ -26,7 +26,7 @@
#include "canvas_base.h"
#include "region.h"
-SpiceCanvas *canvas_create(pixman_image_t *image, int bits
+SpiceCanvas *canvas_create(int width, int height, uint32_t format
#ifdef CAIRO_CANVAS_CACHE
, SpiceImageCache *bits_cache
, SpicePaletteCache *palette_cache
@@ -40,6 +40,21 @@ SpiceCanvas *canvas_create(pixman_image_t *image, int bits
#endif
);
+SpiceCanvas *canvas_create_for_data(int width, int height, uint32_t format, uint8_t *data, size_t stride
+#ifdef CAIRO_CANVAS_CACHE
+ , SpiceImageCache *bits_cache
+ , SpicePaletteCache *palette_cache
+#elif defined(CAIRO_CANVAS_IMAGE_CACHE)
+ , SpiceImageCache *bits_cache
+#endif
+ , SpiceImageSurfaces *surfaces
+ , SpiceGlzDecoder *glz_decoder
+#ifndef CAIRO_CANVAS_NO_CHUNKS
+ , SpiceVirtMapping *virt_mapping
+#endif
+ );
+
+
void cairo_canvas_init();
#endif
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 9852da9e..fb101fda 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -176,6 +176,7 @@ typedef struct CanvasBase {
unsigned long max;
#endif
+ uint32_t format;
int width;
int height;
pixman_region32_t canvas_region;
@@ -3175,7 +3176,7 @@ inline static void canvas_base_init_ops(SpiceCanvasOps *ops)
}
static int canvas_base_init(CanvasBase *canvas, SpiceCanvasOps *ops,
- int width, int height, int depth
+ int width, int height, uint32_t format
#ifdef CAIRO_CANVAS_CACHE
, SpiceImageCache *bits_cache
, SpicePaletteCache *palette_cache
@@ -3218,7 +3219,10 @@ static int canvas_base_init(CanvasBase *canvas, SpiceCanvasOps *ops,
canvas->surfaces = surfaces;
canvas->glz_data.decoder = glz_decoder;
- if (depth == 16) {
+ canvas->format = format;
+
+ /* TODO: This is all wrong now */
+ if (SPICE_SURFACE_FMT_DEPTH(format) == 16) {
canvas->color_shift = 5;
canvas->color_mask = 0x1f;
} else {
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 1e97e872..4f2456d6 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -175,6 +175,11 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
bitmap_info.inf.bmiHeader.biBitCount = 32;
nstride = width * 4;
break;
+ case PIXMAN_x1r5g5b5:
+ case PIXMAN_r5g6b5:
+ bitmap_info.inf.bmiHeader.biBitCount = 16;
+ nstride = SPICE_ALIGN(width * 2, 4);
+ break;
case PIXMAN_a8:
bitmap_info.inf.bmiHeader.biBitCount = 8;
nstride = SPICE_ALIGN(width, 4);
@@ -237,6 +242,10 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
case PIXMAN_x8r8g8b8:
stride = width * 4;
break;
+ case PIXMAN_x1r5g5b5:
+ case PIXMAN_r5g6b5:
+ stride = SPICE_ALIGN(width * 2, 4);
+ break;
case PIXMAN_a8:
stride = SPICE_ALIGN(width, 4);
break;
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index ead94af0..c600419d 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -1884,7 +1884,7 @@ static int need_init = 1;
static SpiceCanvasOps gdi_canvas_ops;
SpiceCanvas *gdi_canvas_create(int width, int height,
- HDC dc, RecurciveMutex* lock, int bits
+ HDC dc, RecurciveMutex* lock, uint32_t format
#ifdef CAIRO_CANVAS_CACHE
, SpiceImageCache *bits_cache
, SpicePaletteCache *palette_cache
@@ -1903,7 +1903,7 @@ SpiceCanvas *gdi_canvas_create(int width, int height,
}
canvas = spice_new0(GdiCanvas, 1);
init_ok = canvas_base_init(&canvas->base, &gdi_canvas_ops,
- width, height, bits
+ width, height, format
#ifdef CAIRO_CANVAS_CACHE
,bits_cache
,palette_cache
diff --git a/common/gdi_canvas.h b/common/gdi_canvas.h
index 43da189c..13d82efa 100644
--- a/common/gdi_canvas.h
+++ b/common/gdi_canvas.h
@@ -34,7 +34,7 @@ typedef struct {
} GdiImage;
SpiceCanvas *gdi_canvas_create(int width, int height,
- HDC dc, class RecurciveMutex *lock, int bits,
+ HDC dc, class RecurciveMutex *lock, uint32_t format,
SpiceImageCache *bits_cache,
SpicePaletteCache *palette_cache,
SpiceImageSurfaces *surfaces,
diff --git a/common/gl_canvas.c b/common/gl_canvas.c
index dd470bc5..9b017fa2 100644
--- a/common/gl_canvas.c
+++ b/common/gl_canvas.c
@@ -821,7 +821,7 @@ static void gl_canvas_set_access_params(SpiceCanvas *spice_canvas, unsigned long
static int need_init = 1;
static SpiceCanvasOps gl_canvas_ops;
-SpiceCanvas *gl_canvas_create(int width, int height, int depth
+SpiceCanvas *gl_canvas_create(int width, int height, uint32_t format
#ifdef CAIRO_CANVAS_CACHE
, SpiceImageCache *bits_cache
, SpicePaletteCache *palette_cache
@@ -848,7 +848,7 @@ SpiceCanvas *gl_canvas_create(int width, int height, int depth
}
canvas->private_data = NULL;
init_ok = canvas_base_init(&canvas->base, &gl_canvas_ops,
- width, height, depth
+ width, height, format
#ifdef CAIRO_CANVAS_CACHE
, bits_cache
, palette_cache
diff --git a/common/gl_canvas.h b/common/gl_canvas.h
index 7c54cbfb..615ca895 100644
--- a/common/gl_canvas.h
+++ b/common/gl_canvas.h
@@ -21,7 +21,7 @@
#include "canvas_base.h"
#include "region.h"
-SpiceCanvas *gl_canvas_create(int width, int height, int depth
+SpiceCanvas *gl_canvas_create(int width, int height, uint32_t format
#ifdef CAIRO_CANVAS_CACHE
, SpiceImageCache *bits_cache
, SpicePaletteCache *palette_cache