2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
9 #define __OOP_NOATTRBASES__
11 #include <proto/exec.h>
12 #include <proto/oop.h>
13 #include <proto/utility.h>
14 #include <aros/symbolsets.h>
15 #include <devices/inputevent.h>
16 #include <exec/alerts.h>
17 #include <exec/memory.h>
18 #include <hardware/custom.h>
19 #include <hidd/hidd.h>
20 #include <hidd/graphics.h>
22 #include <clib/alib_protos.h>
26 #include <aros/debug.h>
28 #include "vesagfxclass.h"
32 #include LC_LIBDEFS_FILE
34 static OOP_AttrBase HiddBitMapAttrBase
;
35 static OOP_AttrBase HiddPixFmtAttrBase
;
36 static OOP_AttrBase HiddGfxAttrBase
;
37 static OOP_AttrBase HiddSyncAttrBase
;
38 static OOP_AttrBase HiddVesaGfxAttrBase
;
39 static OOP_AttrBase HiddVesaGfxBitMapAttrBase
;
41 static struct OOP_ABDescr attrbases
[] =
43 {IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
44 {IID_Hidd_VesaGfxBitMap
, &HiddVesaGfxBitMapAttrBase
},
45 {IID_Hidd_VesaGfx
, &HiddVesaGfxAttrBase
},
46 {IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
47 {IID_Hidd_Sync
, &HiddSyncAttrBase
},
48 {IID_Hidd_Gfx
, &HiddGfxAttrBase
},
52 static UBYTE syncdescription
[100];
54 OOP_Object
*PCVesa__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
56 struct TagItem pftags
[] =
58 {aHidd_PixFmt_RedShift
, 0}, /* 0 */
59 {aHidd_PixFmt_GreenShift
, 0}, /* 1 */
60 {aHidd_PixFmt_BlueShift
, 0}, /* 2 */
61 {aHidd_PixFmt_AlphaShift
, 0}, /* 3 */
62 {aHidd_PixFmt_RedMask
, 0}, /* 4 */
63 {aHidd_PixFmt_GreenMask
, 0}, /* 5 */
64 {aHidd_PixFmt_BlueMask
, 0}, /* 6 */
65 {aHidd_PixFmt_AlphaMask
, 0}, /* 7 */
66 {aHidd_PixFmt_ColorModel
, 0}, /* 8 */
67 {aHidd_PixFmt_Depth
, 0}, /* 9 */
68 {aHidd_PixFmt_BytesPerPixel
,0}, /* 10 */
69 {aHidd_PixFmt_BitsPerPixel
, 0}, /* 11 */
70 {aHidd_PixFmt_StdPixFmt
, 0}, /* 12 */
71 {aHidd_PixFmt_CLUTShift
, 0}, /* 13 */
72 {aHidd_PixFmt_CLUTMask
, 0}, /* 14 */
73 {aHidd_PixFmt_BitMapType
, 0}, /* 15 */
76 struct TagItem sync_mode
[] =
78 {aHidd_Sync_PixelClock
, 0},
79 {aHidd_Sync_HDisp
, 0},
80 {aHidd_Sync_VDisp
, 0},
81 {aHidd_Sync_Description
,0},
82 {aHidd_Sync_HSyncStart
, 0},
83 {aHidd_Sync_HSyncEnd
, 0},
84 {aHidd_Sync_HTotal
, 0},
85 {aHidd_Sync_VSyncStart
, 0},
86 {aHidd_Sync_VSyncEnd
, 0},
87 {aHidd_Sync_VTotal
, 0},
90 struct TagItem modetags
[] =
92 {aHidd_Gfx_PixFmtTags
, (IPTR
)pftags
},
93 {aHidd_Gfx_SyncTags
, (IPTR
)sync_mode
},
96 struct TagItem yourtags
[] =
98 {aHidd_Gfx_ModeTags
, (IPTR
)modetags
},
101 struct pRoot_New yourmsg
;
103 pftags
[0].ti_Data
= XSD(cl
)->data
.redshift
;
104 pftags
[1].ti_Data
= XSD(cl
)->data
.greenshift
;
105 pftags
[2].ti_Data
= XSD(cl
)->data
.blueshift
;
106 pftags
[3].ti_Data
= 0;
107 pftags
[4].ti_Data
= XSD(cl
)->data
.redmask
;
108 pftags
[5].ti_Data
= XSD(cl
)->data
.greenmask
;
109 pftags
[6].ti_Data
= XSD(cl
)->data
.bluemask
;
110 pftags
[7].ti_Data
= 0;
111 pftags
[8].ti_Data
= (XSD(cl
)->data
.depth
> 8) ? vHidd_ColorModel_TrueColor
: vHidd_ColorModel_Palette
;
112 pftags
[9].ti_Data
= (XSD(cl
)->data
.depth
> 24) ? 24 : XSD(cl
)->data
.depth
;
113 pftags
[10].ti_Data
= XSD(cl
)->data
.bytesperpixel
;
114 pftags
[11].ti_Data
= (XSD(cl
)->data
.bitsperpixel
> 24) ? 24 : XSD(cl
)->data
.bitsperpixel
;
115 pftags
[12].ti_Data
= vHidd_StdPixFmt_Native
;
116 pftags
[14].ti_Data
= (1 << XSD(cl
)->data
.depth
) - 1;
117 pftags
[15].ti_Data
= vHidd_BitMapType_Chunky
;
119 sync_mode
[1].ti_Data
= XSD(cl
)->data
.width
;
120 sync_mode
[2].ti_Data
= XSD(cl
)->data
.height
;
121 __sprintf(syncdescription
, "VESA:%ldx%ld", XSD(cl
)->data
.width
, XSD(cl
)->data
.height
);
122 sync_mode
[3].ti_Data
= (IPTR
)syncdescription
;
124 yourtags
[1].ti_Data
= (IPTR
)msg
->attrList
;
125 yourmsg
.mID
= msg
->mID
;
126 yourmsg
.attrList
= yourtags
;
128 EnterFunc(bug("VesaGfx::New()\n"));
129 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
132 D(bug("Got object from super\n"));
133 XSD(cl
)->vesagfxhidd
= o
;
134 XSD(cl
)->mouse
.shape
= NULL
;
135 ReturnPtr("VesaGfx::New", OOP_Object
*, o
);
137 ReturnPtr("VesaGfx::New", OOP_Object
*, NULL
);
140 VOID
PCVesa__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
142 if (XSD(cl
)->mouse
.shape
!= NULL
)
143 FreeVec(XSD(cl
)->mouse
.shape
);
144 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
147 VOID
PCVesa__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
152 if (IS_GFX_ATTR(msg
->attrID
, idx
))
156 /* Our only gettable attribute is wether we support HW cursor or not.
157 * We do not have any such support, since we are a simple VESA fb driver */
158 case aoHidd_Gfx_SupportsHWCursor
:
159 *msg
->storage
= (IPTR
)FALSE
;
165 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
168 OOP_Object
*PCVesa__Hidd_Gfx__NewBitMap(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_NewBitMap
*msg
)
172 OOP_Class
*classptr
= NULL
;
173 struct TagItem tags
[2];
174 struct pHidd_Gfx_NewBitMap yourmsg
;
176 EnterFunc(bug("VesaGfx::NewBitMap()\n"));
177 displayable
= GetTagData(aHidd_BitMap_Displayable
, FALSE
, msg
->attrList
);
178 framebuffer
= GetTagData(aHidd_BitMap_FrameBuffer
, FALSE
, msg
->attrList
);
180 classptr
= XSD(cl
)->onbmclass
;
181 else if (displayable
)
182 classptr
= XSD(cl
)->offbmclass
;
186 modeid
= (HIDDT_ModeID
)GetTagData(aHidd_BitMap_ModeID
, vHidd_ModeID_Invalid
, msg
->attrList
);
187 if (modeid
!= vHidd_ModeID_Invalid
)
188 classptr
= XSD(cl
)->offbmclass
;
191 HIDDT_StdPixFmt stdpf
;
192 stdpf
= (HIDDT_StdPixFmt
)GetTagData(aHidd_BitMap_StdPixFmt
, vHidd_StdPixFmt_Unknown
, msg
->attrList
);
193 if (stdpf
== vHidd_StdPixFmt_Unknown
)
196 friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, 0, msg
->attrList
);
201 OOP_GetAttr(friend, aHidd_BitMap_GfxHidd
, (APTR
)&gfxhidd
);
204 classptr
= XSD(cl
)->offbmclass
;
210 if (classptr
!= NULL
)
212 tags
[0].ti_Tag
= aHidd_BitMap_ClassPtr
;
213 tags
[0].ti_Data
= (IPTR
)classptr
;
214 tags
[1].ti_Tag
= TAG_MORE
;
215 tags
[1].ti_Data
= (IPTR
)msg
->attrList
;
216 yourmsg
.mID
= msg
->mID
;
217 yourmsg
.attrList
= tags
;
220 ReturnPtr("VesaGfx::NewBitMap", OOP_Object
*, (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
));
223 VOID
PCVesa__Hidd_Gfx__CopyBox(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CopyBox
*msg
)
225 unsigned char *src
= 0, *dest
= 0;
228 mode
= GC_DRMD(msg
->gc
);
230 OOP_GetAttr(msg
->src
, aHidd_VesaGfxBitMap_Drawable
, (APTR
)&src
);
231 OOP_GetAttr(msg
->dest
, aHidd_VesaGfxBitMap_Drawable
, (APTR
)&dest
);
234 ((mode
!= vHidd_GC_DrawMode_Copy
)))
236 /* The source and/or destination object is no VesaGfx bitmap, onscreen nor offscreen.
237 Or drawmode is not one of those we accelerate. Let the superclass do the
238 copying in a more general way
240 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
246 struct BitmapData
*data
= OOP_INST_DATA(OOP_OCLASS(msg
->src
), msg
->src
);
247 struct BitmapData
*ddata
= OOP_INST_DATA(OOP_OCLASS(msg
->dest
), msg
->dest
);
251 case vHidd_GC_DrawMode_Copy
:
252 switch(data
->bytesperpix
)
255 HIDD_BM_CopyMemBox8(msg
->dest
,
265 ddata
->bytesperline
);
269 HIDD_BM_CopyMemBox16(msg
->dest
,
279 ddata
->bytesperline
);
284 HIDD_BM_CopyMemBox24(msg
->dest
,
294 ddata
->bytesperline
);
298 HIDD_BM_CopyMemBox32(msg
->dest
,
308 ddata
->bytesperline
);
311 } /* switch(data->bytesperpix) */
317 if (OOP_OCLASS(msg
->dest
) == XSD(cl
)->onbmclass
)
319 LOCK_FRAMEBUFFER(XSD(cl
));
320 vesaRefreshArea(ddata
, msg
->destX
, msg
->destY
, msg
->destX
+ msg
->width
- 1, msg
->destY
+ msg
->height
- 1);
321 UNLOCK_FRAMEBUFFER(XSD(cl
));
329 VOID
PCVesa__Hidd_Gfx__ShowImminentReset(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
331 memset(XSD(cl
)->data
.framebuffer
,
333 XSD(cl
)->data
.height
* XSD(cl
)->data
.bytesperline
);
337 static int PCVesa_InitClass(LIBBASETYPEPTR LIBBASE
)
339 EnterFunc(bug("PCVesa_InitClass\n"));
341 LIBBASE
->vsd
.mouse
.x
=0;
342 LIBBASE
->vsd
.mouse
.y
=0;
343 LIBBASE
->vsd
.mouse
.shape
= NULL
;
345 ReturnInt("PCVesa_InitClass", ULONG
, OOP_ObtainAttrBases(attrbases
));
348 static int PCVesa_ExpungeClass(LIBBASETYPEPTR LIBBASE
)
350 EnterFunc(bug("free_vesagfxclass(xsd=%p)\n", xsd
));
352 OOP_ReleaseAttrBases(attrbases
);
353 ReturnInt("PCVesa_ExpungeClass", int, TRUE
);
356 ADD2INITLIB(PCVesa_InitClass
, 0)
357 ADD2EXPUNGELIB(PCVesa_ExpungeClass
, 0)