2012-09-20 07:51:34 +04:00
|
|
|
/**
|
|
|
|
* xrdp: A Remote Desktop Protocol server.
|
|
|
|
*
|
2014-03-02 11:26:40 +04:00
|
|
|
* Copyright (C) Jay Sorg 2004-2014
|
2012-09-20 07:51:34 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
* main define/macro file
|
|
|
|
*/
|
2005-06-28 07:04:36 +04:00
|
|
|
|
2010-11-03 18:59:26 +03:00
|
|
|
#ifndef DEFINES_H
|
2005-06-28 07:04:36 +04:00
|
|
|
#define DEFINES_H
|
|
|
|
|
|
|
|
/* check for debug */
|
|
|
|
#ifdef XRDP_DEBUG
|
2006-04-29 05:47:06 +04:00
|
|
|
#define DEBUG(args) g_writeln args;
|
|
|
|
#define LIB_DEBUG(_mod, _text) _mod->server_msg(_mod, _text, 1);
|
2005-06-28 07:04:36 +04:00
|
|
|
#else
|
|
|
|
#define DEBUG(args)
|
2006-04-29 05:47:06 +04:00
|
|
|
#define LIB_DEBUG(_mod, _text)
|
2005-06-28 07:04:36 +04:00
|
|
|
#endif
|
|
|
|
/* other macros */
|
2005-11-07 04:49:19 +03:00
|
|
|
#undef MIN
|
2005-06-28 07:04:36 +04:00
|
|
|
#define MIN(x1, x2) ((x1) < (x2) ? (x1) : (x2))
|
2005-11-07 04:49:19 +03:00
|
|
|
#undef MAX
|
2005-06-28 07:04:36 +04:00
|
|
|
#define MAX(x1, x2) ((x1) > (x2) ? (x1) : (x2))
|
2005-11-07 04:49:19 +03:00
|
|
|
#undef HIWORD
|
2005-06-28 07:04:36 +04:00
|
|
|
#define HIWORD(in) (((in) & 0xffff0000) >> 16)
|
2005-11-07 04:49:19 +03:00
|
|
|
#undef LOWORD
|
2005-06-28 07:04:36 +04:00
|
|
|
#define LOWORD(in) ((in) & 0x0000ffff)
|
2005-11-07 04:49:19 +03:00
|
|
|
#undef MAKELONG
|
|
|
|
#define MAKELONG(lo, hi) ((((hi) & 0xffff) << 16) | ((lo) & 0xffff))
|
2005-06-28 07:04:36 +04:00
|
|
|
#define MAKERECT(r, x, y, cx, cy) \
|
|
|
|
{ (r).left = x; (r).top = y; (r).right = (x) + (cx); (r).bottom = (y) + (cy); }
|
|
|
|
#define ISRECTEMPTY(r) (((r).right <= (r).left) || ((r).bottom <= (r).top))
|
|
|
|
#define RECTOFFSET(r, dx, dy) \
|
|
|
|
{ (r).left += dx; (r).top += dy; (r).right += dx; (r).bottom += dy; }
|
|
|
|
#define GETPIXEL8(d, x, y, w) (*(((unsigned char*)d) + ((y) * (w) + (x))))
|
|
|
|
#define GETPIXEL16(d, x, y, w) (*(((unsigned short*)d) + ((y) * (w) + (x))))
|
|
|
|
#define GETPIXEL32(d, x, y, w) (*(((unsigned int*)d) + ((y) * (w) + (x))))
|
|
|
|
#define SETPIXEL8(d, x, y, w, v) \
|
|
|
|
(*(((unsigned char*)d) + ((y) * (w) + (x))) = (v))
|
|
|
|
#define SETPIXEL16(d, x, y, w, v) \
|
|
|
|
(*(((unsigned short*)d) + ((y) * (w) + (x))) = (v))
|
|
|
|
#define SETPIXEL32(d, x, y, w, v) \
|
2006-07-22 06:11:14 +04:00
|
|
|
(*(((unsigned int*)d) + ((y) * (w) + (x))) = (v))
|
2005-06-28 07:04:36 +04:00
|
|
|
#define COLOR8(r, g, b) \
|
|
|
|
( \
|
|
|
|
(((r) >> 5) << 0) | \
|
|
|
|
(((g) >> 5) << 3) | \
|
|
|
|
(((b) >> 6) << 6) \
|
|
|
|
)
|
|
|
|
#define COLOR15(r, g, b) ((((r) >> 3) << 10) | (((g) >> 3) << 5) | ((b) >> 3))
|
|
|
|
#define COLOR16(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
|
2007-04-28 22:23:08 +04:00
|
|
|
#define COLOR24RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
|
|
|
|
#define COLOR24BGR(r, g, b) (((b) << 16) | ((g) << 8) | (r))
|
2010-11-19 22:18:15 +03:00
|
|
|
#define HRED(c) ((c & 0xff0000) >> 16)
|
|
|
|
#define HGREEN(c) ((c & 0x00ff00) >> 8)
|
|
|
|
#define HBLUE(c) ((c & 0x0000ff))
|
|
|
|
#define HCOLOR(bpp,c) \
|
|
|
|
( \
|
|
|
|
(bpp==8?COLOR8(HRED(c),HGREEN(c),HBLUE(c)): \
|
|
|
|
(bpp==15?COLOR15(HRED(c),HGREEN(c),HBLUE(c)): \
|
|
|
|
(bpp==16?COLOR16(HRED(c),HGREEN(c),HBLUE(c)): \
|
2014-06-11 03:58:25 +04:00
|
|
|
(bpp>=24?COLOR24BGR(HRED(c),HGREEN(c),HBLUE(c)):c) \
|
2010-11-19 22:18:15 +03:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
2005-11-10 07:38:39 +03:00
|
|
|
#define SPLITCOLOR15(r, g, b, c) \
|
|
|
|
{ \
|
|
|
|
r = (((c) >> 7) & 0xf8) | (((c) >> 12) & 0x7); \
|
|
|
|
g = (((c) >> 2) & 0xf8) | (((c) >> 8) & 0x7); \
|
|
|
|
b = (((c) << 3) & 0xf8) | (((c) >> 2) & 0x7); \
|
|
|
|
}
|
|
|
|
#define SPLITCOLOR16(r, g, b, c) \
|
|
|
|
{ \
|
|
|
|
r = (((c) >> 8) & 0xf8) | (((c) >> 13) & 0x7); \
|
|
|
|
g = (((c) >> 3) & 0xfc) | (((c) >> 9) & 0x3); \
|
|
|
|
b = (((c) << 3) & 0xf8) | (((c) >> 2) & 0x7); \
|
|
|
|
}
|
2005-11-09 05:29:08 +03:00
|
|
|
#define SPLITCOLOR32(r, g, b, c) \
|
|
|
|
{ \
|
2005-11-10 07:38:39 +03:00
|
|
|
r = ((c) >> 16) & 0xff; \
|
|
|
|
g = ((c) >> 8) & 0xff; \
|
|
|
|
b = (c) & 0xff; \
|
2005-11-09 05:29:08 +03:00
|
|
|
}
|
2005-06-28 07:04:36 +04:00
|
|
|
/* font macros */
|
2005-11-10 07:38:39 +03:00
|
|
|
#define FONT_DATASIZE(f) \
|
|
|
|
((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3);
|
2005-06-28 07:04:36 +04:00
|
|
|
/* use crc for bitmap cache lookups */
|
|
|
|
#define USE_CRC
|
|
|
|
|
2014-06-11 03:58:25 +04:00
|
|
|
#define XR_RGB2BGR(a_ulColor) \
|
|
|
|
(a_ulColor & 0xFF000000) | \
|
|
|
|
((a_ulColor & 0x00FF0000) >> 16) | \
|
|
|
|
(a_ulColor & 0x0000FF00) | \
|
|
|
|
((a_ulColor & 0x000000FF) << 16)
|
|
|
|
|
2005-06-28 07:04:36 +04:00
|
|
|
#endif
|