2 Copyright © 2013, The AROS Development Team. All rights reserved.
5 Desc: VideoCore Gfx Onscreen Bitmap Class.
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <proto/oop.h>
15 #include <proto/vcmbox.h>
16 #include <proto/utility.h>
18 #include <exec/memory.h>
19 #include <exec/lists.h>
20 #include <aros/symbolsets.h>
21 #include <graphics/rastport.h>
22 #include <graphics/gfx.h>
23 #include <hidd/graphics.h>
26 #include "videocoregfx_bitmap.h"
27 #include "videocoregfx_class.h"
29 #include LC_LIBDEFS_FILE
35 #define VCMBoxBase (&((struct VideoCoreGfxBase *)cl->UserData)->vsd)->vcsd_VCMBoxBase
37 #define MNAME_ROOT(x) VideoCoreGfxOnBM__Root__ ## x
38 #define MNAME_BM(x) VideoCoreGfxOnBM__Hidd_BitMap__ ## x
41 #include "videocoregfx_bitmap_common.c"
43 /*********** BitMap::New() *************************************/
45 OOP_Object
*MNAME_ROOT(New
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
47 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New()\n"));
48 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
51 struct BitmapData
*data
;
53 IPTR width
, height
, depth
;
57 data
= OOP_INST_DATA(cl
, o
);
58 memset(data
, 0, sizeof(struct BitmapData
));
61 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
62 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
63 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
64 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (IPTR
*)&pf
);
67 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
69 #if defined(DEBUGPIXFMT)
70 IPTR _pixfmt_RedShift
, _pixfmt_GreenShift
, _pixfmt_BlueShift
, _pixfmt_AlphaShift
,
71 _pixfmt_RedMask
, _pixfmt_GreenMask
, _pixfmt_BlueMask
, _pixfmt_AlphaMask
,
72 _pixfmt_BytesPerPixel
, _pixfmt_BitsPerPixel
,
73 _pixfmt_ColorModel
, _pixfmt_Stdpixfmt
, _pixfmt_BitMapType
;
75 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: PixFmt @ 0x%p\n", pf
));
77 OOP_GetAttr(pf
, aHidd_PixFmt_RedShift
, &_pixfmt_RedShift
);
78 OOP_GetAttr(pf
, aHidd_PixFmt_GreenShift
, &_pixfmt_GreenShift
);
79 OOP_GetAttr(pf
, aHidd_PixFmt_BlueShift
, &_pixfmt_BlueShift
);
80 OOP_GetAttr(pf
, aHidd_PixFmt_AlphaShift
, &_pixfmt_AlphaShift
);
81 OOP_GetAttr(pf
, aHidd_PixFmt_RedMask
, &_pixfmt_RedMask
);
82 OOP_GetAttr(pf
, aHidd_PixFmt_GreenMask
, &_pixfmt_GreenMask
);
83 OOP_GetAttr(pf
, aHidd_PixFmt_BlueMask
, &_pixfmt_BlueMask
);
84 OOP_GetAttr(pf
, aHidd_PixFmt_AlphaMask
, &_pixfmt_AlphaMask
);
85 OOP_GetAttr(pf
, aHidd_PixFmt_ColorModel
, &_pixfmt_ColorModel
);
86 OOP_GetAttr(pf
, aHidd_PixFmt_BytesPerPixel
, &_pixfmt_BytesPerPixel
);
87 OOP_GetAttr(pf
, aHidd_PixFmt_BitsPerPixel
, &_pixfmt_BitsPerPixel
);
88 OOP_GetAttr(pf
, aHidd_PixFmt_StdPixFmt
, &_pixfmt_Stdpixfmt
);
89 OOP_GetAttr(pf
, aHidd_PixFmt_BitMapType
, &_pixfmt_BitMapType
);
91 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: Depth: %d, Bpp: %d, bpp: %d\n", depth
, _pixfmt_BytesPerPixel
, _pixfmt_BitsPerPixel
));
92 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: Ashift: %08x Rshift: %08x Gshift: %08x Bshift: %08x\n", _pixfmt_AlphaShift
, _pixfmt_RedShift
, _pixfmt_GreenShift
, _pixfmt_BlueShift
));
93 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: Amask: %08x Rmask: %08x Gmask: %08x Bmask: %08x\n", _pixfmt_AlphaMask
, _pixfmt_RedMask
, _pixfmt_GreenMask
, _pixfmt_BlueMask
));
94 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: CM: %08x, stdpixfmt: %08x, BMType: %08x", _pixfmt_ColorModel
, _pixfmt_Stdpixfmt
, _pixfmt_BitMapType
));
98 (modeid
!= vHidd_ModeID_Invalid
) &&
99 (width
!= 0) && (height
!= 0) &&
103 We must only create depths that are supported by the friend drawable
104 Currently we only support the default depth
107 width
= (width
+ 15) & ~15;
109 data
->height
= height
;
113 data
->bytesperpix
= 1;
115 data
->bytesperpix
= 4;
117 data
->bytesperpix
= 3;
119 data
->bytesperpix
= 2;
121 data
->data
= &XSD(cl
)->data
;
123 #if !defined(DEBUGDISPLAY)
127 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[0] = 6 * 4;
128 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[1] = VCTAG_REQ
;
129 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[2] = VCTAG_FBFREE
;
130 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[3] = 0;
131 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[4] = 0;
132 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[5] = 0; // terminate tags
133 VCMBoxWrite(VCMB_BASE
, VCMB_PROPCHAN
, (unsigned int)(&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
);
134 VCMBoxRead(VCMB_BASE
, VCMB_PROPCHAN
);
137 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[1] = VCTAG_REQ
;
139 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[2] = VCTAG_SETRES
;
140 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[3] = 8;
141 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[4] = 8;
142 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[5] = data
->width
;
143 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[6] = data
->height
;
145 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[7] = VCTAG_SETVRES
; // duplicate physical size...
146 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[8] = 8;
147 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[9] = 8;
148 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[10] = data
->width
;
149 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[11] = data
->height
;
151 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[12] = VCTAG_SETDEPTH
;
152 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[13] = 4;
153 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[14] = 4;
154 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[15] = data
->bpp
;
156 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[16] = VCTAG_FBALLOC
;
157 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[17] = 8;
158 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[18] = 4;
159 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[19] = 16;
160 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[20] = 0;
162 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[21] = 0; // terminate tags
164 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[0] = (22 << 2); // fill in request size
166 #if !defined(DEBUGDISPLAY)
167 VCMBoxWrite(VCMB_BASE
, VCMB_PROPCHAN
, (unsigned int)(&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
);
168 if ((VCMBoxRead(VCMB_BASE
, VCMB_PROPCHAN
) == (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
)
169 && ((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[1] == VCTAG_RESP
)
170 && ((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[18] == (VCTAG_RESP
+ 8)))
172 struct TagItem buffertags
[] = {
173 { aHidd_ChunkyBM_Buffer
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[19] },
174 { aHidd_BitMap_BytesPerRow
, 0 },
178 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[0] = 7 * 4;
179 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[1] = VCTAG_REQ
;
180 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[2] = VCTAG_GETPITCH
;
181 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[3] = 4;
182 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[4] = 0;
183 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[5] = 0;
184 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[6] = 0; // terminate tag
186 VCMBoxWrite(VCMB_BASE
, VCMB_PROPCHAN
, (unsigned int)(&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
);
187 if ((VCMBoxRead(VCMB_BASE
, VCMB_PROPCHAN
) == (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
)
188 && ((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[4] == (VCTAG_RESP
+ 4)))
190 // Set the bitmaps stride..
191 buffertags
[1].ti_Data
= (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[5];
195 buffertags
[1].ti_Tag
= TAG_DONE
;
197 data
->VideoData
= buffertags
[0].ti_Data
;
198 OOP_SetAttrs(o
, buffertags
);
199 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: FrameBuffer @ 0x%p\n", data
->VideoData
));
201 ReturnPtr("VideoCoreGfx.OnBitMap::New: Obj", OOP_Object
*, o
);
202 #if !defined(DEBUGDISPLAY)
208 D(bug("[VideoCoreGfx] VideoCoreGfx.OnBitMap::New: Failed to get PixFmt obj??\n"));
212 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
213 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
216 } /* if created object */
217 ReturnPtr("VideoCoreGfx.OnBitMap::New: Obj", OOP_Object
*, o
);
220 /********** Bitmap::Dispose() ***********************************/
222 VOID
MNAME_ROOT(Dispose
)(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
224 EnterFunc(bug("VideoCoreGfx.OnBitMap::Dispose()\n"));
225 OOP_DoSuperMethod(cl
, o
, msg
);
226 ReturnVoid("VideoCoreGfx.OnBitMap::Dispose");