2 Copyright © 2013-2017, The AROS Development Team. All rights reserved.
5 Desc: BCM VideoCore4 Gfx Hidd Onscreen Bitmap Class.
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <proto/oop.h>
15 #include <proto/mbox.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>
26 #include "vc4gfx_bitmap.h"
27 #include "vc4gfx_hidd.h"
29 #include LC_LIBDEFS_FILE
35 #define MBoxBase (&((struct VideoCoreGfxBase *)cl->UserData)->vsd)->vcsd_MBoxBase
37 #define MNAME_ROOT(x) VideoCoreGfxOnBM__Root__ ## x
38 #define MNAME_BM(x) VideoCoreGfxOnBM__Hidd_BitMap__ ## x
41 #include "vc4gfx_bitmapclass.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_MBoxMessage
[0] = AROS_LE2LONG(6 * 4);
128 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[1] = AROS_LE2LONG(VCTAG_REQ
);
129 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[2] = AROS_LE2LONG(VCTAG_FBFREE
);
130 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[3] = 0;
131 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[4] = 0;
132 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[5] = 0; // terminate tags
133 MBoxWrite((void *)VCMB_BASE
, VCMB_PROPCHAN
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
);
134 MBoxRead((void *)VCMB_BASE
, VCMB_PROPCHAN
);
137 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[1] = AROS_LE2LONG(VCTAG_REQ
);
139 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[2] = AROS_LE2LONG(VCTAG_SETRES
);
140 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[3] = AROS_LE2LONG(8);
141 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[4] = AROS_LE2LONG(8);
142 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[5] = AROS_LE2LONG(data
->width
);
143 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[6] = AROS_LE2LONG(data
->height
);
145 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[7] = AROS_LE2LONG(VCTAG_SETVRES
); // duplicate physical size...
146 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[8] = AROS_LE2LONG(8);
147 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[9] = AROS_LE2LONG(8);
148 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[10] = AROS_LE2LONG(data
->width
);
149 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[11] = AROS_LE2LONG(data
->height
);
151 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[12] = AROS_LE2LONG(VCTAG_SETDEPTH
);
152 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[13] = AROS_LE2LONG(4);
153 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[14] = AROS_LE2LONG(4);
154 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[15] = AROS_LE2LONG(data
->bpp
);
156 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[16] = AROS_LE2LONG(VCTAG_FBALLOC
);
157 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[17] = AROS_LE2LONG(8);
158 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[18] = AROS_LE2LONG(4);
159 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[19] = AROS_LE2LONG(16);
160 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[20] = 0;
162 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[21] = 0; // terminate tags
164 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[0] = AROS_LE2LONG((22 << 2)); // fill in request size
166 #if !defined(DEBUGDISPLAY)
167 MBoxWrite((void *)VCMB_BASE
, VCMB_PROPCHAN
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
);
168 if ((MBoxRead((void *)VCMB_BASE
, VCMB_PROPCHAN
) == (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
)
169 && ((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[1] == AROS_LE2LONG(VCTAG_RESP
))
170 && ((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[18] == AROS_LE2LONG(VCTAG_RESP
+ 8)))
172 struct TagItem buffertags
[] = {
173 { aHidd_ChunkyBM_Buffer
, AROS_LE2LONG((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[19]) & 0x3fffffff },
174 { aHidd_BitMap_BytesPerRow
, 0 },
178 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[0] = AROS_LE2LONG(7 * 4);
179 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[1] = AROS_LE2LONG(VCTAG_REQ
);
180 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[2] = AROS_LE2LONG(VCTAG_GETPITCH
);
181 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[3] = AROS_LE2LONG(4);
182 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[4] = 0;
183 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[5] = 0;
184 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[6] = 0; // terminate tag
186 MBoxWrite((void *)VCMB_BASE
, VCMB_PROPCHAN
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
);
187 if ((MBoxRead((void *)VCMB_BASE
, VCMB_PROPCHAN
) == (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
)
188 && ((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[4] == AROS_LE2LONG(VCTAG_RESP
+ 4)))
190 // Set the bitmaps stride..
191 buffertags
[1].ti_Data
= AROS_LE2LONG((&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_MBoxMessage
[5]);
195 buffertags
[1].ti_Tag
= TAG_DONE
;
197 data
->VideoData
= (UBYTE
*)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");