2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Offscreen bitmap class for VGA 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>
17 #include <graphics/rastport.h>
18 #include <graphics/gfx.h>
20 #include <exec/alerts.h>
22 #include <aros/symbolsets.h>
24 #include <hidd/graphics.h>
31 #include LC_LIBDEFS_FILE
35 #include <aros/debug.h>
39 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
41 static OOP_AttrBase HiddBitMapAttrBase
;
42 static OOP_AttrBase HiddPixFmtAttrBase
;
43 static OOP_AttrBase HiddGfxAttrBase
;
44 static OOP_AttrBase HiddVGAGfxAB
;
45 static OOP_AttrBase HiddVGABitMapAB
;
47 static struct OOP_ABDescr attrbases
[] =
49 { IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
50 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
51 { IID_Hidd_Gfx
, &HiddGfxAttrBase
},
53 { IID_Hidd_VGAgfx
, &HiddVGAGfxAB
},
54 { IID_Hidd_VGABitMap
, &HiddVGABitMapAB
},
58 void free_offbmclass(struct vga_staticdata
*);
59 void vgaRefreshArea(struct bitmap_data
*, int , struct Box
*);
61 #define MNAME_ROOT(x) PCVGAOffBM__Root__ ## x
62 #define MNAME_BM(x) PCVGAOffBM__Hidd_BitMap__ ## x
64 #include "bitmap_common.c"
66 /*********** BitMap::New() *************************************/
68 OOP_Object
*PCVGAOffBM__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
70 EnterFunc(bug("VGAGfx.BitMap::New()\n"));
72 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
75 struct bitmap_data
*data
;
76 IPTR width
, height
, depth
;
78 OOP_Object
*friend, *pf
;
80 data
= OOP_INST_DATA(cl
, o
);
83 memset(data
, 0, sizeof(struct bitmap_data
));
86 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
87 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
89 /* nlorentz: The aHidd_BitMap_Depth attribute no loner exist,, so we must
90 get the depth in two steps: First get pixel format, then get depth */
91 OOP_GetAttr(o
, aHidd_BitMap_Depth
, &depth
);
93 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, &pf
);
94 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
97 /* Get the friend bitmap. This should be a displayable bitmap */
98 OOP_GetAttr(o
, aHidd_BitMap_Friend
, &friend);
100 /* If you got a friend bitmap, copy its colormap */
103 struct bitmap_data
*src
= OOP_INST_DATA(cl
, friend);
105 CopyMem(&src
->cmap
, &data
->cmap
, 4*16);
109 ASSERT (width
!= 0 && height
!= 0 && depth
!= 0);
112 We must only create depths that are supported by the friend drawable
113 Currently we only support the default depth
116 /* nlorentz: With the new HIDD design we decided in Gfx::NewBitMap()
117 that we should only create bitmaps that are alike to the friend bitmap.
118 Thus the test below is really not necessary, as we will allways
123 // depth = 4; /* Do anything... */
127 /* nlorentz: Not necessary with the new design */
128 /* Update the depth to the one we use */
129 depth_tags
[0].ti_Data
= depth
;
130 SetAttrs(o
, depth_tags
);
133 data
->height
= height
;
136 width
=(width
+15) & ~15;
137 data
->VideoData
= AllocVec(width
*height
,MEMF_PUBLIC
|MEMF_CLEAR
);
140 data
->Regs
= AllocVec(sizeof(struct vgaHWRec
),MEMF_PUBLIC
|MEMF_CLEAR
);
144 /* nlorentz: Not necessary nor possible with the new design */
147 if (XSD(cl
)->activecallback
)
148 XSD(cl
)->activecallback(XSD(cl
)->callbackdata
, o
, TRUE
);
150 ReturnPtr("VGAGfx.BitMap::New()", OOP_Object
*, o
);
152 } /* if got data->VideoData */
155 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
156 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
160 } /* if created object */
162 ReturnPtr("VGAGfx.BitMap::New()", OOP_Object
*, o
);
165 /********** Bitmap::Dispose() ***********************************/
167 VOID
PCVGAOffBM__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
169 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
170 EnterFunc(bug("VGAGfx.BitMap::Dispose()\n"));
173 FreeVec(data
->VideoData
);
177 OOP_DoSuperMethod(cl
, o
, msg
);
179 ReturnVoid("VGAGfx.BitMap::Dispose");
187 #include <aros/debug.h>
191 /*** init_bmclass *********************************************************/
193 static int PCVGAOffBM_Init(LIBBASETYPEPTR LIBBASE
)
195 EnterFunc(bug("PCVGAOffBM_Init\n"));
197 ReturnInt("PCVGAOffBM_Init", ULONG
, OOP_ObtainAttrBases(attrbases
));
200 /*** expunge_onbmclass *******************************************************/
202 static int PCVGAOffBM_Expunge(LIBBASETYPEPTR LIBBASE
)
204 EnterFunc(bug("PCVGAOffBM_Expunge\n"));
206 OOP_ReleaseAttrBases(attrbases
);
207 ReturnInt("PCVGAOffBM_Expunge", int, TRUE
);
210 /*****************************************************************************/
212 ADD2INITLIB(PCVGAOffBM_Init
, 0)
213 ADD2EXPUNGELIB(PCVGAOffBM_Expunge
, 0)