2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: Offscreen bitmap class for X11 hidd.
9 /****************************************************************************************/
11 #include "x11_debug.h"
13 #include <proto/utility.h>
16 #include "x11_types.h"
18 #include "x11_hostlib.h"
19 #include "x11gfx_bitmap.h"
21 /****************************************************************************************/
23 BOOL
X11BM_InitPM(OOP_Class
*cl
, OOP_Object
*o
, struct TagItem
*attrList
)
26 Drawable friend_drawable
= 0;
28 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
30 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__
));
32 /* Retrieve bitmap size from superclass */
33 OOP_GetAttr(o
, aHidd_BitMap_Width
, &data
->width
);
34 OOP_GetAttr(o
, aHidd_BitMap_Height
, &data
->height
);
35 OOP_GetAttr(o
, aHidd_BitMap_Depth
, &depth
);
37 friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, 0, attrList
);
40 /* Get the X11 window from the friend bitmap */
41 OOP_GetAttr(friend, aHidd_BitMap_X11_Drawable
, &friend_drawable
);
46 /* If no friend, or friend is not X11 bitmap, use default friend drawable */
47 friend_drawable
= XSD(cl
)->dummy_window_for_creating_pixmaps
;
51 * We must only create depths that are supported by the friend drawable
52 * Currently we only support the default depth, and depth 1
56 depth
= DefaultDepth(data
->display
, data
->screen
);
60 /* Need this because of stipple bug in XFree86 :-( */
64 D(bug("[X11OffBm] %s: Creating X Pixmap, 0x%p, %ld, %ld, %ld\n", __PRETTY_FUNCTION__
, friend_drawable
, data
->width
, data
->height
, depth
));
68 DRAWABLE(data
) = XCALL(XCreatePixmap
, data
->display
, friend_drawable
, data
->width
, data
->height
, depth
);
69 XCALL(XFlush
, data
->display
);
73 return DRAWABLE(data
) ? TRUE
: FALSE
;
76 /****************************************************************************************/
78 VOID
X11BM_DisposePM(struct bitmap_data
*data
)
80 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__
));
86 XCALL(XFreePixmap
, GetSysDisplay(), DRAWABLE(data
));
87 XCALL(XFlush
, GetSysDisplay());
93 /****************************************************************************************/
95 VOID
X11BM_ClearPM(struct bitmap_data
*data
, HIDDT_Pixel bg
)
97 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__
));
99 XCALL(XSetForeground
, data
->display
, data
->gc
, bg
);
100 XCALL(XFillRectangle
, data
->display
, DRAWABLE(data
), data
->gc
, 0, 0, data
->width
, data
->height
);