2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
5 Desc: Bitmap class for Vesa hidd.
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
14 #include <exec/memory.h>
15 #include <exec/lists.h>
16 #include <graphics/rastport.h>
17 #include <graphics/gfx.h>
18 #include <hidd/graphics.h>
20 #include <aros/symbolsets.h>
22 #include <aros/debug.h>
26 #include "vesagfxclass.h"
28 #include LC_LIBDEFS_FILE
30 /* 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 HiddVesaGfxAttrBase
;
37 static OOP_AttrBase HiddVesaGfxBitMapAttrBase
;
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_VesaGfx
, &HiddVesaGfxAttrBase
},
47 { IID_Hidd_VesaGfxBitMap
, &HiddVesaGfxBitMapAttrBase
},
51 #define MNAME_ROOT(x) PCVesaOnBM__Root__ ## x
52 #define MNAME_BM(x) PCVesaOnBM__Hidd_BitMap__ ## x
55 #include "bitmap_common.c"
57 /*********** BitMap::New() *************************************/
58 OOP_Object
*MNAME_ROOT(New
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
60 EnterFunc(bug("VesaGfx.BitMap::New()\n"));
62 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
65 struct BitmapData
*data
;
67 IPTR width
, height
, depth
, multi
;
72 data
= OOP_INST_DATA(cl
, o
);
75 memset(data
, 0, sizeof(struct BitmapData
));
78 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
79 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
80 OOP_GetAttr(o
, aHidd_BitMap_GfxHidd
, (IPTR
*)&data
->gfxhidd
);
81 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (IPTR
*)&pf
);
83 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
84 OOP_GetAttr(pf
, aHidd_PixFmt_BytesPerPixel
, &multi
);
86 ASSERT (width
!= 0 && height
!= 0 && depth
!= 0);
88 We must only create depths that are supported by the friend drawable
89 Currently we only support the default depth
92 width
=(width
+15) & ~15;
94 data
->height
= height
;
98 data
->bytesperpix
= multi
;
99 data
->data
= &XSD(cl
)->data
;
100 data
->mouse
= &XSD(cl
)->mouse
;
103 data
->bytesperline
= width
* multi
;
104 data
->VideoData
= AllocVec(width
* height
* multi
, MEMF_PUBLIC
| MEMF_CLEAR
);
106 data
->bytesperline
= data
->data
->bytesperline
;
107 data
->VideoData
= data
->data
->framebuffer
;
110 /* We should be able to get modeID from the bitmap */
111 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
113 if ((modeid
!= vHidd_ModeID_Invalid
) && (data
->VideoData
))
116 Because of not defined BitMap_Show method show
119 XSD(cl
)->visible
= data
; /* Set created object as visible */
121 ReturnPtr("VesaGfx.BitMap::New()", OOP_Object
*, o
);
125 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
126 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
131 } /* if created object */
133 ReturnPtr("VesaGfx.BitMap::New()", OOP_Object
*, o
);
136 /********** Bitmap::Dispose() ***********************************/
137 VOID
MNAME_ROOT(Dispose
)(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
139 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
141 EnterFunc(bug("VesaGfx.BitMap::Dispose()\n"));
145 FreeVec(data
->VideoData
);
147 OOP_DoSuperMethod(cl
, o
, msg
);
149 ReturnVoid("VesaGfx.BitMap::Dispose");
152 /*** init_onbmclass *********************************************************/
154 static int PCVesaOnBM_Init(LIBBASETYPEPTR LIBBASE
)
156 EnterFunc(bug("PCVesaOnBM_Init\n"));
158 ReturnPtr("PCVesaOnBM_Init", ULONG
, OOP_ObtainAttrBases(attrbases
));
161 /*** free_bitmapclass *********************************************************/
163 static int PCVesaOnBM_Expunge(LIBBASETYPEPTR LIBBASE
)
165 OOP_ReleaseAttrBases(attrbases
);
166 ReturnInt("PCVesaOnBM_Expunge", int, TRUE
);
169 ADD2INITLIB(PCVesaOnBM_Init
, 0)
170 ADD2EXPUNGELIB(PCVesaOnBM_Expunge
, 0)