Use macros from <spice/macros.h> rather than duplicate them

This commit is contained in:
Alexander Larsson 2010-03-09 11:10:00 +01:00 committed by Marc-André Lureau
parent a64e487d78
commit 29b01c2c16
9 changed files with 19 additions and 75 deletions

View File

@ -23,6 +23,7 @@
#include <math.h>
#include <spice/draw.h>
#include <spice/macros.h>
#include "quic.h"
#include "lz.h"
#include "canvas_base.h"
@ -71,18 +72,6 @@
#define DBG(level, format, ...) printf("%s: debug: " format "\n", __FUNCTION__, ## __VA_ARGS__);
#endif
#ifndef ALIGN
#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
#endif
#ifndef MIN
#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
#endif
#define ROUND(_x) ((int)floor((_x) + 0.5))
#ifdef WIN32
@ -1148,7 +1137,7 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b
src_stride = bitmap->stride;
end_line = src_line + (bitmap->y * src_stride);
access_test(canvas, src_line, end_line - src_line);
line_size = ALIGN(bitmap->x, 8) >> 3;
line_size = SPICE_ALIGN(bitmap->x, 8) >> 3;
dest_stride = pixman_image_get_stride(surface);
dest_line = (uint8_t *)pixman_image_get_data(surface);
@ -1243,7 +1232,7 @@ static inline pixman_image_t *canvas_A1_invers(pixman_image_t *src_surf)
uint8_t *src_line = (uint8_t *)pixman_image_get_data(src_surf);
int src_stride = pixman_image_get_stride(src_surf);
uint8_t *end_line = src_line + (height * src_stride);
int line_size = ALIGN(width, 8) >> 3;
int line_size = SPICE_ALIGN(width, 8) >> 3;
uint8_t *dest_line = (uint8_t *)pixman_image_get_data(invers);
int dest_stride = pixman_image_get_stride(invers);
@ -1382,7 +1371,7 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int
static inline SpiceRasterGlyph *canvas_next_raster_glyph(const SpiceRasterGlyph *glyph, int bpp)
{
return (SpiceRasterGlyph *)((uint8_t *)(glyph + 1) +
(ALIGN(glyph->width * bpp, 8) * glyph->height >> 3));
(SPICE_ALIGN(glyph->width * bpp, 8) * glyph->height >> 3));
}
static inline void canvas_raster_glyph_box(const SpiceRasterGlyph *glyph, SpiceRect *r)
@ -1472,7 +1461,7 @@ static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des
width = glyph_box.right - glyph_box.left;
switch (bpp) {
case 1: {
int src_stride = ALIGN(width, 8) >> 3;
int src_stride = SPICE_ALIGN(width, 8) >> 3;
int i;
src += src_stride * (lines);
@ -1485,7 +1474,7 @@ static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des
}
case 4: {
uint8_t *end;
int src_stride = ALIGN(width * 4, 8) >> 3;
int src_stride = SPICE_ALIGN(width * 4, 8) >> 3;
src += src_stride * lines;
dest += glyph_box.left;

View File

@ -18,6 +18,8 @@
#include "canvas_utils.h"
#include <spice/macros.h>
#ifdef __GNUC__
#include <stdlib.h>
#include <stdio.h>
@ -42,10 +44,6 @@ extern int gdi_handlers;
}
#endif
#ifndef ALIGN
#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
#endif
static void release_data(pixman_image_t *image, void *release_data)
{
PixmanData *data = (PixmanData *)release_data;
@ -154,11 +152,11 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
break;
case PIXMAN_a8:
bitmap_info.inf.bmiHeader.biBitCount = 8;
nstride = ALIGN(width, 4);
nstride = SPICE_ALIGN(width, 4);
break;
case PIXMAN_a1:
bitmap_info.inf.bmiHeader.biBitCount = 1;
nstride = ALIGN(width, 32) / 8;
nstride = SPICE_ALIGN(width, 32) / 8;
break;
default:
CANVAS_ERROR("invalid format");
@ -208,10 +206,10 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
stride = width * 4;
break;
case PIXMAN_a8:
stride = ALIGN(width, 4);
stride = SPICE_ALIGN(width, 4);
break;
case PIXMAN_a1:
stride = ALIGN(width, 32) / 8;
stride = SPICE_ALIGN(width, 32) / 8;
break;
default:
CANVAS_ERROR("invalid format");

View File

@ -24,6 +24,7 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <spice/macros.h>
#include <GL/gl.h>
#include <GL/glu.h>
@ -37,9 +38,6 @@
#include "glc.h"
#include "gl_utils.h"
#define TRUE 1
#define FALSE 0
#define ASSERT(x) if (!(x)) {printf("%s: assert failed %s\n", __FUNCTION__, #x); abort();}
#define WARN_ONCE(x) { \

View File

@ -48,6 +48,7 @@ SOFTWARE.
#include <stdio.h>
#include <spice/macros.h>
#ifdef _XOPEN_SOURCE
#include <math.h>
#else
@ -57,22 +58,6 @@ SOFTWARE.
#endif
#include "lines.h"
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#ifndef MIN
# define MIN(a, b) ((a < b) ? a : b)
#endif
#ifndef MAX
# define MAX(a, b) ((a > b) ? a : b)
#endif
#define xalloc(i) malloc(i)
#define xrealloc(a,b) realloc(a,b)
#define xfree(i) free(i)

View File

@ -22,15 +22,7 @@
#define __LZ_CONFIG_H
#include <spice/types.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#include <spice/macros.h>
#ifdef __GNUC__

View File

@ -17,19 +17,12 @@
*/
#include "pixman_utils.h"
#include <spice/macros.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#ifndef ASSERT
#define ASSERT(x) if (!(x)) { \
printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \

View File

@ -20,6 +20,7 @@
// http://sun.iinf.polsl.gliwice.pl/~rstaros/sfalic/index.html
#include "quic.h"
#include <spice/macros.h>
//#define DEBUG
@ -36,8 +37,6 @@
#define QUIC_VERSION_MINOR 1U
#define QUIC_VERSION ((QUIC_VERSION_MAJOR << 16) | (QUIC_VERSION_MAJOR & 0xffff))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#ifdef DEBUG
#define ASSERT(usr, x) \
@ -49,9 +48,6 @@
#endif
#define FALSE 0
#define TRUE 1
typedef uint8_t BYTE;
/* maximum number of codes in family */

View File

@ -20,9 +20,7 @@
#define _H_RECT
#include <spice/draw.h>
#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
#include <spice/macros.h>
static inline void rect_sect(SpiceRect* r, const SpiceRect* bounds)
{

View File

@ -19,16 +19,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <spice/macros.h>
#include "region.h"
#include "rect.h"
#define FALSE 0
#define TRUE 1
#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
#define ASSERT(x) if (!(x)) { \
printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \
abort(); \