2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Bitmap class for Display hidd.
10 #include <proto/oop.h>
11 #include <proto/utility.h>
13 #include <exec/memory.h>
14 #include <exec/lists.h>
16 #include <graphics/rastport.h>
17 #include <graphics/gfx.h>
20 #include <hidd/graphics.h>
22 #include "displayhw.h"
24 #include "displayclass.h"
29 /* Don't initialize static variables with "=0", otherwise they go into DATA segment */
32 static OOP_AttrBase HiddBitMapAttrBase
;
33 static OOP_AttrBase HiddPixFmtAttrBase
;
34 static OOP_AttrBase HiddGfxAttrBase
;
35 static OOP_AttrBase HiddSyncAttrBase
;
36 static OOP_AttrBase HiddDisplayGfxAB
;
37 static OOP_AttrBase HiddDisplayBitMapAB
;
39 static struct OOP_ABDescr attrbases
[] =
41 { IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
42 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
43 { IID_Hidd_Gfx
, &HiddGfxAttrBase
},
44 { IID_Hidd_Sync
, &HiddSyncAttrBase
},
46 { IID_Hidd_Displaygfx
, &HiddDisplayGfxAB
},
47 { IID_Hidd_DisplayBitMap
, &HiddDisplayBitMapAB
},
52 void DisplayRestore(struct DisplayHWRec
*, BOOL onlyDAC
);
53 void * DisplaySave(struct DisplayHWRec
*);
54 int DisplayInitMode(struct DisplayModeDesc
*, struct DisplayHWRec
*);
55 void DisplayLoadPalette(struct DisplayHWRec
*, unsigned char *);
57 void free_onbmclass(struct display_staticdata
*);
59 #define MNAME(x) onbitmap_ ## x
63 #include <aros/debug.h>
66 #include "bitmap_common.c"
71 void scr_RawPutChars(char *, int);
75 #define rkprintf(x...) scr_RawPutChars(tab, sprintf(tab, x))
79 #define clr() /* eps */
83 #define rkprintf(x...) /* eps */
87 /*********** BitMap::New() *************************************/
89 static OOP_Object
*onbitmap_new(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
91 EnterFunc(bug("DisplayGfx.BitMap::New()\n"));
93 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
96 struct bitmap_data
*data
;
100 IPTR width
, height
, depth
;
102 data
= OOP_INST_DATA(cl
, o
);
105 memset(data
, 0, sizeof(struct bitmap_data
));
107 /* Get attr values */
108 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
109 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
110 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (IPTR
*)&pf
);
111 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
113 // assert (width != 0 && height != 0 && depth != 0);
116 We must only create depths that are supported by the friend drawable
117 Currently we only support the default depth
120 width
=(width
+15) & ~15;
123 data
->height
= height
;
125 data
->Regs
= AllocVec(sizeof(struct DisplayHWRec
),MEMF_PUBLIC
|MEMF_CLEAR
);
129 Here there is brand new method of getting pixelclock data.
130 It was introduced here to make the code more portable. Besides
131 it may now be used as a base for creating other low level
137 data
->VideoData
= AllocVec(width
*height
,MEMF_PUBLIC
|MEMF_CLEAR
);
141 struct DisplayModeDesc mode
;
147 /* We should be able to get modeID from the bitmap */
149 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
151 if (modeid
!= vHidd_ModeID_Invalid
)
153 struct Box box
= {0, 0, width
-1, height
-1};
155 /* Get Sync and PixelFormat properties */
156 HIDD_Gfx_GetMode(XSD(cl
)->displayhidd
, modeid
, &sync
, &pf
);
159 mode
.Height
= height
;
162 OOP_GetAttr(sync
, aHidd_Sync_PixelClock
, &pixelc
);
164 mode
.clock
= (pixelc
> 26000000) ? 1 : 0;
168 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &mode
.HDisplay
);
169 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &mode
.VDisplay
);
170 OOP_GetAttr(sync
, aHidd_Sync_HSyncStart
, &mode
.HSyncStart
);
171 OOP_GetAttr(sync
, aHidd_Sync_VSyncStart
, &mode
.VSyncStart
);
174 OOP_GetAttr(sync
, aHidd_Sync_HSyncEnd
, &mode
.HSyncEnd
);
175 OOP_GetAttr(sync
, aHidd_Sync_VSyncEnd
, &mode
.VSyncEnd
);
177 OOP_GetAttr(sync
, aHidd_Sync_HTotal
, &mode
.HTotal
);
178 OOP_GetAttr(sync
, aHidd_Sync_VTotal
, &mode
.VTotal
);
182 ObtainSemaphore(&XSD(cl
)->HW_acc
);
184 /* Now, when the best display mode is chosen, we can build it */
185 DisplayInitMode(&mode
, (struct DisplayHWRec
*)data
->Regs
);
186 DisplayLoadPalette((struct DisplayHWRec
*)data
->Regs
,(unsigned char *)NULL
);
189 Because of not defined BitMap_Show method show
193 DisplayRestore((struct DisplayHWRec
*)data
->Regs
, FALSE
);
194 DisplayRefreshArea(data
, 1, &box
);
196 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
198 XSD(cl
)->visible
= data
; /* Set created object as visible */
202 // ReturnPtr("DisplayGfx.BitMap::New()", Object *, o);
205 } /* if got data->VideoData */
208 } /* if got data->Regs */
211 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
212 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
216 } /* if created object */
218 ReturnPtr("DisplayGfx.BitMap::New()", OOP_Object
*, o
);
221 /********** Bitmap::Dispose() ***********************************/
223 static VOID
onbitmap_dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
225 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
226 EnterFunc(bug("DisplayGfx.BitMap::Dispose()\n"));
229 FreeVec(data
->VideoData
);
233 OOP_DoSuperMethod(cl
, o
, msg
);
235 ReturnVoid("DisplayGfx.BitMap::Dispose");
238 /*** init_onbmclass *********************************************************/
243 #define NUM_ROOT_METHODS 3
244 #define NUM_BITMAP_METHODS 10
246 OOP_Class
*init_onbmclass(struct display_staticdata
*xsd
)
248 struct OOP_MethodDescr root_descr
[NUM_ROOT_METHODS
+ 1] =
250 {(IPTR (*)())MNAME(new) , moRoot_New
},
251 {(IPTR (*)())MNAME(dispose
), moRoot_Dispose
},
253 {(IPTR (*)())MNAME(set
) , moRoot_Set
},
255 {(IPTR (*)())MNAME(get
) , moRoot_Get
},
259 struct OOP_MethodDescr bitMap_descr
[NUM_BITMAP_METHODS
+ 1] =
261 {(IPTR (*)())MNAME(setcolors
), moHidd_BitMap_SetColors
},
262 {(IPTR (*)())MNAME(putpixel
), moHidd_BitMap_PutPixel
},
263 {(IPTR (*)())MNAME(clear
), moHidd_BitMap_Clear
},
264 {(IPTR (*)())MNAME(getpixel
), moHidd_BitMap_GetPixel
},
265 /* {(IPTR (*)())MNAME(drawpixel), moHidd_BitMap_DrawPixel},*/
266 {(IPTR (*)())MNAME(fillrect
), moHidd_BitMap_FillRect
},
267 {(IPTR (*)())MNAME(getimage
), moHidd_BitMap_GetImage
},
268 {(IPTR (*)())MNAME(putimage
), moHidd_BitMap_PutImage
},
269 {(IPTR (*)())MNAME(blitcolorexpansion
), moHidd_BitMap_BlitColorExpansion
},
270 {(IPTR (*)())MNAME(putimagelut
), moHidd_BitMap_PutImageLUT
},
271 {(IPTR (*)())MNAME(getimagelut
), moHidd_BitMap_GetImageLUT
},
275 struct OOP_InterfaceDescr ifdescr
[] =
277 {root_descr
, IID_Root
, NUM_ROOT_METHODS
},
278 {bitMap_descr
, IID_Hidd_BitMap
, NUM_BITMAP_METHODS
},
282 OOP_AttrBase MetaAttrBase
= OOP_ObtainAttrBase(IID_Meta
);
284 struct TagItem tags
[] =
286 {aMeta_SuperID
, (IPTR
) CLID_Hidd_BitMap
},
287 {aMeta_InterfaceDescr
, (IPTR
) ifdescr
},
288 {aMeta_InstSize
, (IPTR
) sizeof(struct bitmap_data
)},
292 OOP_Class
*cl
= NULL
;
294 EnterFunc(bug("init_bitmapclass(xsd=%p)\n", xsd
));
296 D(bug("Metattrbase: %x\n", MetaAttrBase
));
300 D(bug("Got attrbase\n"));
302 cl
= OOP_NewObject(NULL
, CLID_HiddMeta
, tags
);
305 D(bug("BitMap class ok\n"));
307 cl
->UserData
= (APTR
) xsd
;
309 __IHidd_BitMap
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
310 __IHidd_PixFmt
= OOP_ObtainAttrBase(IID_Hidd_PixFmt
);
311 __IHidd_Gfx
= OOP_ObtainAttrBase(IID_Hidd_Gfx
);
312 __IHidd_Sync
= OOP_ObtainAttrBase(IID_Hidd_Sync
);
313 __IHidd_DisplayGfx
= OOP_ObtainAttrBase(IID_Hidd_Displaygfx
);
314 __IHidd_DisplayBitMap
= OOP_ObtainAttrBase(IID_Hidd_DisplayBitMap
);
316 /* Get attrbase for the BitMap interface */
317 if (NULL
!= __IHidd_BitMap
&&
318 NULL
!= __IHidd_PixFmt
&&
319 NULL
!= __IHidd_Gfx
&&
320 NULL
!= __IHidd_Sync
&&
321 NULL
!= __IHidd_DisplayGfx
&&
322 NULL
!= __IHidd_DisplayBitMap
)
328 free_onbmclass( xsd
);
333 /* We don't need this anymore */
334 OOP_ReleaseAttrBase(IID_Meta
);
335 } /* if(MetaAttrBase) */
337 ReturnPtr("init_onbmclass", OOP_Class
*, cl
);
340 /*** free_bitmapclass *********************************************************/
342 void free_onbmclass(struct display_staticdata
*xsd
)
344 EnterFunc(bug("free_onbmclass(xsd=%p)\n", xsd
));
348 OOP_RemoveClass(xsd
->onbmclass
);
349 if(xsd
->onbmclass
) OOP_DisposeObject((OOP_Object
*) xsd
->onbmclass
);
350 xsd
->onbmclass
= NULL
;
352 #warning Change this!
353 if (NULL
!= __IHidd_BitMap
)
354 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
355 if (NULL
!= __IHidd_PixFmt
)
356 OOP_ReleaseAttrBase(IID_Hidd_PixFmt
);
357 if (NULL
!= __IHidd_Gfx
)
358 OOP_ReleaseAttrBase(IID_Hidd_Gfx
);
359 if (NULL
!= __IHidd_Sync
)
360 OOP_ReleaseAttrBase(IID_Hidd_Sync
);
361 if (NULL
!= __IHidd_DisplayGfx
)
362 OOP_ReleaseAttrBase(IID_Hidd_Displaygfx
);
363 if (NULL
!= __IHidd_DisplayBitMap
)
364 OOP_ReleaseAttrBase(IID_Hidd_DisplayBitMap
);
367 ReturnVoid("free_onbmclass");