add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / arch / .unmaintained / m68k-pp-native / Drivers / display.hidd / offbitmap.c
blob93f9ed5d64360babb8fee15bf5eed54a07896d30
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Offscreen bitmap class for Display hidd.
6 Lang: English.
7 */
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>
18 #include <oop/oop.h>
19 #include <exec/alerts.h>
21 #include <hidd/graphics.h>
23 #include <string.h>
25 #include "display.h"
26 #include "displayclass.h"
28 #define SDEBUG 0
29 #define DEBUG 0
30 #include <aros/debug.h>
32 #include "bitmap.h"
34 #include "assert.h"
35 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
37 #if 0
38 static OOP_AttrBase HiddBitMapAttrBase;
39 static OOP_AttrBase HiddPixFmtAttrBase;
40 static OOP_AttrBase HiddGfxAttrBase;
41 static OOP_AttrBase HiddDisplayGfxAB;
42 static OOP_AttrBase HiddDisplayBitMapAB;
44 static struct OOP_ABDescr attrbases[] =
46 { IID_Hidd_BitMap, &HiddBitMapAttrBase },
47 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
48 { IID_Hidd_Gfx, &HiddGfxAttrBase },
49 /* Private bases */
50 { IID_Hidd_Displaygfx, &HiddDisplayGfxAB },
51 { IID_Hidd_DisplayBitMap, &HiddDisplayBitMapAB },
52 { NULL, NULL }
54 #endif
56 void free_offbmclass(struct display_staticdata *);
57 void DisplayRefreshArea(struct bitmap_data *, int , struct Box *);
59 #define MNAME(x) offbitmap_ ## x
61 #include "bitmap_common.c"
63 /*********** BitMap::New() *************************************/
65 static OOP_Object *offbitmap_new(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
67 EnterFunc(bug("DisplayGfx.BitMap::New()\n"));
69 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
70 if (o)
72 struct bitmap_data *data;
73 IPTR width, height, depth;
75 OOP_Object *friend, *pf;
77 data = OOP_INST_DATA(cl, o);
79 /* clear all data */
80 memset(data, 0, sizeof(struct bitmap_data));
82 /* Get attr values */
83 #define xsd XSD(cl)
84 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
85 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
86 #if 0
87 /* nlorentz: The aHidd_BitMap_Depth attribute no loner exist,, so we must
88 get the depth in two steps: First get pixel format, then get depth */
89 OOP_GetAttr(o, aHidd_BitMap_Depth, &depth);
90 #else
91 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR *)&pf);
92 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
93 #endif
95 /* Get the friend bitmap. This should be a displayable bitmap */
96 OOP_GetAttr(o, aHidd_BitMap_Friend, (IPTR *)&friend);
97 #undef xsd
98 /* If you got a friend bitmap, copy its colormap */
99 if (friend)
101 struct bitmap_data *src = OOP_INST_DATA(cl, friend);
103 CopyMem(&src->cmap, &data->cmap, 4*16);
107 // assert (width != 0 && height != 0 && depth != 0);
110 We must only create depths that are supported by the friend drawable
111 Currently we only support the default depth
114 /* nlorentz: With the new HIDD design we decided in Gfx::NewBitMap()
115 that we should only create bitmaps that are alike to the friend bitmap.
116 Thus the test below is really not necessary, as we will allways
117 get the same depth
119 if (depth != 4)
121 // depth = 4; /* Do anything... */
124 #if 0
125 /* nlorentz: Not necessary with the new design */
126 /* Update the depth to the one we use */
127 depth_tags[0].ti_Data = depth;
128 SetAttrs(o, depth_tags);
129 #endif
130 width=(width+15) & ~15;
132 data->width = width;
133 data->height = height;
134 data->bpp = depth;
135 data->disp = 0;
136 data->VideoData = AllocVec(width*height,MEMF_PUBLIC|MEMF_CLEAR);
137 if (data->VideoData)
139 data->Regs = AllocVec(sizeof(struct DisplayHWRec),MEMF_PUBLIC|MEMF_CLEAR);
140 if (data->Regs)
142 #if 0
143 /* nlorentz: Not necessary nor possible with the new design */
144 set_pixelformat(o);
145 #endif
146 if (XSD(cl)->activecallback)
147 XSD(cl)->activecallback(XSD(cl)->callbackdata, o, TRUE);
149 ReturnPtr("DisplayGfx.BitMap::New()", Object *, o);
151 } /* if got data->VideoData */
154 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
155 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
158 o = NULL;
159 } /* if created object */
161 ReturnPtr("DisplayGfx.BitMap::New()", OOP_Object *, o);
164 /********** Bitmap::Dispose() ***********************************/
166 static VOID offbitmap_dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
168 struct bitmap_data *data = OOP_INST_DATA(cl, o);
169 EnterFunc(bug("DisplayGfx.BitMap::Dispose()\n"));
171 if (data->VideoData)
172 FreeVec(data->VideoData);
173 if (data->Regs)
174 FreeVec(data->Regs);
176 OOP_DoSuperMethod(cl, o, msg);
178 ReturnVoid("DisplayGfx.BitMap::Dispose");
182 #undef SDEBUG
183 #undef DEBUG
184 #define SDEBUG 0
185 #define DEBUG 0
186 #include <aros/debug.h>
190 /*** init_bmclass *********************************************************/
192 #undef XSD
193 #define XSD(cl) xsd
196 #define NUM_ROOT_METHODS 3
197 #define NUM_BITMAP_METHODS 10
200 OOP_Class *init_offbmclass(struct display_staticdata *xsd)
202 struct OOP_MethodDescr root_descr[NUM_ROOT_METHODS + 1] =
204 {(IPTR (*)())MNAME(new), moRoot_New },
205 {(IPTR (*)())MNAME(dispose), moRoot_Dispose},
206 #if 0
207 {(IPTR (*)())MNAME(set), moRoot_Set},
208 #endif
209 {(IPTR (*)())MNAME(get), moRoot_Get},
210 {NULL, 0UL}
213 struct OOP_MethodDescr bitMap_descr[NUM_BITMAP_METHODS + 1] =
215 {(IPTR (*)())MNAME(setcolors), moHidd_BitMap_SetColors},
216 {(IPTR (*)())MNAME(putpixel), moHidd_BitMap_PutPixel},
217 {(IPTR (*)())MNAME(clear), moHidd_BitMap_Clear},
218 {(IPTR (*)())MNAME(getpixel), moHidd_BitMap_GetPixel},
219 /* {(IPTR (*)())MNAME(drawpixel), moHidd_BitMap_DrawPixel},*/
220 {(IPTR (*)())MNAME(fillrect), moHidd_BitMap_FillRect},
221 {(IPTR (*)())MNAME(getimage), moHidd_BitMap_GetImage},
222 {(IPTR (*)())MNAME(putimage), moHidd_BitMap_PutImage},
223 {(IPTR (*)())MNAME(blitcolorexpansion), moHidd_BitMap_BlitColorExpansion},
224 {(IPTR (*)())MNAME(putimagelut), moHidd_BitMap_PutImageLUT},
225 {(IPTR (*)())MNAME(getimagelut), moHidd_BitMap_GetImageLUT},
226 {NULL, 0UL}
229 struct OOP_InterfaceDescr ifdescr[] =
231 {root_descr, IID_Root , NUM_ROOT_METHODS},
232 {bitMap_descr, IID_Hidd_BitMap, NUM_BITMAP_METHODS},
233 {NULL, NULL, 0}
236 OOP_AttrBase MetaAttrBase = OOP_ObtainAttrBase(IID_Meta);
238 struct TagItem tags[] =
240 {aMeta_SuperID, (IPTR) CLID_Hidd_BitMap},
241 {aMeta_InterfaceDescr, (IPTR) ifdescr},
242 {aMeta_InstSize, (IPTR) sizeof(struct bitmap_data)},
243 {TAG_DONE, 0UL}
246 OOP_Class *cl = NULL;
248 EnterFunc(bug("init_bitmapclass(xsd=%p)\n", xsd));
251 D(bug("Metattrbase: %x\n", MetaAttrBase));
254 if(MetaAttrBase)
256 D(bug("Got attrbase\n"));
258 /* for (;;) {cl = cl; } */
259 cl = OOP_NewObject(NULL, CLID_HiddMeta, tags);
260 if(cl)
262 D(bug("BitMap class ok\n"));
263 xsd->offbmclass = cl;
264 cl->UserData = (APTR) xsd;
266 __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap);
267 __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt);
268 __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx);
269 __IHidd_DisplayGfx = OOP_ObtainAttrBase(IID_Hidd_Displaygfx);
270 __IHidd_DisplayBitMap = OOP_ObtainAttrBase(IID_Hidd_DisplayBitMap);
272 /* Get attrbase for the BitMap interface */
273 if (NULL != __IHidd_BitMap &&
274 NULL != __IHidd_PixFmt &&
275 NULL != __IHidd_Gfx &&
276 NULL != __IHidd_DisplayGfx &&
277 NULL != __IHidd_DisplayBitMap)
279 OOP_AddClass(cl);
281 else
283 free_offbmclass( xsd );
284 cl = NULL;
288 /* We don't need this anymore */
289 OOP_ReleaseAttrBase(IID_Meta);
290 } /* if(MetaAttrBase) */
292 ReturnPtr("init_bmclass", Class *, cl);
296 /*** free_offbitmapclass *********************************************************/
298 void free_offbmclass(struct display_staticdata *xsd)
300 EnterFunc(bug("free_bmclass(xsd=%p)\n", xsd));
302 if(xsd)
304 OOP_RemoveClass(xsd->offbmclass);
305 if(xsd->offbmclass) OOP_DisposeObject((OOP_Object *) xsd->offbmclass);
306 xsd->offbmclass = NULL;
308 #warning Change this!
309 if (NULL != __IHidd_BitMap)
310 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
311 if (NULL != __IHidd_PixFmt)
312 OOP_ReleaseAttrBase(IID_Hidd_PixFmt);
313 if (NULL != __IHidd_Gfx)
314 OOP_ReleaseAttrBase(IID_Hidd_Gfx);
315 if (NULL != __IHidd_DisplayGfx)
316 OOP_ReleaseAttrBase(IID_Hidd_Displaygfx);
317 if (NULL != __IHidd_DisplayBitMap)
318 OOP_ReleaseAttrBase(IID_Hidd_DisplayBitMap);
320 ReturnVoid("free_bmclass");