1 #ifndef GFXFUNCSUPPORT_H
2 #define GFXFUNCSUPPORT_H
4 /****************************************************************************************/
7 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
11 /****************************************************************************************/
13 #include <hidd/graphics.h>
16 #define NUM_COLORS (1L << PEN_BITS)
17 #define PEN_MASK (NUM_COLORS - 1)
19 #define FIX_GFXCOORD(x) x = (WORD)x
21 /* !!!! ONLY USE THE BELOW MACROS IF YOU ARE 100% SURE
22 THAT IT IS A HIDD BITMAP AND NOT ONE THE USER
23 HAS CREATED BY HAND !!!. You can use IS_HIDD_BM(bitmap) to test
24 if it is a HIDD bitmap
27 #define HIDD_BM_OBJ(bitmap) (*(OOP_Object **)&((bitmap)->Planes[0]))
28 #define HIDD_BM_COLMAP(bitmap) (*(OOP_Object **)&((bitmap)->Planes[2]))
29 #define HIDD_BM_COLMOD(bitmap) (*(HIDDT_ColorModel *)&((bitmap)->Planes[3]))
30 #define HIDD_BM_PIXTAB(bitmap) (*(HIDDT_Pixel **)&((bitmap)->Planes[4]))
31 #define HIDD_BM_REALDEPTH(bitmap) (*(LONG *)&((bitmap)->Planes[5]))
32 #define HIDD_BM_FLAGS(bitmap) (*(ULONG *)&((bitmap)->Planes[6]))
33 #define HIDD_BM_HIDDMODE(bitmap) (*(ULONG *)&((bitmap)->Planes[7]))
35 #define OBTAIN_HIDD_BM(bitmap) \
36 ( ( IS_HIDD_BM(bitmap)) \
37 ? HIDD_BM_OBJ(bitmap) \
38 : get_planarbm_object((bitmap), GfxBase) )
40 #define RELEASE_HIDD_BM(bm_obj, bitmap) \
43 if(! IS_HIDD_BM(bitmap)) \
44 release_cache_object(SDD(GfxBase)->planarbm_cache, (bm_obj), GfxBase); \
48 #define IS_HIDD_BM(bitmap) (((bitmap)->Flags & BMF_AROS_HIDD) == BMF_AROS_HIDD)
51 #define BM_PIXEL(bitmap, pen) ((!IS_HIDD_BM(bitmap) || !HIDD_BM_PIXTAB(bitmap)) ? (pen) : \
52 HIDD_BM_PIXTAB(bitmap)[pen])
54 #define BM_PIXEL(bitmap, pen) ((!IS_HIDD_BM(bitmap) || !HIDD_BM_COLMAP(bitmap)) ? (pen) : \
55 HIDD_CM_GetPixel(HIDD_BM_COLMAP(bitmap), pen))
60 #define HIDD_BMF_SHARED_PIXTAB 1
61 #define HIDD_BMF_SCREEN_BITMAP 512 /* Must not conflict with BMF_ flags! */
63 /* Minterms and GC drawmodes are in opposite order */
64 #define MINTERM_TO_GCDRMD(minterm) \
65 (( ((minterm & 0x80) >> 3) \
66 | ((minterm & 0x40) >> 1) \
67 | ((minterm & 0x20) << 1) \
68 | ((minterm & 0x10) << 3) ) >> 4 )
70 #define TranslateRect(rect, dx, dy) \
73 struct Rectangle *_rect = rect; \
76 (_rect)->MinX += (_dx); \
77 (_rect)->MinY += (_dy); \
78 (_rect)->MaxX += (_dx); \
79 (_rect)->MaxY += (_dy); \
82 /* Private Rastport flags */
84 /* Flags that tells whether or not the driver has been inited */
85 #define RPF_DRIVER_INITED (1L << 15)
86 #define RPF_SELF_CLEANUP (1L << 14)
87 /* Shall color fonts be automatically remapped? */
88 #define RPF_REMAP_COLORFONTS (1L << 13)
90 #define AROS_PALETTE_SIZE 256
91 #define AROS_PALETTE_MEMSIZE (sizeof (HIDDT_Pixel) * AROS_PALETTE_SIZE)
93 /* private AROS fields in RastPort struct:
95 driverdata: longreserved[0],longreserved[1]
96 backpointer: wordreserved[0],wordreserved[1],wordreserved[2],wordreserved[3]
97 fgcolor: wordreserved[4],wordreserved[5]
98 bgcolor: wordreserved[6],reserved[0],reserved[1]
99 patoriginx: reserved[2], reserved[3]
100 patoriginy: reserved[4], reserved[5]
102 Pointers above use 8 byte/64 bit, because that's what
103 would be required on AROS 64 bit.
107 UBYTE reserved[6 .. 7]
111 #define RP_FGCOLOR(rp) (*(ULONG *)&((rp)->wordreserved[4]))
112 #define RP_BGCOLOR(rp) (*(ULONG *)&((rp)->wordreserved[6]))
113 #define RP_PATORIGINX(rp) (*(WORD *)&((rp)->reserved[2]))
114 #define RP_PATORIGINY(rp) (*(WORD *)&((rp)->reserved[4]))
116 #define RP_BACKPOINTER(rp) (*(struct RastPort **)&((rp)->wordreserved[0]))
117 #define RP_DRIVERDATA(rp) (*(struct gfx_driverdata **)&((rp)->longreserved[0]))
118 #define GetDriverData(rp) RP_DRIVERDATA(rp)
120 /* SetDriverData() should only be used when cloning RastPorts */
121 /* For other purposes just change the values directly in the struct. */
122 #define SetDriverData(rp,dd) RP_DRIVERDATA(rp) = dd
125 #define PIXELBUF_SIZE (NUMPIX * 4)
127 #define NUMLUTPIX (PIXELBUF_SIZE)
129 #define LOCK_PIXBUF ObtainSemaphore(&(PrivGBase(GfxBase)->pixbuf_sema));
130 #define ULOCK_PIXBUF ReleaseSemaphore(&(PrivGBase(GfxBase)->pixbuf_sema));
132 #define LOCK_BLIT ObtainSemaphore(&(PrivGBase(GfxBase)->blit_sema));
133 #define ULOCK_BLIT ReleaseSemaphore(&(PrivGBase(GfxBase)->blit_sema));
135 #define FLG_PALETTE ( 1L << vHidd_ColorModel_Palette )
136 #define FLG_STATICPALETTE ( 1L << vHidd_ColorModel_StaticPalette )
137 #define FLG_TRUECOLOR ( 1L << vHidd_ColorModel_TrueColor )
138 #define FLG_HASCOLMAP ( 1L << num_Hidd_CM )
140 #define GET_COLMOD_FLAGS(bm) (1L << HIDD_BM_COLMOD(bm))
142 /****************************************************************************************/
144 struct render_special_info
146 struct BitMap
*curbm
;
152 #define RSI(x) ((struct render_special_info *)x)
154 /* A Pointer to this struct is stored in each RastPort->longreserved[0] */
156 struct gfx_driverdata
159 UWORD
* dd_AreaPtrn
; /* Amiga current AreaPtrn */
160 BYTE dd_AreaPtSz
; /* Amiga AreaPtSz */
161 UWORD dd_LinePtrn
; /* Amiga current LinePtrn */
163 struct MinNode dd_Node
;
165 struct RastPort
* dd_RastPort
; /* This RastPort */
166 struct Rectangle dd_ClipRectangle
;
168 UBYTE dd_ClipRectangleFlags
;
171 /****************************************************************************************/
173 OOP_Object
*get_planarbm_object(struct BitMap
*bitmap
, struct GfxBase
*GfxBase
);
175 ULONG
do_render_func(struct RastPort
*rp
, Point
*src
, struct Rectangle
*rr
,
176 ULONG (*render_func
)(APTR
, LONG
, LONG
, OOP_Object
*, OOP_Object
*, LONG
, LONG
, LONG
, LONG
, struct GfxBase
*),
177 APTR funcdata
, BOOL get_special_info
, struct GfxBase
*GfxBase
);
179 ULONG
do_pixel_func(struct RastPort
*rp
, LONG x
, LONG y
,
180 LONG (*render_func
)(APTR
, OOP_Object
*, OOP_Object
*, LONG
, LONG
, struct GfxBase
*),
181 APTR funcdata
, struct GfxBase
*GfxBase
);
183 LONG
fillrect_pendrmd(struct RastPort
*tp
, LONG x1
, LONG y1
, LONG x2
, LONG y2
,
184 HIDDT_Pixel pix
, HIDDT_DrawMode drmd
, struct GfxBase
*GfxBase
);
186 BOOL
int_bltbitmap(struct BitMap
*srcBitMap
, OOP_Object
*srcbm_obj
, LONG xSrc
, LONG ySrc
,
187 struct BitMap
*dstBitMap
, OOP_Object
*dstbm_obj
, LONG xDest
, LONG yDest
,
188 LONG xSize
, LONG ySize
, ULONG minterm
, OOP_Object
*gc
, struct GfxBase
*GfxBase
);
191 LONG
write_pixels_8(struct RastPort
*rp
, UBYTE
*array
, ULONG modulo
,
192 LONG xstart
, LONG ystart
, LONG xstop
, LONG ystop
,
193 HIDDT_PixelLUT
*pixlut
, struct GfxBase
*GfxBase
);
195 LONG
write_transp_pixels_8(struct RastPort
*rp
, UBYTE
*array
, ULONG modulo
,
196 LONG xstart
, LONG ystart
, LONG xstop
, LONG ystop
,
197 HIDDT_PixelLUT
*pixlut
, UBYTE transparent
,
198 struct GfxBase
*GfxBase
);
200 void amiga2hidd_fast(APTR src_info
, OOP_Object
*hidd_gc
, LONG x_src
, LONG y_src
,
201 struct BitMap
*hidd_bm
, LONG x_dest
, LONG y_dest
,
202 ULONG xsize
, ULONG ysize
, VOID (*fillbuf_hook
)(),
203 struct GfxBase
* GfxBase
);
205 void hidd2buf_fast(struct BitMap
*hidd_bm
, LONG x_src
, LONG y_src
, APTR dest_info
,
206 LONG x_dest
, LONG y_dest
, ULONG xsize
, ULONG ysize
, VOID (*putbuf_hook
)(),
207 struct GfxBase
* GfxBase
);
209 HIDDT_StdPixFmt
cyber2hidd_pixfmt(UWORD cpf
, struct GfxBase
*GfxBase
);
211 UWORD
hidd2cyber_pixfmt(HIDDT_StdPixFmt stdpf
, struct GfxBase
*GfxBase
);
213 BOOL
MoveRaster (struct RastPort
* rp
, LONG dx
, LONG dy
, LONG x1
, LONG y1
,
214 LONG x2
, LONG y2
, BOOL UpdateDamageList
, struct GfxBase
* GfxBase
);
216 BOOL
GetRPClipRectangleForLayer(struct RastPort
*rp
, struct Layer
*lay
,
217 struct Rectangle
*r
, struct GfxBase
*GfxBase
);
218 BOOL
GetRPClipRectangleForBitMap(struct RastPort
*rp
, struct BitMap
*bm
,
219 struct Rectangle
*r
, struct GfxBase
*GfxBase
);
222 /****************************************************************************************/