2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
5 Desc: Offscreen bitmap class for X11 hidd.
9 /****************************************************************************************/
11 #include "x11_debug.h"
16 #include <X11/Xutil.h>
17 #include <X11/cursorfont.h>
18 #include <X11/keysym.h>
22 #include <proto/oop.h>
23 #include <proto/utility.h>
25 #include <exec/memory.h>
26 #include <exec/lists.h>
27 #include <graphics/rastport.h>
28 #include <graphics/gfx.h>
30 #include <hidd/graphics.h>
32 #include "x11gfx_intern.h"
36 /****************************************************************************************/
38 BOOL
X11BM_InitPM(OOP_Class
*cl
, OOP_Object
*o
, struct TagItem
*attrList
)
41 Drawable friend_drawable
= 0;
43 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
45 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__
));
47 /* Retrieve bitmap size from superclass */
48 OOP_GetAttr(o
, aHidd_BitMap_Width
, &data
->width
);
49 OOP_GetAttr(o
, aHidd_BitMap_Height
, &data
->height
);
50 OOP_GetAttr(o
, aHidd_BitMap_Depth
, &depth
);
52 friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, 0, attrList
);
55 /* Get the X11 window from the friend bitmap */
56 OOP_GetAttr(friend, aHidd_X11BitMap_Drawable
, &friend_drawable
);
61 /* If no friend, or friend is not X11 bitmap, use default friend drawable */
62 friend_drawable
= XSD(cl
)->dummy_window_for_creating_pixmaps
;
66 * We must only create depths that are supported by the friend drawable
67 * Currently we only support the default depth, and depth 1
71 depth
= DefaultDepth(data
->display
, data
->screen
);
75 /* Need this because of stipple bug in XFree86 :-( */
79 D(bug("[X11OffBm] %s: Creating X Pixmap, 0x%p, %ld, %ld, %ld\n", __PRETTY_FUNCTION__
, friend_drawable
, data
->width
, data
->height
, depth
));
83 DRAWABLE(data
) = XCALL(XCreatePixmap
, data
->display
, friend_drawable
, data
->width
, data
->height
, depth
);
84 XCALL(XFlush
, data
->display
);
88 return DRAWABLE(data
) ? TRUE
: FALSE
;
91 /****************************************************************************************/
93 VOID
X11BM_DisposePM(struct bitmap_data
*data
)
95 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__
));
101 XCALL(XFreePixmap
, GetSysDisplay(), DRAWABLE(data
));
102 XCALL(XFlush
, GetSysDisplay());
108 /****************************************************************************************/
110 VOID
X11BM_ClearPM(struct bitmap_data
*data
, HIDDT_Pixel bg
)
112 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__
));
114 XCALL(XSetForeground
, data
->display
, data
->gc
, bg
);
115 XCALL(XFillRectangle
, data
->display
, DRAWABLE(data
), data
->gc
, 0, 0, data
->width
, data
->height
);