wip prep commit in lieu of gfx subsystem update changes.
[AROS.git] / arch / all-hosted / hidd / x11 / x11gfx_offbitmap.c
blob928996593ad2a4b289223d8998c7e86a8a5c6422
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Offscreen bitmap class for X11 hidd.
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include "x11_debug.h"
13 #include <proto/utility.h>
14 #include <hidd/gfx.h>
16 #include "x11_types.h"
17 #include "x11.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)
25 OOP_Object *friend;
26 Drawable friend_drawable = 0;
27 IPTR depth;
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);
38 if (friend)
40 /* Get the X11 window from the friend bitmap */
41 OOP_GetAttr(friend, aHidd_BitMap_X11_Drawable, &friend_drawable);
44 if (!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;
50 /*
51 * We must only create depths that are supported by the friend drawable
52 * Currently we only support the default depth, and depth 1
54 if (depth != 1)
56 depth = DefaultDepth(data->display, data->screen);
58 else
60 /* Need this because of stipple bug in XFree86 :-( */
61 data->width += 32;
64 D(bug("[X11OffBm] %s: Creating X Pixmap, 0x%p, %ld, %ld, %ld\n", __PRETTY_FUNCTION__, friend_drawable, data->width, data->height, depth));
66 HostLib_Lock();
68 DRAWABLE(data) = XCALL(XCreatePixmap, data->display, friend_drawable, data->width, data->height, depth);
69 XCALL(XFlush, data->display);
71 HostLib_Unlock();
73 return DRAWABLE(data) ? TRUE : FALSE;
76 /****************************************************************************************/
78 VOID X11BM_DisposePM(struct bitmap_data *data)
80 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__));
82 if (DRAWABLE(data))
84 HostLib_Lock();
86 XCALL(XFreePixmap, GetSysDisplay(), DRAWABLE(data));
87 XCALL(XFlush, GetSysDisplay());
89 HostLib_Unlock();
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);