diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-04-21 17:45:07 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-04-23 16:36:35 +0200 |
commit | 619c37af17406f77c7cb76f3b72bbfc268383d91 (patch) | |
tree | eb570d9ced1d4e6e3be80ff6d2ef3d4ee45fbb11 /common | |
parent | 6dc52f1389b6b1c6ce2589ff183982d65c8c1581 (diff) |
common: Add lookaside storage for pixman image format
Ideally we should just read this from the pixman image, but
there is no API to do so in stable pixman, so we store it.
Diffstat (limited to 'common')
-rw-r--r-- | common/canvas_utils.c | 33 | ||||
-rw-r--r-- | common/canvas_utils.h | 6 |
2 files changed, 38 insertions, 1 deletions
diff --git a/common/canvas_utils.c b/common/canvas_utils.c index 6ffd8565..1e97e872 100644 --- a/common/canvas_utils.c +++ b/common/canvas_utils.c @@ -82,6 +82,29 @@ pixman_image_add_data(pixman_image_t *image) return data; } +void +spice_pixman_image_set_format(pixman_image_t *image, + pixman_format_code_t format) +{ + PixmanData *data; + + data = pixman_image_add_data(image); + data->format = format; +} + +pixman_format_code_t +spice_pixman_image_get_format(pixman_image_t *image) +{ + PixmanData *data; + + data = (PixmanData *)pixman_image_get_destroy_data(image); + if (data != NULL && + data->format != 0) + return data->format; + + CANVAS_ERROR("Unknown pixman image type"); +} + static inline pixman_image_t *__surface_create_stride(pixman_format_code_t format, int width, int height, int stride) { @@ -106,6 +129,7 @@ static inline pixman_image_t *__surface_create_stride(pixman_format_code_t forma pixman_data = pixman_image_add_data(surface); pixman_data->data = data; + pixman_data->format = format; return surface; } @@ -190,6 +214,7 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig CANVAS_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++; @@ -197,7 +222,13 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig } else { #endif if (top_down) { - return pixman_image_create_bits(format, width, height, NULL, 0); + pixman_image_t *surface; + PixmanData *data; + + surface = pixman_image_create_bits(format, width, height, NULL, 0); + data = pixman_image_add_data(surface); + data->format = format; + return surface; } else { // NOTE: we assume here that the lz decoders always decode to RGB32. int stride = 0; diff --git a/common/canvas_utils.h b/common/canvas_utils.h index 1c78ffac..b81a6f91 100644 --- a/common/canvas_utils.h +++ b/common/canvas_utils.h @@ -30,8 +30,14 @@ typedef struct PixmanData { 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); +pixman_format_code_t spice_pixman_image_get_format(pixman_image_t *image); + + #ifdef WIN32 pixman_image_t *surface_create(HDC dc, pixman_format_code_t format, int width, int height, int top_down); |