summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2016-01-19 17:07:04 +0100
committerPavel Grunt <pgrunt@redhat.com>2016-01-19 17:07:21 +0100
commit723e50da78b3f8c43ba8b325bb73492021b1fe38 (patch)
treed36d0824f07b2c836030f82f9cc987e5bced0d73
parentb61f43f228950505ef809dccd6a73aefdfd44ce1 (diff)
draw: Add spice_image_descriptor_is_lossylossy_compression
It will be used in the server code
-rw-r--r--common/canvas_base.c12
-rw-r--r--common/draw.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/common/canvas_base.c b/common/canvas_base.c
index d918441..509e0bf 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -47,9 +47,11 @@
#define ROUND(_x) ((int)floor((_x) + 0.5))
-#define IS_IMAGE_LOSSY(descriptor) \
- (((descriptor)->type == SPICE_IMAGE_TYPE_JPEG) || \
- ((descriptor)->type == SPICE_IMAGE_TYPE_JPEG_ALPHA))
+int spice_image_descriptor_is_lossy(const SpiceImageDescriptor *descriptor)
+{
+ return descriptor->type == SPICE_IMAGE_TYPE_JPEG ||
+ descriptor->type == SPICE_IMAGE_TYPE_JPEG_ALPHA;
+}
static inline int fix_to_int(SPICE_FIXED28_4 fixed)
{
@@ -1219,7 +1221,7 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
#endif
descriptor->type != SPICE_IMAGE_TYPE_FROM_CACHE ) {
#ifdef SW_CANVAS_CACHE
- if (!IS_IMAGE_LOSSY(descriptor)) {
+ if (!spice_image_descriptor_is_lossy(descriptor)) {
canvas->bits_cache->ops->put(canvas->bits_cache, descriptor->id, surface);
} else {
canvas->bits_cache->ops->put_lossy(canvas->bits_cache, descriptor->id, surface);
@@ -1232,7 +1234,7 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
#endif
#ifdef SW_CANVAS_CACHE
} else if (descriptor->flags & SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME) {
- if (IS_IMAGE_LOSSY(descriptor)) {
+ if (spice_image_descriptor_is_lossy(descriptor)) {
spice_warning("invalid cache replace request: the image is lossy");
return NULL;
}
diff --git a/common/draw.h b/common/draw.h
index 1155dc5..851a02c 100644
--- a/common/draw.h
+++ b/common/draw.h
@@ -294,6 +294,8 @@ typedef struct SpiceCursorHeader {
uint16_t hot_spot_y;
} SpiceCursorHeader;
+int spice_image_descriptor_is_lossy(const SpiceImageDescriptor *descriptor);
+
SPICE_END_DECLS
#endif /* _H_SPICE_DRAW */