[Spice-commits] 8 commits - common/canvas_base.c common/canvas_base.h common/canvas_utils.c common/canvas_utils.h common/sw_canvas.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Jan 18 14:35:42 UTC 2018
common/canvas_base.c | 53 +----------------
common/canvas_base.h | 6 -
common/canvas_utils.c | 151 ++------------------------------------------------
common/canvas_utils.h | 26 --------
common/sw_canvas.c | 3
5 files changed, 14 insertions(+), 225 deletions(-)
New commits:
commit 41c7ea6611a2a10c96a3fa032c6e236c93431348
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:44:30 2017 +0000
canvas: Remove unused include header
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_base.h b/common/canvas_base.h
index b746bcb..27e2751 100644
--- a/common/canvas_base.h
+++ b/common/canvas_base.h
@@ -25,9 +25,6 @@
#include "lz.h"
#include "region.h"
#include "draw.h"
-#ifdef WIN32
-#include <windows.h>
-#endif
SPICE_BEGIN_DECLS
diff --git a/common/canvas_utils.h b/common/canvas_utils.h
index 60a9e16..febf858 100644
--- a/common/canvas_utils.h
+++ b/common/canvas_utils.h
@@ -19,10 +19,6 @@
#ifndef _H_CANVAS_UTILS
#define _H_CANVAS_UTILS
-#ifdef WIN32
-#include <windows.h>
-#endif
-
#include <spice/types.h>
#include <spice/macros.h>
commit 0dda6fbf550d77c04fdc91aaa696490458abca3f
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:42:23 2017 +0000
canvas: Unify __surface_create_stride and surface_create_stride
They are now just the same function with same parameters,
just one calls the other.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 3e143de..a95501f 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -84,8 +84,8 @@ int spice_pixman_image_get_format(pixman_image_t *image, pixman_format_code_t *f
return 0;
}
-static inline pixman_image_t *__surface_create_stride(pixman_format_code_t format, int width, int height,
- int stride)
+pixman_image_t *surface_create_stride(pixman_format_code_t format, int width, int height,
+ int stride)
{
uint8_t *data;
uint8_t *stride_data;
@@ -157,16 +157,10 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
spice_error("invalid format");
}
stride = -stride;
- return __surface_create_stride(format, width, height, stride);
+ return surface_create_stride(format, width, height, stride);
}
}
-pixman_image_t *surface_create_stride(pixman_format_code_t format, int width, int height,
- int stride)
-{
- return __surface_create_stride(format, width, height, stride);
-}
-
pixman_image_t *alloc_lz_image_surface(LzDecodeUsrData *canvas_data,
pixman_format_code_t pixman_format, int width,
int height, int gross_pixels, int top_down)
commit 3bf6e7b899b372e076ba39266417530c470f3d76
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:40:57 2017 +0000
canvas: Remove dc fields from CanvasBase and LzDecodeUsrData
Now always NULL.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 764747a..42f0eea 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -132,9 +132,6 @@ typedef struct CanvasBase {
#ifdef SW_CANVAS_CACHE
SpicePaletteCache *palette_cache;
#endif
-#ifdef WIN32
- HDC dc;
-#endif
SpiceImageSurfaces *surfaces;
@@ -623,9 +620,6 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *ima
alpha_top_down = TRUE;
}
-#ifdef WIN32
- lz_data->decode_data.dc = canvas->dc;
-#endif
surface = alloc_lz_image_surface(&lz_data->decode_data, PIXMAN_LE_a8r8g8b8,
width, height, width*height, alpha_top_down);
@@ -840,10 +834,6 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
spice_return_val_if_fail((unsigned)height == image->descriptor.height, NULL);
spice_return_val_if_fail((image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) || (n_comp_pixels == width * height), NULL);
-#ifdef WIN32
- lz_data->decode_data.dc = canvas->dc;
-#endif
-
alloc_lz_image_surface(&lz_data->decode_data, pixman_format,
width, height, n_comp_pixels, top_down);
@@ -886,9 +876,6 @@ static pixman_image_t *canvas_get_glz(CanvasBase *canvas, SpiceImage *image,
int want_original)
{
spice_return_val_if_fail(image->descriptor.type == SPICE_IMAGE_TYPE_GLZ_RGB, NULL);
-#ifdef WIN32
- canvas->glz_data.decode_data.dc = canvas->dc;
-#endif
spice_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
return canvas_get_glz_rgb_common(canvas, image->u.lz_rgb.data->chunk[0].data, want_original);
@@ -3481,9 +3468,5 @@ static int canvas_base_init(CanvasBase *canvas, SpiceCanvasOps *ops,
canvas->palette_cache = palette_cache;
#endif
-#ifdef WIN32
- canvas->dc = NULL;
-#endif
-
return 1;
}
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index b586886..3e143de 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -161,22 +161,9 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
}
}
-#ifdef WIN32
-pixman_image_t *surface_create_stride(HDC dc, pixman_format_code_t format, int width, int height,
- int stride)
-#else
pixman_image_t *surface_create_stride(pixman_format_code_t format, int width, int height,
int stride)
-#endif
{
-#ifdef WIN32
- if (dc) {
- if (abs(stride) == (width * 4)) {
- return surface_create(format, width, height, (stride > 0));
- }
- }
-#endif
-
return __surface_create_stride(format, width, height, stride);
}
@@ -196,11 +183,7 @@ pixman_image_t *alloc_lz_image_surface(LzDecodeUsrData *canvas_data,
stride = -stride;
}
- surface = surface_create_stride(
-#ifdef WIN32
- canvas_data->dc,
-#endif
- pixman_format, width, height, stride);
+ surface = surface_create_stride(pixman_format, width, height, stride);
canvas_data->out_surface = surface;
return surface;
}
diff --git a/common/canvas_utils.h b/common/canvas_utils.h
index c198234..60a9e16 100644
--- a/common/canvas_utils.h
+++ b/common/canvas_utils.h
@@ -38,19 +38,11 @@ int spice_pixman_image_get_format(pixman_image_t *image, pixman_format_code_t *f
pixman_image_t *surface_create(pixman_format_code_t format, int width, int height, int top_down);
-#ifdef WIN32
-pixman_image_t *surface_create_stride(HDC dc, pixman_format_code_t format, int width, int height,
- int stride);
-#else
pixman_image_t *surface_create_stride(pixman_format_code_t format, int width, int height,
int stride);
-#endif
typedef struct LzDecodeUsrData {
-#ifdef WIN32
- HDC dc;
-#endif
pixman_image_t *out_surface;
} LzDecodeUsrData;
commit b0f1d31dd1793e4cf048f2f26e9e96dc88ccff30
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:36:33 2017 +0000
canvas: Remove dc parameter from SwCanvas::put_image
Not used anymore.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_base.h b/common/canvas_base.h
index 2d3c35b..b746bcb 100644
--- a/common/canvas_base.h
+++ b/common/canvas_base.h
@@ -141,9 +141,6 @@ typedef struct {
void (*draw_transparent)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceTransparent* transparent);
void (*draw_alpha_blend)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceAlphaBlend* alpha_blend);
void (*put_image)(SpiceCanvas *canvas,
-#ifdef WIN32
- HDC dc,
-#endif
const SpiceRect *dest, const uint8_t *src_data,
uint32_t src_width, uint32_t src_height, int src_stride,
const QRegion *clip);
diff --git a/common/sw_canvas.c b/common/sw_canvas.c
index c347a56..c41edb1 100644
--- a/common/sw_canvas.c
+++ b/common/sw_canvas.c
@@ -993,9 +993,6 @@ static void colorkey_scale_image_from_surface(SpiceCanvas *spice_canvas,
}
static void canvas_put_image(SpiceCanvas *spice_canvas,
-#ifdef WIN32
- HDC dc,
-#endif
const SpiceRect *dest, const uint8_t *src_data,
uint32_t src_width, uint32_t src_height, int src_stride,
const QRegion *clip)
commit 6ce1a6157737da1809cee5834296708b8fe941bb
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:32:17 2017 +0000
canvas: Remove unused dc parameter from surface_create
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_base.c b/common/canvas_base.c
index b9ba37c..764747a 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -418,11 +418,7 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,
spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);
- surface = surface_create(
-#ifdef WIN32
- canvas->dc,
-#endif
- pixman_format,
+ surface = surface_create(pixman_format,
width, height, FALSE);
spice_return_val_if_fail(surface != NULL, NULL);
@@ -481,11 +477,7 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);
- surface = surface_create(
-#ifdef WIN32
- canvas->dc,
-#endif
- PIXMAN_LE_x8r8g8b8,
+ surface = surface_create(PIXMAN_LE_x8r8g8b8,
width, height, FALSE);
if (surface == NULL) {
spice_warning("create surface failed");
@@ -563,11 +555,7 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image)
return NULL;
}
- surface = surface_create(
-#ifdef WIN32
- canvas->dc,
-#endif
- format,
+ surface = surface_create(format,
width, height, top_down);
if (surface == NULL) {
spice_warning("create surface failed");
@@ -694,11 +682,7 @@ static pixman_image_t *canvas_bitmap_to_surface(CanvasBase *canvas, SpiceBitmap*
bitmap->format == SPICE_BITMAP_FMT_RGBA);
}
- image = surface_create(
-#ifdef WIN32
- canvas->dc,
-#endif
- format,
+ image = surface_create(format,
bitmap->x, bitmap->y, FALSE);
if (image == NULL) {
spice_warning("create surface failed");
@@ -1262,11 +1246,7 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
surface_format == PIXMAN_a8r8g8b8);
if (surface_format != wanted_format) {
- converted = surface_create(
-#ifdef WIN32
- canvas->dc,
-#endif
- wanted_format,
+ converted = surface_create(wanted_format,
pixman_image_get_width(surface),
pixman_image_get_height(surface),
TRUE);
@@ -1411,11 +1391,7 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b
int line_size;
int dest_stride;
- surface = surface_create(
-#ifdef WIN32
- canvas->dc,
-#endif
- PIXMAN_a1, bitmap->x, bitmap->y, TRUE);
+ surface = surface_create(PIXMAN_a1, bitmap->x, bitmap->y, TRUE);
spice_return_val_if_fail(surface != NULL, NULL);
spice_chunks_linearize(bitmap->data);
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 57fffbe..b586886 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -114,12 +114,7 @@ static inline pixman_image_t *__surface_create_stride(pixman_format_code_t forma
return surface;
}
-#ifdef WIN32
-pixman_image_t *surface_create(HDC dc, pixman_format_code_t format,
- int width, int height, int top_down)
-#else
pixman_image_t * surface_create(pixman_format_code_t format, int width, int height, int top_down)
-#endif
{
if (top_down) {
pixman_image_t *surface;
@@ -177,7 +172,7 @@ pixman_image_t *surface_create_stride(pixman_format_code_t format, int width, in
#ifdef WIN32
if (dc) {
if (abs(stride) == (width * 4)) {
- return surface_create(dc, format, width, height, (stride > 0));
+ return surface_create(format, width, height, (stride > 0));
}
}
#endif
diff --git a/common/canvas_utils.h b/common/canvas_utils.h
index 63d0fbb..c198234 100644
--- a/common/canvas_utils.h
+++ b/common/canvas_utils.h
@@ -36,12 +36,7 @@ void spice_pixman_image_set_format(pixman_image_t *image,
int spice_pixman_image_get_format(pixman_image_t *image, pixman_format_code_t *format);
-#ifdef WIN32
-pixman_image_t *surface_create(HDC dc, pixman_format_code_t format,
- int width, int height, int top_down);
-#else
pixman_image_t *surface_create(pixman_format_code_t format, int width, int height, int top_down);
-#endif
#ifdef WIN32
pixman_image_t *surface_create_stride(HDC dc, pixman_format_code_t format, int width, int height,
commit 00d1cda4ce9f62fb81df94a104afe6e3076c8cff
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:29:18 2017 +0000
canvas: Remove Windows bitmap allocation
There's no reason to use a DIB section if we are going to use just the
memory in it assigned to a pixman surface, use normal path and memory.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index a6527e7..57fffbe 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -23,14 +23,7 @@
#include "canvas_utils.h"
#include "mem.h"
-#ifdef WIN32
-static int gdi_handlers = 0;
-#endif
-
typedef struct PixmanData {
-#ifdef WIN32
- HBITMAP bitmap;
-#endif
uint8_t *data;
pixman_format_code_t format;
} PixmanData;
@@ -40,12 +33,6 @@ static void release_data(SPICE_GNUC_UNUSED pixman_image_t *image,
{
PixmanData *data = (PixmanData *)release_data;
-#ifdef WIN32
- if (data->bitmap) {
- DeleteObject((HBITMAP)data->bitmap);
- gdi_handlers--;
- }
-#endif
free(data->data);
free(data);
@@ -134,94 +121,6 @@ pixman_image_t *surface_create(HDC dc, pixman_format_code_t format,
pixman_image_t * surface_create(pixman_format_code_t format, int width, int height, int top_down)
#endif
{
-#ifdef WIN32
- /*
- * Windows xp allow only 10,000 of gdi handlers, considering the fact that
- * we limit here the number to 5000, we dont use atomic operations to sync
- * this calculation against the other canvases (in case of multiple
- * monitors), in worst case there will be little more than 5000 gdi
- * handlers.
- */
- if (dc && gdi_handlers < 5000) {
- uint8_t *data;
- uint8_t *src;
- struct {
- BITMAPINFO inf;
- RGBQUAD palette[255];
- } bitmap_info;
- int nstride;
- pixman_image_t *surface;
- PixmanData *pixman_data;
- HBITMAP bitmap;
-
- memset(&bitmap_info, 0, sizeof(bitmap_info));
- bitmap_info.inf.bmiHeader.biSize = sizeof(bitmap_info.inf.bmiHeader);
- bitmap_info.inf.bmiHeader.biWidth = width;
-
- bitmap_info.inf.bmiHeader.biHeight = (!top_down) ? height : -height;
-
- bitmap_info.inf.bmiHeader.biPlanes = 1;
- switch (format) {
- case PIXMAN_a8r8g8b8:
- case PIXMAN_x8r8g8b8:
-#ifdef WORDS_BIGENDIAN
- case PIXMAN_b8g8r8a8:
- case PIXMAN_b8g8r8x8:
-#endif
- bitmap_info.inf.bmiHeader.biBitCount = 32;
- nstride = width * 4;
- break;
- case PIXMAN_r8g8b8:
-#ifdef WORDS_BIGENDIAN
- case PIXMAN_b8g8r8:
-#endif
- bitmap_info.inf.bmiHeader.biBitCount = 24;
- nstride = SPICE_ALIGN(width * 3, 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);
- break;
- case PIXMAN_a1:
- bitmap_info.inf.bmiHeader.biBitCount = 1;
- nstride = SPICE_ALIGN(width, 32) / 8;
- break;
- default:
- spice_error("invalid format");
- return NULL;
- }
-
- bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
-
- bitmap = CreateDIBSection(dc, &bitmap_info.inf, 0, (VOID **)&data, NULL, 0);
- if (!bitmap) {
- spice_error("Unable to CreateDIBSection");
- }
-
- if (top_down) {
- src = data;
- } else {
- src = data + nstride * (height - 1);
- nstride = -nstride;
- }
-
- surface = pixman_image_create_bits(format, width, height, (uint32_t *)src, nstride);
- if (surface == NULL) {
- DeleteObject(bitmap);
- spice_error("create surface failed, out of memory");
- }
- pixman_data = pixman_image_add_data(surface);
- pixman_data->format = format;
- pixman_data->bitmap = bitmap;
- gdi_handlers++;
- return surface;
- } else {
-#endif
if (top_down) {
pixman_image_t *surface;
PixmanData *data;
@@ -265,10 +164,6 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
stride = -stride;
return __surface_create_stride(format, width, height, stride);
}
-#ifdef WIN32
-}
-
-#endif
}
#ifdef WIN32
commit cd88d0294c78a4d12f4a9a1b7551c5e5e1461c8a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:23:31 2017 +0000
canvas: Remove mutex field from PixmanData
The field is only assigned but never used.
This was used in the GDI canvas which has now been removed.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 626f17d..a6527e7 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -30,7 +30,6 @@ static int gdi_handlers = 0;
typedef struct PixmanData {
#ifdef WIN32
HBITMAP bitmap;
- HANDLE mutex;
#endif
uint8_t *data;
pixman_format_code_t format;
@@ -44,7 +43,6 @@ static void release_data(SPICE_GNUC_UNUSED pixman_image_t *image,
#ifdef WIN32
if (data->bitmap) {
DeleteObject((HBITMAP)data->bitmap);
- CloseHandle(data->mutex);
gdi_handlers--;
}
#endif
@@ -155,7 +153,6 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
pixman_image_t *surface;
PixmanData *pixman_data;
HBITMAP bitmap;
- HANDLE mutex;
memset(&bitmap_info, 0, sizeof(bitmap_info));
bitmap_info.inf.bmiHeader.biSize = sizeof(bitmap_info.inf.bmiHeader);
@@ -201,14 +198,8 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
- mutex = CreateMutex(NULL, 0, NULL);
- if (!mutex) {
- spice_error("Unable to CreateMutex");
- }
-
bitmap = CreateDIBSection(dc, &bitmap_info.inf, 0, (VOID **)&data, NULL, 0);
if (!bitmap) {
- CloseHandle(mutex);
spice_error("Unable to CreateDIBSection");
}
@@ -221,14 +212,12 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
surface = pixman_image_create_bits(format, width, height, (uint32_t *)src, nstride);
if (surface == NULL) {
- CloseHandle(mutex);
DeleteObject(bitmap);
spice_error("create surface failed, out of memory");
}
pixman_data = pixman_image_add_data(surface);
pixman_data->format = format;
pixman_data->bitmap = bitmap;
- pixman_data->mutex = mutex;
gdi_handlers++;
return surface;
} else {
commit fea48544a89471e4577bb2a24835dd3b07b8bd0c
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Dec 24 14:21:17 2017 +0000
canvas: Move PixmanData to C file
This structure is used only in canvas_utils.c
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 0be761a..626f17d 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -27,6 +27,15 @@
static int gdi_handlers = 0;
#endif
+typedef struct PixmanData {
+#ifdef WIN32
+ HBITMAP bitmap;
+ HANDLE mutex;
+#endif
+ uint8_t *data;
+ pixman_format_code_t format;
+} PixmanData;
+
static void release_data(SPICE_GNUC_UNUSED pixman_image_t *image,
void *release_data)
{
diff --git a/common/canvas_utils.h b/common/canvas_utils.h
index ef3f9c5..63d0fbb 100644
--- a/common/canvas_utils.h
+++ b/common/canvas_utils.h
@@ -31,15 +31,6 @@
SPICE_BEGIN_DECLS
-typedef struct PixmanData {
-#ifdef WIN32
- HBITMAP bitmap;
- HANDLE mutex;
-#endif
- uint8_t *data;
- pixman_format_code_t format;
-} PixmanData;
-
void spice_pixman_image_set_format(pixman_image_t *image,
pixman_format_code_t format);
int spice_pixman_image_get_format(pixman_image_t *image, pixman_format_code_t *format);
More information about the Spice-commits
mailing list