Fixed warnings.
[cake.git] / arch / i386-pc / drivers / vesa.hidd / offbitmap.c
blobd6d6927c16b8cdc1fce4dbf050a5648534d40e7e
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Offscreen bitmap class for Vesa hidd.
6 Lang: English.
7 */
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
13 #include <assert.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>
20 #include <oop/oop.h>
21 #include <aros/symbolsets.h>
22 #define DEBUG 0
23 #include <aros/debug.h>
25 #include "bitmap.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 },
44 /* Private bases */
45 {IID_Hidd_VesaGfx , &HiddVesaGfxAttrBase },
46 {IID_Hidd_VesaGfxBitMap , &HiddVesaGfxBitMapAttrBase },
47 {NULL , NULL }
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);
61 if (o)
63 struct BitmapData *data;
64 IPTR width, height, depth, multi;
65 OOP_Object *friend, *pf;
67 data = OOP_INST_DATA(cl, o);
69 /* clear all data */
70 memset(data, 0, sizeof(struct BitmapData));
72 /* Get attr values */
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, (IPTR *)&pf);
77 data->pixfmtobj = 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, (IPTR *)&friend);
84 /* If you got a friend bitmap, copy its colormap */
85 if (friend)
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;
94 data->width = width;
95 data->height = height;
96 data->bpp = depth;
97 data->disp = 0;
99 data->bytesperpix = multi;
100 data->bytesperline = width * multi;
102 data->VideoData = AllocVec(width*height*multi, MEMF_PUBLIC | MEMF_CLEAR);
103 if (data->VideoData)
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);
118 o = NULL;
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"));
132 if (data->VideoData)
133 FreeVec(data->VideoData);
135 OOP_DoSuperMethod(cl, o, msg);
137 ReturnVoid("VesaGfx.BitMap::Dispose");
140 #undef SDEBUG
141 #undef DEBUG
142 #define SDEBUG 0
143 #define DEBUG 0
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)