Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. typedef unsigned int color_t;
  3.  
  4. typedef struct
  5. {
  6.   int x;
  7.   int y;
  8. }pt_t;
  9.  
  10. /***********               Clipping             **********/
  11.  
  12. typedef struct
  13. {
  14.   int xmin;
  15.   int ymin;
  16.   int xmax;
  17.   int ymax;
  18. }clip_t, *PTRclip;
  19.  
  20. #define CLIP_TOP          1
  21. #define CLIP_BOTTOM       2
  22. #define CLIP_RIGHT        4
  23. #define CLIP_LEFT         8
  24.  
  25. int LineClip ( clip_t *clip, int *x1, int *y1, int *x2, int *y2 );
  26.  
  27. int BlockClip( clip_t *clip, int *x1, int *y1, int *x2, int* y2 );
  28.  
  29. /***********               Brushes             ***********/
  30.  
  31. typedef struct
  32. {
  33.   color_t bkcolor;
  34.   color_t fcolor;
  35.   union {
  36.     u32_t bmp[2];
  37.     u8_t  bits[8];
  38.   };
  39. }brush_t;
  40.  
  41. #define HS_HORIZONTAL     0
  42. #define HS_VERTICAL       1
  43. #define HS_FDIAGONAL      2
  44. #define HS_BDIAGONAL      3
  45. #define HS_CROSS          4
  46. #define HS_DIAGCROSS      5
  47.  
  48.  
  49. #define HATCH_MAX         7
  50.  
  51. brush_t* CreateHatch(int hatch, color_t bkcolor, color_t fcolor);
  52.  
  53. void     DestroyBrush(brush_t *brush);
  54.  
  55. /***********         Pixmap & drawing          ***********/
  56.  
  57. typedef struct
  58. {
  59.   unsigned  width;
  60.   unsigned  height;
  61.   u32_t     format;
  62.   u32_t     flags;
  63.   unsigned  pitch;
  64.   void      *mapped;
  65.   u32_t     handle;
  66. }pixmap_t;
  67.  
  68. #define  PX_MEM_SYSTEM    0
  69. #define  PX_MEM_LOCAL     1
  70. #define  PX_MEM_GART      2
  71.  
  72. #define  PX_MEM_MASK      3
  73.  
  74. #define  PX_LOCK          1
  75.  
  76. pixmap_t* CreatePixmap(unsigned width, unsigned height, u32_t format, u32_t flags);
  77.  
  78. void* LockPixmap(pixmap_t *pixmap);
  79.  
  80. int UnlockPixmap(pixmap_t *pixmap);
  81.  
  82. int DrawRect(pixmap_t *pixmap, int xorg, int yorg,
  83.              int width, int height,
  84.              color_t dst_color, color_t border);
  85.  
  86. int FillRect(pixmap_t *pixmap, int xorg, int yorg,
  87.                int width, int height,
  88.                brush_t *brush, color_t border);
  89.  
  90. //int PixBlit(pixblit_t* blit);
  91.  
  92. /********          Hardware accelerated          *********/
  93.  
  94. typedef struct
  95. {
  96.   pixmap_t  *dstpix;
  97.  
  98.   struct {
  99.     int x0;
  100.     int y0;
  101.   };
  102.   union {
  103.     struct {
  104.       int x1;
  105.       int y1;
  106.     };
  107.     struct {
  108.       int w;
  109.       int h;
  110.     };
  111.   };
  112.   color_t color;
  113.   color_t border;
  114. }draw_t;
  115.  
  116. typedef struct
  117. {
  118.   pixmap_t  *dstpix;
  119.  
  120.   int x;
  121.   int y;
  122.   int w;
  123.   int h;
  124.  
  125.   color_t bkcolor;
  126.   color_t fcolor;
  127.  
  128.   u32_t   bmp0;
  129.   u32_t   bmp1;
  130.   color_t border;
  131. }fill_t;
  132.  
  133. typedef struct
  134. {
  135.   int src_x;
  136.   int src_y;
  137.   int dst_x;
  138.   int dst_y;
  139.   int w;
  140.   int h;
  141. }blit_t;
  142.  
  143. typedef struct
  144. {
  145.   pixmap_t  *dst_pixmap;
  146.   int        dst_x;
  147.   int        dst_y;
  148.  
  149.   pixmap_t  *src_pixmap;
  150.   int        src_x;
  151.   int        src_y;
  152.   int        w;
  153.   int        h;
  154. }pxblit_t;
  155.  
  156. #define PX_CREATE              1
  157. #define PX_DESTROY             2
  158. #define PX_CLEAR               3
  159. #define PX_DRAW_RECT           4
  160. #define PX_FILL_RECT           5
  161. #define PX_LINE                6
  162. #define PX_BLIT                7
  163. #define PX_BLIT_TRANSPARENT    8
  164. #define PX_BLIT_ALPHA          9
  165.  
  166. /*********************************************************/
  167.  
  168. #define DBG(x) x
  169. //  #define DBG(x)
  170.  
  171. #pragma pack (push,1)
  172. typedef struct s_cursor
  173. {
  174.    u32_t   magic;                           // 'CURS'
  175.    void    (*destroy)(struct s_cursor*);    // destructor
  176.    u32_t   fd;                              // next object in list
  177.    u32_t   bk;                              // prev object in list
  178.    u32_t   pid;                             // owner id
  179.  
  180.    void    *base;                            // allocated memory
  181.    u32_t   hot_x;                           // hotspot coords
  182.    u32_t   hot_y;
  183. }cursor_t;
  184. #pragma pack (pop)
  185.  
  186.  
  187. typedef struct {
  188.     u32_t x ;
  189.     u32_t y ;
  190. } xPointFixed;
  191.  
  192. typedef u32_t   xFixed_16_16;
  193.  
  194. typedef xFixed_16_16  xFixed;
  195.  
  196. #define XFIXED_BITS 16
  197.  
  198. #define xFixedToInt(f)  (int) ((f) >> XFIXED_BITS)
  199. #define IntToxFixed(i)  ((xFixed) (i) << XFIXED_BITS)
  200.  
  201. #define xFixedToFloat(f) (((float) (f)) / 65536)
  202.  
  203. #define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) |  \
  204.                                          ((type) << 16) | \
  205.                                          ((a) << 12) | \
  206.                                          ((r) << 8) | \
  207.                                          ((g) << 4) | \
  208.                                          ((b)))
  209.  
  210. #define PICT_FORMAT_A(f)  (((f) >> 12) & 0x0f)
  211. #define PICT_FORMAT_RGB(f)  (((f)      ) & 0xfff)
  212.  
  213. #define PICT_TYPE_OTHER 0
  214. #define PICT_TYPE_A     1
  215. #define PICT_TYPE_ARGB  2
  216. #define PICT_TYPE_ABGR  3
  217. #define PICT_TYPE_COLOR 4
  218. #define PICT_TYPE_GRAY  5
  219.  
  220. typedef enum _PictFormatShort {
  221.    PICT_a8r8g8b8 =      PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8),
  222.    PICT_x8r8g8b8 =      PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8),
  223.    PICT_a8b8g8r8 =      PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8),
  224.    PICT_x8b8g8r8 =      PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8),
  225.  
  226. /* 24bpp formats */
  227.    PICT_r8g8b8 =        PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8),
  228.    PICT_b8g8r8 =        PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8),
  229.  
  230. /* 16bpp formats */
  231.    PICT_r5g6b5 =        PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5),
  232.    PICT_b5g6r5 =        PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5),
  233.  
  234.    PICT_a1r5g5b5 =      PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5),
  235.    PICT_x1r5g5b5 =      PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5),
  236.    PICT_a1b5g5r5 =      PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5),
  237.    PICT_x1b5g5r5 =      PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5),
  238.    PICT_a4r4g4b4 =      PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4),
  239.    PICT_x4r4g4b4 =      PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4),
  240.    PICT_a4b4g4r4 =      PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4),
  241.    PICT_x4b4g4r4 =      PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4),
  242.  
  243. /* 8bpp formats */
  244.    PICT_a8 =            PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0),
  245.    PICT_r3g3b2 =        PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2),
  246.    PICT_b2g3r3 =        PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2),
  247.    PICT_a2r2g2b2 =      PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2),
  248.    PICT_a2b2g2r2 =      PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2),
  249.  
  250.    PICT_c8 =            PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0),
  251.    PICT_g8 =            PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0),
  252.  
  253.    PICT_x4a4 =          PICT_FORMAT(8,PICT_TYPE_A,4,0,0,0),
  254.  
  255.    PICT_x4c4 =          PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0),
  256.    PICT_x4g4 =          PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0),
  257.  
  258. /* 4bpp formats */
  259.    PICT_a4 =            PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0),
  260.    PICT_r1g2b1 =        PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1),
  261.    PICT_b1g2r1 =        PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1),
  262.    PICT_a1r1g1b1 =      PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1),
  263.    PICT_a1b1g1r1 =      PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1),
  264.  
  265.    PICT_c4 =            PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0),
  266.    PICT_g4 =            PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0),
  267.  
  268. /* 1bpp formats */
  269.    PICT_a1 =            PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0),
  270.  
  271.    PICT_g1 =            PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0),
  272. } PictFormatShort;
  273.  
  274. void dump_mem();
  275.  
  276.  
  277.  
  278.