1 #ifndef GRAPHICS_INTERN_H
2 #define GRAPHICS_INTERN_H
4 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
7 Desc: Internal header file for graphics.library
11 #ifndef AROS_LIBCALL_H
12 # include <aros/libcall.h>
14 #ifndef EXEC_EXECBASE_H
15 # include <exec/execbase.h>
18 # include <exec/lists.h>
21 # include <exec/nodes.h>
23 #ifndef EXEC_SEMAPHORE_H
24 # include <exec/semaphores.h>
26 #ifndef GRAPHICS_GFXBASE_H
27 # include <graphics/gfxbase.h>
29 #ifndef GRAPHICS_TEXT_H
30 # include <graphics/text.h>
32 #ifndef GRAPHICS_RASTPORT_H
33 # include <graphics/rastport.h>
35 #ifndef GRAPHICS_REGIONS_H
36 # include <graphics/regions.h>
41 #ifndef GRAPHICS_VIEW_H
42 # include <graphics/view.h>
44 #ifndef HIDD_GRAPHICS_H
45 # include <hidd/graphics.h>
48 #include <exec/memory.h>
49 #include <proto/exec.h>
50 #include <graphics/scale.h>
51 #include "fontsupport.h"
54 #define REGIONS_USE_MEMPOOL 1
56 /* Setting BMDEPTH_COMPATIBILITY to 1 will cause bitmap->Depth
57 to be never bigger than 8. The same seems to be the case under
58 AmigaOS with CyberGraphX/Picasso96. GetBitMapAttr() OTOH will
59 actually return the real depth. */
61 #define BMDEPTH_COMPATIBILITY 1
63 /* New driverdata code (driverdata is gfx driver stuff connected
64 to rastports, ie. a GC object) which is prepared for garbage
65 collection. Really need this, as relying on all rastports
66 to be un-initialized with AROS specific DeinitRastPort() just
67 will not work. Best example: 68k binaries, if we should ever
68 have some kind of 68k emu */
70 #define NEW_DRIVERDATA_CODE 0
72 #if NEW_DRIVERDATA_CODE
73 #define OBTAIN_DRIVERDATA(rp,libbase) ObtainDriverData(rp, libbase)
74 #define RELEASE_DRIVERDATA(rp,libbase) ReleaseDriverData(rp, libbase)
75 #define KILL_DRIVERDATA(rp,libbase) KillDriverData(rp, libbase)
77 #define OBTAIN_DRIVERDATA(rp,libbase) obsolete_CorrectDriverData(rp, libbase)
78 #define RELEASE_DRIVERDATA(rp,libbase)
79 #define KILL_DRIVERDATA(rp,libbase)
82 #define SIZERECTBUF 128
84 struct RegionRectangleExt
86 struct RegionRectangle RR
;
90 struct RegionRectangleExtChunk
92 struct RegionRectangleExt Rects
[SIZERECTBUF
];
93 struct RegionRectangleExtChunk
*FirstChunk
;
96 #define RRE(x) ((struct RegionRectangleExt *)(x))
97 #define Counter(x) (RRE(x)->Counter)
98 #define Chunk(x) ((x) ? ((struct RegionRectangleExtChunk *)&RRE(x)[-Counter(x)]) : NULL)
100 /* PaletteExtra internals */
102 typedef WORD PalExtra_RefCnt_Type
;
103 typedef WORD PalExtra_AllocList_Type
;
105 #define PALEXTRA_REFCNT(pe,n) (((PalExtra_RefCnt_Type *)(pe)->pe_RefCnt)[(n)])
106 #define PALEXTRA_ALLOCLIST(pe,n) (((PalExtra_AllocList_Type *)(pe)->pe_AllocList)[(n)])
108 struct class_static_data
110 struct GfxBase
*gfxbase
;
112 OOP_AttrBase hiddFakeFBAttrBase
;
114 OOP_Class
*fakegfxclass
;
115 OOP_Class
*fakefbclass
;
116 OOP_Class
*fakedbmclass
;
118 OOP_Object
*fakegfxobj
;
121 struct shared_driverdata
124 OOP_Object
*gfxhidd_orig
;
125 OOP_Object
*gfxhidd_fake
;
127 ObjectCache
*gc_cache
;
128 ObjectCache
*planarbm_cache
;
130 OOP_Object
*framebuffer
;
133 OOP_Object
*colmap_bak
;
134 HIDDT_ColorModel colmod_bak
;
136 OOP_AttrBase hiddBitMapAttrBase
;
137 OOP_AttrBase hiddGCAttrBase
;
138 OOP_AttrBase hiddSyncAttrBase
;
139 OOP_AttrBase hiddPixFmtAttrBase
;
140 OOP_AttrBase hiddPlanarBMAttrBase
;
141 OOP_AttrBase hiddGfxAttrBase
;
142 OOP_AttrBase hiddFakeGfxHiddAttrBase
;
143 OOP_MethodID hiddGfxShowImminentReset_MethodID
;
145 /* The frontmost screen's bitmap */
146 struct BitMap
*frontbm
;
148 /* Does the gfx hidd support hardware pointers ? */
151 /* This is used if the gfx hidd does not support hardware mouse pointers */
152 OOP_Object
*pointerbm
;
156 struct class_static_data fakegfx_staticdata
;
160 /* Has the code to handle active screens been activated ? */
161 BOOL activescreen_inited
;
163 APTR dispinfo_db
; /* Display info database */
166 #define SDD(base) ((struct shared_driverdata *)&PrivGBase(base)->shared_driverdata)
167 #define __IHidd_BitMap SDD(GfxBase)->hiddBitMapAttrBase
168 #define __IHidd_GC SDD(GfxBase)->hiddGCAttrBase
169 #define __IHidd_Sync SDD(GfxBase)->hiddSyncAttrBase
170 #define __IHidd_PixFmt SDD(GfxBase)->hiddPixFmtAttrBase
171 #define __IHidd_PlanarBM SDD(GfxBase)->hiddPlanarBMAttrBase
172 #define __IHidd_Gfx SDD(GfxBase)->hiddGfxAttrBase
173 #define __IHidd_FakeGfxHidd SDD(GfxBase)->hiddFakeGfxHiddAttrBase
176 #define DRIVERDATALIST_HASHSIZE 256
178 /* Internal GFXBase struct */
179 struct GfxBase_intern
181 struct GfxBase gfxbase
;
184 /* Driver data shared between all rastports (allocated once) */
185 struct shared_driverdata shared_driverdata
;
188 #define TFE_HASHTABSIZE 16 /* This MUST be a power of two */
190 struct tfe_hashnode
* tfe_hashtab
[TFE_HASHTABSIZE
];
191 struct SignalSemaphore tfe_hashtab_sema
;
192 struct SignalSemaphore fontsem
;
193 #if REGIONS_USE_MEMPOOL
194 struct SignalSemaphore regionsem
;
196 struct MinList ChunkPoolList
;
198 struct SignalSemaphore driverdatasem
;
200 struct MinList driverdatalist
[DRIVERDATALIST_HASHSIZE
];
201 ULONG
*pixel_buf
; // used in graphics_driver
202 struct SignalSemaphore pixbuf_sema
;
203 struct SignalSemaphore blit_sema
;
209 #define PrivGBase(x) ((struct GfxBase_intern *)x)
211 #define WIDTH_TO_BYTES(width) ((( (width) + 15) & ~15) >> 3)
212 #define WIDTH_TO_WORDS(width) ((( (width) + 15) & ~15) >> 4)
214 #define XCOORD_TO_BYTEIDX( x ) (( x ) >> 3)
215 #define XCOORD_TO_WORDIDX( x ) (( x ) >> 4)
217 #define COORD_TO_BYTEIDX(x, y, bytes_per_row) \
218 ( ( ((LONG)(y)) * (bytes_per_row)) + XCOORD_TO_BYTEIDX(x))
220 #define CHUNKY8_COORD_TO_BYTEIDX(x, y, bytes_per_row) \
221 ( ( ((LONG)(y)) * (bytes_per_row)) + (x) )
223 #define XCOORD_TO_MASK(x) (128L >> ((x) & 0x07))
225 /* For vsprite sorting */
227 #define JOIN_XY_COORDS(x,y) (LONG)( ( ((UWORD)(y)) << 16) + ( ( ((UWORD)(x)) + 0x8000 ) & 0xFFFF ) )
230 #define BMT_STANDARD 0x0000 /* Standard bitmap */
231 #define BMT_RGB 0x1234 /* RTG Bitmap. 24bit RGB chunky */
232 #define BMT_RGBA 0x1238 /* RTG Bitmap. 32bit RGBA chunky */
233 #define BMT_DRIVER 0x8000 /* Special RTG bitmap.
234 Use this as an offset. */
236 #define TFE(tfe) (*(struct TextFontExtension**)&tfe)
238 #define TFE_MATCHWORD 0xDFE7 /* randomly invented */
240 /* Defines for flags in areainfo->FlagPtr */
242 #define AREAINFOFLAG_MOVE 0x00
243 #define AREAINFOFLAG_DRAW 0x01
244 #define AREAINFOFLAG_CLOSEDRAW 0x02
245 #define AREAINFOFLAG_ELLIPSE 0x03
247 /* Forward declaration */
250 /* a function needed by GfxAssocate(), GfxLookUp(), GfxFree() */
251 extern ULONG
CalcHashIndex(ULONG n
);
253 BOOL
obsolete_CorrectDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
254 #if NEW_DRIVERDATA_CODE
255 BOOL
ObtainDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
256 void ReleaseDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
257 void KillDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
260 /* a function needed by ClipBlit */
261 void internal_ClipBlit(struct RastPort
* srcRP
,
264 struct RastPort
* destRP
,
270 struct GfxBase
* GfxBase
);
272 /* Driver prototypes */
273 extern BOOL
driver_LateGfxInit(APTR
, struct GfxBase
*GfxBase
);
275 extern void driver_Text (struct RastPort
*, CONST_STRPTR
, LONG
, struct GfxBase
*);
277 /* functions in support.c */
278 extern BOOL
pattern_pen(struct RastPort
*rp
280 , ULONG apen
, ULONG bpen
282 , struct GfxBase
*GfxBase
);
284 /* function for area opeartions */
285 BOOL
areafillpolygon(struct RastPort
* rp
,
286 struct Rectangle
* bounds
,
290 struct GfxBase
* GfxBase
);
292 void areafillellipse(struct RastPort
* rp
,
293 struct Rectangle
* bounds
,
296 struct GfxBase
* GfxBase
);
298 void areaclosepolygon(struct AreaInfo
*areainfo
);
300 /* functions in color_support */
301 ULONG
color_distance(struct ColorMap
* cm
,
307 BOOL
color_equal(struct ColorMap
* cm
,
313 VOID
color_set(struct ColorMap
* cm
,
319 VOID
color_get(struct ColorMap
*cm
,
325 void _DisposeRegionRectangleList
327 struct RegionRectangle
*RR
,
328 struct GfxBase
*GfxBase
331 struct RegionRectangle
*_NewRegionRectangle
333 struct RegionRectangle
**LastRectPtr
,
334 struct GfxBase
*GfxBase
337 BOOL _LinkRegionRectangleList
339 struct RegionRectangle
*src
,
340 struct RegionRectangle
**dstptr
,
341 struct GfxBase
*GfxBase
345 # define GFX_ALLOC(Size) \
349 ObtainSemaphore(&PrivGBase(GfxBase)->regionsem); \
353 PrivGBase(GfxBase)->regionpool, \
357 ReleaseSemaphore(&PrivGBase(GfxBase)->regionsem); \
362 # define GFX_FREE(Mem, Size) \
366 ObtainSemaphore(&PrivGBase(GfxBase)->regionsem); \
370 PrivGBase(GfxBase)->regionpool, \
375 ReleaseSemaphore(&PrivGBase(GfxBase)->regionsem); \
378 # define GFX_ALLOC(Size) AllocMem(Size, MEMF_ANY)
379 # define GFX_FREE(Mem, Size) FreeMem(Mem, Size)
382 #define _NewRegionRectangleExtChunk() \
383 __NewRegionRectangleExtChunk(GfxBase)
385 #define _DisposeRegionRectangleExtChunk(_chunk) \
386 __DisposeRegionRectangleExtChunk(_chunk, GfxBase)
388 #define SIZECHUNKBUF 20
392 struct RegionRectangleExtChunk Chunk
;
393 struct ChunkPool
*Owner
;
399 struct ChunkExt Chunks
[SIZECHUNKBUF
];
400 struct MinList ChunkList
;
404 void __DisposeRegionRectangleExtChunk
406 struct RegionRectangleExtChunk
*Chunk
,
407 struct GfxBase
*GfxBase
410 #endif /* GRAPHICS_INTERN_H */