2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Offscreen 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>
19 #include <exec/alerts.h>
21 #include <hidd/graphics.h>
26 #include "displayclass.h"
30 #include <aros/debug.h>
35 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
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
},
50 { IID_Hidd_Displaygfx
, &HiddDisplayGfxAB
},
51 { IID_Hidd_DisplayBitMap
, &HiddDisplayBitMapAB
},
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
);
72 struct bitmap_data
*data
;
73 IPTR width
, height
, depth
;
75 OOP_Object
*friend, *pf
;
77 data
= OOP_INST_DATA(cl
, o
);
80 memset(data
, 0, sizeof(struct bitmap_data
));
84 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
85 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
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
);
91 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (IPTR
*)&pf
);
92 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
95 /* Get the friend bitmap. This should be a displayable bitmap */
96 OOP_GetAttr(o
, aHidd_BitMap_Friend
, (IPTR
*)&friend);
98 /* If you got a friend bitmap, copy its colormap */
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
121 // depth = 4; /* Do anything... */
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
);
130 width
=(width
+15) & ~15;
133 data
->height
= height
;
136 data
->VideoData
= AllocVec(width
*height
,MEMF_PUBLIC
|MEMF_CLEAR
);
139 data
->Regs
= AllocVec(sizeof(struct DisplayHWRec
),MEMF_PUBLIC
|MEMF_CLEAR
);
143 /* nlorentz: Not necessary nor possible with the new design */
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
);
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"));
172 FreeVec(data
->VideoData
);
176 OOP_DoSuperMethod(cl
, o
, msg
);
178 ReturnVoid("DisplayGfx.BitMap::Dispose");
186 #include <aros/debug.h>
190 /*** init_bmclass *********************************************************/
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
},
207 {(IPTR (*)())MNAME(set
), moRoot_Set
},
209 {(IPTR (*)())MNAME(get
), moRoot_Get
},
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
},
229 struct OOP_InterfaceDescr ifdescr
[] =
231 {root_descr
, IID_Root
, NUM_ROOT_METHODS
},
232 {bitMap_descr
, IID_Hidd_BitMap
, NUM_BITMAP_METHODS
},
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
)},
246 OOP_Class
*cl
= NULL
;
248 EnterFunc(bug("init_bitmapclass(xsd=%p)\n", xsd
));
251 D(bug("Metattrbase: %x\n", MetaAttrBase
));
256 D(bug("Got attrbase\n"));
258 /* for (;;) {cl = cl; } */
259 cl
= OOP_NewObject(NULL
, CLID_HiddMeta
, tags
);
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
)
283 free_offbmclass( xsd
);
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
));
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");