forcing device into host mode requires a full config - which we will do in opendevice...
[AROS.git] / rom / graphics / gfxfuncsupport.h
blobb112d5d611483e19cf5b81e7f8e6c46fd70cb8ab
1 #ifndef GFXFUNCSUPPORT_H
2 #define GFXFUNCSUPPORT_H
4 /****************************************************************************************/
6 /*
7 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
8 $Id$
9 */
11 /****************************************************************************************/
13 #include <graphics/clip.h>
14 #include <graphics/gfxbase.h>
15 #include <hidd/graphics.h>
17 #define PEN_BITS 8
18 #define NUM_COLORS (1L << PEN_BITS)
19 #define PEN_MASK (NUM_COLORS - 1)
21 #define FIX_GFXCOORD(x) x = (WORD)x
23 /* Our own usage of some private fields in ViewPortExtra */
24 #define VPE_DATA(vpe) ((struct HIDD_ViewPortData *)(vpe)->DriverData[0])
25 #define VPE_DRIVER(vpe) ((struct monitor_driverdata *)(vpe)->DriverData[1])
27 /* Additional private flags in ViewPortExtra */
28 #define VPXF_RELEASE_BITMAP 0x8000
30 /* !!!! ONLY USE THE BELOW MACROS IF YOU ARE 100% SURE
31 THAT IT IS A HIDD BITMAP AND NOT ONE THE USER
32 HAS CREATED BY HAND !!!. You can use IS_HIDD_BM(bitmap) to test
33 if it is a HIDD bitmap
36 #define OBTAIN_HIDD_BM(bitmap) \
37 ( ( IS_HIDD_BM(bitmap)) \
38 ? HIDD_BM_OBJ(bitmap) \
39 : get_planarbm_object((bitmap), GfxBase) )
41 #define RELEASE_HIDD_BM(bm_obj, bitmap) \
42 do \
43 { \
44 if(! IS_HIDD_BM(bitmap)) \
45 release_cache_object(CDD(GfxBase)->planarbm_cache, (bm_obj), GfxBase); \
46 } while (0)
49 #define GET_BM_DEPTH(bitmap) \
50 (IS_HIDD_BM(bitmap) ? HIDD_BM_REALDEPTH(bitmap) : bitmap->Depth)
52 #define GET_BM_DRIVERDATA(bitmap) \
53 ((IS_HIDD_BM(bitmap)) \
54 ? HIDD_BM_DRVDATA(bitmap) \
55 : (struct monitor_driverdata *)CDD(GfxBase))
57 #define GET_BM_MODEID(bitmap) \
58 (HIDD_BM_DRVDATA(bitmap)->id | HIDD_BM_HIDDMODE(bitmap))
60 /* An idea for future Amiga(tm) chipset driver: it should be implemented in
61 architecture-specific part of graphics.hidd. In this case many things will
62 start working automatically */
63 #define GET_VP_DRIVERDATA(vp) \
64 ((vp->ColorMap && vp->ColorMap->NormalDisplayInfo) \
65 ? DIH(vp->ColorMap->NormalDisplayInfo)->drv \
66 : GET_BM_DRIVERDATA(vp->RasInfo->BitMap))
68 #if 0
69 #define BM_PIXEL(bitmap, pen) ((!IS_HIDD_BM(bitmap) || !HIDD_BM_PIXTAB(bitmap)) ? (pen) : \
70 HIDD_BM_PIXTAB(bitmap)[pen])
71 #else
72 #define BM_PIXEL(bitmap, pen) ((!IS_HIDD_BM(bitmap) || !HIDD_BM_COLMAP(bitmap)) ? (pen) : \
73 HIDD_CM_GetPixel(HIDD_BM_COLMAP(bitmap), pen))
74 #endif
76 /* HIDD BM Flags */
78 #define HIDD_BMF_SHARED_PIXTAB 1
79 #define HIDD_BMF_SCREEN_BITMAP 512
81 /* Minterms and GC drawmodes are in opposite order */
82 #define MINTERM_TO_GCDRMD(minterm) \
83 (( ((minterm & 0x80) >> 3) \
84 | ((minterm & 0x40) >> 1) \
85 | ((minterm & 0x20) << 1) \
86 | ((minterm & 0x10) << 3) ) >> 4 )
88 #define TranslateRect(rect, dx, dy) \
89 do \
90 { \
91 struct Rectangle *_rect = rect; \
92 WORD _dx = dx; \
93 WORD _dy = dy; \
94 (_rect)->MinX += (_dx); \
95 (_rect)->MinY += (_dy); \
96 (_rect)->MaxX += (_dx); \
97 (_rect)->MaxY += (_dy); \
98 } while(0)
100 /****************************************************************************************/
102 /* Private Rastport flags */
103 #define RPF_NO_PENS (1L << 14) /* Are pens disabled? */
104 #define RPF_REMAP_COLORFONTS (1L << 13) /* Shall color fonts be automatically remapped? */
106 #define AROS_PALETTE_SIZE 256
107 #define AROS_PALETTE_MEMSIZE (sizeof (HIDDT_Pixel) * AROS_PALETTE_SIZE)
110 * private AROS fields in RastPort struct:
111 * longreserved[0] - pointer to GC class (see oop's _OOP_OBJECT() macro)
112 * longreserved[1] - Enbedded hidd.graphics.gc object starts here
115 #define RP_GC(rp) ((APTR)&((rp)->longreserved[1]))
116 #define RP_FGCOLOR(rp) GC_FG(RP_GC(rp))
117 #define RP_BGCOLOR(rp) GC_BG(RP_GC(rp))
119 /****************************************************************************************/
121 #define LOCK_BLIT ObtainSemaphore(&(PrivGBase(GfxBase)->blit_sema));
122 #define ULOCK_BLIT ReleaseSemaphore(&(PrivGBase(GfxBase)->blit_sema));
124 #define FLG_PALETTE ( 1L << vHidd_ColorModel_Palette )
125 #define FLG_STATICPALETTE ( 1L << vHidd_ColorModel_StaticPalette )
126 #define FLG_TRUECOLOR ( 1L << vHidd_ColorModel_TrueColor )
127 #define FLG_HASCOLMAP ( 1L << num_Hidd_CM )
129 #define GET_COLMOD_FLAGS(bm) (1L << HIDD_BM_COLMOD(bm))
131 /****************************************************************************************/
133 struct render_special_info
135 struct BitMap *curbm;
138 #define RSI(x) ((struct render_special_info *)x)
140 /* A Pointer to this struct is stored in each RastPort->longreserved[0] */
142 struct gfx_driverdata
144 struct RastPort * dd_RastPort; /* This RastPort */
145 struct Rectangle dd_ClipRectangle;
146 UBYTE dd_ClipRectangleFlags;
149 static inline struct gfx_driverdata *ObtainDriverData(struct RastPort *rp)
151 struct gfx_driverdata *dd = rp->RP_Extra;
153 if (dd && dd->dd_RastPort != rp)
155 /* We have detected a cloned rastport. Detach extra data from it. */
156 dd = NULL;
159 return dd;
162 typedef ULONG (*RENDERFUNC)(APTR, WORD, WORD, OOP_Object *, OOP_Object *, struct Rectangle *, struct GfxBase *);
163 typedef LONG (*PIXELFUNC)(APTR, OOP_Object *, OOP_Object *, WORD, WORD, struct GfxBase *);
165 /****************************************************************************************/
167 OOP_Object *get_planarbm_object(struct BitMap *bitmap, struct GfxBase *GfxBase);
169 ULONG do_render_func(struct RastPort *rp, Point *src, struct Rectangle *rr,
170 RENDERFUNC render_func, APTR funcdata,
171 BOOL do_update, BOOL get_special_info, struct GfxBase *GfxBase);
173 ULONG do_render_with_gc(struct RastPort *rp, Point *src, struct Rectangle *rr,
174 RENDERFUNC render_func, APTR funcdata, OOP_Object *gc,
175 BOOL do_update, BOOL get_special_info, struct GfxBase *GfxBase);
177 ULONG do_pixel_func(struct RastPort *rp, WORD x, WORD y,
178 LONG (*render_func)(APTR, OOP_Object *, OOP_Object *, WORD, WORD, struct GfxBase *),
179 APTR funcdata, BOOL do_update, struct GfxBase *GfxBase);
181 ULONG fillrect_render(APTR funcdata, WORD srcx, WORD srcy,
182 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
183 struct Rectangle *rect, struct GfxBase *GfxBase);
185 LONG fillrect_pendrmd(struct RastPort *tp, WORD x1, WORD y1, WORD x2, WORD y2,
186 HIDDT_Pixel pix, HIDDT_DrawMode drmd, BOOL do_update, struct GfxBase *GfxBase);
188 BOOL int_bltbitmap(struct BitMap *srcBitMap, OOP_Object *srcbm_obj, WORD xSrc, WORD ySrc,
189 struct BitMap *dstBitMap, OOP_Object *dstbm_obj, WORD xDest, WORD yDest,
190 WORD xSize, WORD ySize, ULONG minterm, OOP_Object *gfxhidd, OOP_Object *gc,
191 struct GfxBase *GfxBase);
194 LONG write_pixels_8(struct RastPort *rp, UBYTE *array, ULONG modulo,
195 WORD xstart, WORD ystart, WORD xstop, WORD ystop,
196 HIDDT_PixelLUT *pixlut, BOOL do_update, struct GfxBase *GfxBase);
198 LONG write_transp_pixels_8(struct RastPort *rp, UBYTE *array, ULONG modulo,
199 WORD xstart, WORD ystart, WORD xstop, WORD ystop,
200 HIDDT_PixelLUT *pixlut, UBYTE transparent,
201 BOOL do_update, struct GfxBase *GfxBase);
203 void amiga2hidd_fast(APTR src_info, OOP_Object *hidd_gc, WORD x_src , WORD y_src,
204 struct BitMap *hidd_bm, WORD x_dest, WORD y_dest,
205 ULONG xsize, ULONG ysize, VOID (*fillbuf_hook)(),
206 struct GfxBase * GfxBase);
208 BOOL MoveRaster (struct RastPort * rp, WORD dx, WORD dy, WORD x1, WORD y1,
209 WORD x2, WORD y2, BOOL UpdateDamageList, struct GfxBase * GfxBase);
211 BOOL GetRPClipRectangleForRect(struct RastPort *rp, struct Rectangle *rect, struct Rectangle *r);
212 BOOL GetRPClipRectangleForBitMap(struct RastPort *rp, struct BitMap *bm,
213 struct Rectangle *r, struct GfxBase *GfxBase);
215 void update_bitmap(struct BitMap *bitmap, OOP_Object *bm, UWORD x, UWORD y, UWORD width, UWORD height, struct GfxBase *GfxBase);
217 void BltRastPortBitMap(struct RastPort *srcRastPort, WORD xSrc, WORD ySrc,
218 struct BitMap *destBitMap, WORD xDest, WORD yDest,
219 WORD xSize, WORD ySize, ULONG minterm,
220 struct GfxBase *GfxBase);
222 /****************************************************************************************/
224 static inline BOOL GetRPClipRectangleForLayer(struct RastPort *rp, struct Layer *lay, struct Rectangle *r, struct GfxBase *GfxBase)
226 return GetRPClipRectangleForRect(rp, &lay->bounds, r);
229 #endif