New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / graphics / gfxfuncsupport.h
blob54b82e163e973bbfd5eb7418dde65b59ef40e017
1 #ifndef GFXFUNCSUPPORT_H
2 #define GFXFUNCSUPPORT_H
4 /****************************************************************************************/
6 /*
7 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 $Id$
9 */
11 /****************************************************************************************/
13 #include <hidd/graphics.h>
15 #define PEN_BITS 8
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) \
41 do \
42 { \
43 if(! IS_HIDD_BM(bitmap)) \
44 release_cache_object(SDD(GfxBase)->planarbm_cache, (bm_obj), GfxBase); \
45 } while (0)
48 #define IS_HIDD_BM(bitmap) (((bitmap)->Flags & BMF_AROS_HIDD) == BMF_AROS_HIDD)
50 #if 0
51 #define BM_PIXEL(bitmap, pen) ((!IS_HIDD_BM(bitmap) || !HIDD_BM_PIXTAB(bitmap)) ? (pen) : \
52 HIDD_BM_PIXTAB(bitmap)[pen])
53 #else
54 #define BM_PIXEL(bitmap, pen) ((!IS_HIDD_BM(bitmap) || !HIDD_BM_COLMAP(bitmap)) ? (pen) : \
55 HIDD_CM_GetPixel(HIDD_BM_COLMAP(bitmap), pen))
56 #endif
58 /* HIDD BM Flags */
60 #define HIDD_BMF_SHARED_PIXTAB 1
62 /* Minterms and GC drawmodes are in opposite order */
63 #define MINTERM_TO_GCDRMD(minterm) \
64 (( ((minterm & 0x80) >> 3) \
65 | ((minterm & 0x40) >> 1) \
66 | ((minterm & 0x20) << 1) \
67 | ((minterm & 0x10) << 3) ) >> 4 )
69 #define TranslateRect(rect, dx, dy) \
70 do \
71 { \
72 struct Rectangle *_rect = rect; \
73 WORD _dx = dx; \
74 WORD _dy = dy; \
75 (_rect)->MinX += (_dx); \
76 (_rect)->MinY += (_dy); \
77 (_rect)->MaxX += (_dx); \
78 (_rect)->MaxY += (_dy); \
79 } while(0)
81 /* Private Rastport flags */
83 /* Flags that tells whether or not the driver has been inited */
84 #define RPF_DRIVER_INITED (1L << 15)
85 #define RPF_SELF_CLEANUP (1L << 14)
86 /* Shall color fonts be automatically remapped? */
87 #define RPF_REMAP_COLORFONTS (1L << 13)
89 #define AROS_PALETTE_SIZE 256
90 #define AROS_PALETTE_MEMSIZE (sizeof (HIDDT_Pixel) * AROS_PALETTE_SIZE)
92 /* private AROS fields in RastPort struct:
94 driverdata: longreserved[0],longreserved[1]
95 backpointer: wordreserved[0],wordreserved[1],wordreserved[2],wordreserved[3]
96 fgcolor: wordreserved[4],wordreserved[5]
97 bgcolor: wordreserved[6],reserved[0],reserved[1]
98 patoriginx: reserved[2], reserved[3]
99 patoriginy: reserved[4], reserved[5]
101 Pointers above use 8 byte/64 bit, because that's what
102 would be required on AROS 64 bit.
104 Still unused fields:
106 UBYTE reserved[6 .. 7]
110 #define RP_FGCOLOR(rp) (*(ULONG *)&((rp)->wordreserved[4]))
111 #define RP_BGCOLOR(rp) (*(ULONG *)&((rp)->wordreserved[6]))
112 #define RP_PATORIGINX(rp) (*(WORD *)&((rp)->reserved[2]))
113 #define RP_PATORIGINY(rp) (*(WORD *)&((rp)->reserved[4]))
115 #define RP_BACKPOINTER(rp) (*(struct RastPort **)&((rp)->wordreserved[0]))
116 #define RP_DRIVERDATA(rp) (*(struct gfx_driverdata **)&((rp)->longreserved[0]))
117 #define GetDriverData(rp) RP_DRIVERDATA(rp)
119 /* SetDriverData() should only be used when cloning RastPorts */
120 /* For other purposes just change the values directly in the struct. */
121 #define SetDriverData(rp,dd) RP_DRIVERDATA(rp) = dd
123 #define NUMPIX 50000
124 #define PIXELBUF_SIZE (NUMPIX * 4)
126 #define NUMLUTPIX (PIXELBUF_SIZE)
128 #define LOCK_PIXBUF ObtainSemaphore(&(PrivGBase(GfxBase)->pixbuf_sema));
129 #define ULOCK_PIXBUF ReleaseSemaphore(&(PrivGBase(GfxBase)->pixbuf_sema));
131 #define LOCK_BLIT ObtainSemaphore(&(PrivGBase(GfxBase)->blit_sema));
132 #define ULOCK_BLIT ReleaseSemaphore(&(PrivGBase(GfxBase)->blit_sema));
134 #define FLG_PALETTE ( 1L << vHidd_ColorModel_Palette )
135 #define FLG_STATICPALETTE ( 1L << vHidd_ColorModel_StaticPalette )
136 #define FLG_TRUECOLOR ( 1L << vHidd_ColorModel_TrueColor )
137 #define FLG_HASCOLMAP ( 1L << num_Hidd_CM )
139 #define GET_COLMOD_FLAGS(bm) (1L << HIDD_BM_COLMOD(bm))
141 /****************************************************************************************/
143 struct render_special_info
145 struct BitMap *curbm;
146 BOOL onscreen;
147 LONG layer_rel_srcx;
148 LONG layer_rel_srcy;
151 #define RSI(x) ((struct render_special_info *)x)
153 /* A Pointer to this struct is stored in each RastPort->longreserved[0] */
155 struct gfx_driverdata
157 #if 0
158 UWORD * dd_AreaPtrn; /* Amiga current AreaPtrn */
159 BYTE dd_AreaPtSz; /* Amiga AreaPtSz */
160 UWORD dd_LinePtrn; /* Amiga current LinePtrn */
161 #endif
162 struct MinNode dd_Node;
163 OOP_Object * dd_GC;
164 struct RastPort * dd_RastPort; /* This RastPort */
165 struct Rectangle dd_ClipRectangle;
166 WORD dd_LockCount;
167 UBYTE dd_ClipRectangleFlags;
170 /****************************************************************************************/
172 OOP_Object *get_planarbm_object(struct BitMap *bitmap, struct GfxBase *GfxBase);
174 ULONG do_render_func(struct RastPort *rp, Point *src, struct Rectangle *rr,
175 ULONG (*render_func)(APTR, LONG, LONG, OOP_Object *, OOP_Object *, LONG, LONG, LONG, LONG, struct GfxBase *),
176 APTR funcdata, BOOL get_special_info, struct GfxBase *GfxBase);
178 ULONG do_pixel_func(struct RastPort *rp, LONG x, LONG y,
179 LONG (*render_func)(APTR, OOP_Object *, OOP_Object *, LONG, LONG, struct GfxBase *),
180 APTR funcdata, struct GfxBase *GfxBase);
182 LONG fillrect_pendrmd(struct RastPort *tp, LONG x1, LONG y1, LONG x2, LONG y2,
183 HIDDT_Pixel pix, ULONG drmd, struct GfxBase *GfxBase);
185 BOOL int_bltbitmap(struct BitMap *srcBitMap, OOP_Object *srcbm_obj, LONG xSrc, LONG ySrc,
186 struct BitMap *dstBitMap, OOP_Object *dstbm_obj, LONG xDest, LONG yDest,
187 LONG xSize, LONG ySize, ULONG minterm, OOP_Object *gc, struct GfxBase *GfxBase);
190 LONG write_pixels_8(struct RastPort *rp, UBYTE *array, ULONG modulo,
191 LONG xstart, LONG ystart, LONG xstop, LONG ystop,
192 HIDDT_PixelLUT *pixlut, struct GfxBase *GfxBase);
194 LONG write_transp_pixels_8(struct RastPort *rp, UBYTE *array, ULONG modulo,
195 LONG xstart, LONG ystart, LONG xstop, LONG ystop,
196 HIDDT_PixelLUT *pixlut, UBYTE transparent,
197 struct GfxBase *GfxBase);
199 void amiga2hidd_fast(APTR src_info, OOP_Object *hidd_gc, LONG x_src , LONG y_src,
200 struct BitMap *hidd_bm, LONG x_dest, LONG y_dest,
201 ULONG xsize, ULONG ysize, VOID (*fillbuf_hook)(),
202 struct GfxBase * GfxBase);
204 void hidd2buf_fast(struct BitMap *hidd_bm, LONG x_src , LONG y_src, APTR dest_info,
205 LONG x_dest, LONG y_dest, ULONG xsize, ULONG ysize, VOID (*putbuf_hook)(),
206 struct GfxBase * GfxBase);
208 HIDDT_StdPixFmt cyber2hidd_pixfmt(UWORD cpf, struct GfxBase *GfxBase);
210 UWORD hidd2cyber_pixfmt(HIDDT_StdPixFmt stdpf, struct GfxBase *GfxBase);
212 BOOL MoveRaster (struct RastPort * rp, LONG dx, LONG dy, LONG x1, LONG y1,
213 LONG x2, LONG y2, BOOL UpdateDamageList, struct GfxBase * GfxBase);
215 BOOL GetRPClipRectangleForLayer(struct RastPort *rp, struct Layer *lay,
216 struct Rectangle *r, struct GfxBase *GfxBase);
217 BOOL GetRPClipRectangleForBitMap(struct RastPort *rp, struct BitMap *bm,
218 struct Rectangle *r, struct GfxBase *GfxBase);
221 /****************************************************************************************/
223 #endif