Re: [PATCH spice-common] draw: Add spice_image_descriptor_is_lossy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> It will be used in the server code
> ---
>  common/canvas_base.c | 12 +++++++-----
>  common/draw.h        |  2 ++
>  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 */

Patch looks good.

Perhaps it's me that I'm optimization-olic but I would use a static inline
function in the header file.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]