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
;
183 /* Driver data shared between all rastports (allocated once) */
184 struct shared_driverdata shared_driverdata
;
187 #define TFE_HASHTABSIZE 16 /* This MUST be a power of two */
189 struct tfe_hashnode
* tfe_hashtab
[TFE_HASHTABSIZE
];
190 struct SignalSemaphore tfe_hashtab_sema
;
191 struct SignalSemaphore fontsem
;
192 #if REGIONS_USE_MEMPOOL
193 struct SignalSemaphore regionsem
;
195 struct MinList ChunkPoolList
;
197 struct SignalSemaphore driverdatasem
;
199 struct MinList driverdatalist
[DRIVERDATALIST_HASHSIZE
];
200 ULONG
*pixel_buf
; // used in graphics_driver
201 struct SignalSemaphore pixbuf_sema
;
202 struct SignalSemaphore blit_sema
;
208 #define PrivGBase(x) ((struct GfxBase_intern *)x)
210 #define WIDTH_TO_BYTES(width) ((( (width) + 15) & ~15) >> 3)
211 #define WIDTH_TO_WORDS(width) ((( (width) + 15) & ~15) >> 4)
213 #define XCOORD_TO_BYTEIDX( x ) (( x ) >> 3)
214 #define XCOORD_TO_WORDIDX( x ) (( x ) >> 4)
216 #define COORD_TO_BYTEIDX(x, y, bytes_per_row) \
217 ( ( ((LONG)(y)) * (bytes_per_row)) + XCOORD_TO_BYTEIDX(x))
219 #define CHUNKY8_COORD_TO_BYTEIDX(x, y, bytes_per_row) \
220 ( ( ((LONG)(y)) * (bytes_per_row)) + (x) )
222 #define XCOORD_TO_MASK(x) (128L >> ((x) & 0x07))
224 /* For vsprite sorting */
226 #define JOIN_XY_COORDS(x,y) (LONG)( ( ((UWORD)(y)) << 16) + ( ( ((UWORD)(x)) + 0x8000 ) & 0xFFFF ) )
229 #define BMT_STANDARD 0x0000 /* Standard bitmap */
230 #define BMT_RGB 0x1234 /* RTG Bitmap. 24bit RGB chunky */
231 #define BMT_RGBA 0x1238 /* RTG Bitmap. 32bit RGBA chunky */
232 #define BMT_DRIVER 0x8000 /* Special RTG bitmap.
233 Use this as an offset. */
235 #define TFE(tfe) (*(struct TextFontExtension**)&tfe)
237 #define TFE_MATCHWORD 0xDFE7 /* randomly invented */
239 /* Defines for flags in areainfo->FlagPtr */
241 #define AREAINFOFLAG_MOVE 0x00
242 #define AREAINFOFLAG_DRAW 0x01
243 #define AREAINFOFLAG_CLOSEDRAW 0x02
244 #define AREAINFOFLAG_ELLIPSE 0x03
246 /* Forward declaration */
249 /* a function needed by GfxAssocate(), GfxLookUp(), GfxFree() */
250 extern ULONG
CalcHashIndex(ULONG n
);
252 BOOL
obsolete_CorrectDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
253 #if NEW_DRIVERDATA_CODE
254 BOOL
ObtainDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
255 void ReleaseDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
256 void KillDriverData (struct RastPort
* rp
, struct GfxBase
* GfxBase
);
259 /* a function needed by ClipBlit */
260 void internal_ClipBlit(struct RastPort
* srcRP
,
263 struct RastPort
* destRP
,
269 struct GfxBase
* GfxBase
);
271 /* Driver prototypes */
272 extern BOOL
driver_LateGfxInit(APTR
, struct GfxBase
*GfxBase
);
274 extern void driver_Text (struct RastPort
*, CONST_STRPTR
, LONG
, struct GfxBase
*);
276 /* functions in support.c */
277 extern BOOL
pattern_pen(struct RastPort
*rp
279 , ULONG apen
, ULONG bpen
281 , struct GfxBase
*GfxBase
);
283 /* function for area opeartions */
284 BOOL
areafillpolygon(struct RastPort
* rp
,
285 struct Rectangle
* bounds
,
289 struct GfxBase
* GfxBase
);
291 void areafillellipse(struct RastPort
* rp
,
292 struct Rectangle
* bounds
,
295 struct GfxBase
* GfxBase
);
297 void areaclosepolygon(struct AreaInfo
*areainfo
);
299 /* functions in color_support */
300 ULONG
color_distance(struct ColorMap
* cm
,
306 BOOL
color_equal(struct ColorMap
* cm
,
312 VOID
color_set(struct ColorMap
* cm
,
318 VOID
color_get(struct ColorMap
*cm
,
324 void _DisposeRegionRectangleList
326 struct RegionRectangle
*RR
,
327 struct GfxBase
*GfxBase
330 struct RegionRectangle
*_NewRegionRectangle
332 struct RegionRectangle
**LastRectPtr
,
333 struct GfxBase
*GfxBase
336 BOOL _LinkRegionRectangleList
338 struct RegionRectangle
*src
,
339 struct RegionRectangle
**dstptr
,
340 struct GfxBase
*GfxBase
344 # define GFX_ALLOC(Size) \
348 ObtainSemaphore(&PrivGBase(GfxBase)->regionsem); \
352 PrivGBase(GfxBase)->regionpool, \
356 ReleaseSemaphore(&PrivGBase(GfxBase)->regionsem); \
361 # define GFX_FREE(Mem, Size) \
365 ObtainSemaphore(&PrivGBase(GfxBase)->regionsem); \
369 PrivGBase(GfxBase)->regionpool, \
374 ReleaseSemaphore(&PrivGBase(GfxBase)->regionsem); \
377 # define GFX_ALLOC(Size) AllocMem(Size, MEMF_ANY)
378 # define GFX_FREE(Mem, Size) FreeMem(Mem, Size)
381 #define _NewRegionRectangleExtChunk() \
382 __NewRegionRectangleExtChunk(GfxBase)
384 #define _DisposeRegionRectangleExtChunk(_chunk) \
385 __DisposeRegionRectangleExtChunk(_chunk, GfxBase)
387 #define SIZECHUNKBUF 20
391 struct RegionRectangleExtChunk Chunk
;
392 struct ChunkPool
*Owner
;
398 struct ChunkExt Chunks
[SIZECHUNKBUF
];
399 struct MinList ChunkList
;
403 void __DisposeRegionRectangleExtChunk
405 struct RegionRectangleExtChunk
*Chunk
,
406 struct GfxBase
*GfxBase
409 #endif /* GRAPHICS_INTERN_H */