2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Offscreen bitmap class for Vesa hidd.
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
14 #include <exec/alerts.h>
15 #include <exec/lists.h>
16 #include <exec/memory.h>
17 #include <graphics/gfx.h>
18 #include <graphics/rastport.h>
19 #include <hidd/graphics.h>
21 #include <aros/symbolsets.h>
23 #include <aros/debug.h>
26 #include "offbitmap.h"
27 #include "vesagfxclass.h"
29 #include LC_LIBDEFS_FILE
31 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
33 static OOP_AttrBase HiddBitMapAttrBase
;
34 static OOP_AttrBase HiddPixFmtAttrBase
;
35 static OOP_AttrBase HiddGfxAttrBase
;
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
},
45 {IID_Hidd_VesaGfx
, &HiddVesaGfxAttrBase
},
46 {IID_Hidd_VesaGfxBitMap
, &HiddVesaGfxBitMapAttrBase
},
50 #define MNAME_ROOT(x) PCVesaOffBM__Root__ ## x
51 #define MNAME_BM(x) PCVesaOffBM__Hidd_BitMap__ ## x
53 #include "bitmap_common.c"
55 /*********** BitMap::New() *************************************/
56 OOP_Object
*MNAME_ROOT(New
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
59 EnterFunc(bug("VesaGfx.BitMap::New()\n"));
60 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
63 struct BitmapData
*data
;
64 IPTR width
, height
, depth
, multi
;
65 OOP_Object
*friend, *pf
;
67 data
= OOP_INST_DATA(cl
, o
);
70 memset(data
, 0, sizeof(struct BitmapData
));
73 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
74 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
75 OOP_GetAttr(o
, aHidd_BitMap_GfxHidd
, (IPTR
*)&data
->gfxhidd
);
76 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, &pf
);
78 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
79 OOP_GetAttr(pf
, aHidd_PixFmt_BytesPerPixel
, &multi
);
81 /* Get the friend bitmap. This should be a displayable bitmap */
82 OOP_GetAttr(o
, aHidd_BitMap_Friend
, &friend);
84 /* If you got a friend bitmap, copy its colormap */
87 struct BitmapData
*src
= OOP_INST_DATA(cl
, friend);
88 CopyMem(&src
->cmap
, &data
->cmap
, 4*16);
91 ASSERT (width
!= 0 && height
!= 0 && depth
!= 0);
93 width
=(width
+15) & ~15;
95 data
->height
= height
;
99 data
->bytesperpix
= multi
;
100 data
->bytesperline
= width
* multi
;
102 data
->VideoData
= AllocVec(width
*height
*multi
, MEMF_PUBLIC
| MEMF_CLEAR
);
105 data
->data
= &XSD(cl
)->data
;
107 if (XSD(cl
)->activecallback
)
108 XSD(cl
)->activecallback(XSD(cl
)->callbackdata
, o
, TRUE
);
110 ReturnPtr("VesaGfx.BitMap::New()", OOP_Object
*, o
);
111 } /* if got data->VideoData */
114 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
115 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
120 } /* if created object */
122 ReturnPtr("VesaGfx.BitMap::New()", OOP_Object
*, o
);
125 /********** Bitmap::Dispose() ***********************************/
126 VOID
MNAME_ROOT(Dispose
)(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
128 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
130 EnterFunc(bug("VesaGfx.BitMap::Dispose()\n"));
133 FreeVec(data
->VideoData
);
135 OOP_DoSuperMethod(cl
, o
, msg
);
137 ReturnVoid("VesaGfx.BitMap::Dispose");
144 #include <aros/debug.h>
146 /*** init_bmclass *********************************************************/
148 static int PCVesaOffBM_Init(LIBBASETYPEPTR LIBBASE
)
150 EnterFunc(bug("PCVesaOffBM_Init\n"));
152 ReturnInt("PCVesaOffBM_Init", ULONG
, OOP_ObtainAttrBases(attrbases
));
155 /*** free_bitmapclass *********************************************************/
157 static int PCVesaOffBM_Expunge(LIBBASETYPEPTR LIBBASE
)
159 OOP_ReleaseAttrBases(attrbases
);
160 ReturnInt("PCVesaOffBM_Expunge", int, TRUE
);
163 ADD2INITLIB(PCVesaOffBM_Init
, 0)
164 ADD2EXPUNGELIB(PCVesaOffBM_Expunge
, 0)