f976f93493c3f4fb494be416aff6b3781ce6f7fc
[framework/uifw/ecore.git] / src / lib / ecore_x / xcb / ecore_xcb_pixmap.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #include "ecore_xcb_private.h"
6
7
8 /**
9  * @defgroup Ecore_X_Pixmap_Group X Pixmap Functions
10  *
11  * Functions that operate on pixmaps.
12  */
13
14
15 /**
16  * Creates a new pixmap.
17  * @param   win Window used to determine which screen of the display the
18  *              pixmap should be created on.  If 0, the default root window
19  *              is used.
20  * @param   w   Width of the new pixmap.
21  * @param   h   Height of the new pixmap.
22  * @param   dep Depth of the pixmap.  If 0, the default depth of the default
23  *              screen is used.
24  * @return  New pixmap.
25  * @ingroup Ecore_X_Pixmap_Group
26  */
27 EAPI Ecore_X_Pixmap
28 ecore_x_pixmap_new(Ecore_X_Window win,
29                    int            w,
30                    int            h,
31                    int            dep)
32 {
33    Ecore_X_Pixmap pmap;
34
35    if (win == 0) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
36    if (dep == 0) dep = ((xcb_screen_t *)_ecore_xcb_screen)->root_depth;
37
38    pmap = xcb_generate_id(_ecore_xcb_conn);
39    xcb_create_pixmap(_ecore_xcb_conn, dep, pmap, win, w, h);
40
41    return pmap;
42 }
43
44
45 /**
46  * Deletes the reference to the given pixmap.
47  *
48  * If no other clients have a reference to the given pixmap, the server
49  * will destroy it.
50  *
51  * @param   pmap The given pixmap.
52  * @ingroup Ecore_X_Pixmap_Group
53  */
54 EAPI void
55 ecore_x_pixmap_del(Ecore_X_Pixmap pmap)
56 {
57    xcb_free_pixmap(_ecore_xcb_conn, pmap);
58 }
59
60
61 /**
62  * Pastes a rectangular area of the given pixmap onto the given drawable.
63  * @param   pmap The given pixmap.
64  * @param   dest The given drawable.
65  * @param   gc   The graphics context which governs which operation will
66  *               be used to paste the area onto the drawable.
67  * @param   sx   The X position of the area on the pixmap.
68  * @param   sy   The Y position of the area on the pixmap.
69  * @param   w    The width of the area.
70  * @param   h    The height of the area.
71  * @param   dx   The X position at which to paste the area on @p dest.
72  * @param   dy   The Y position at which to paste the area on @p dest.
73  * @ingroup Ecore_X_Pixmap_Group
74  */
75 EAPI void
76 ecore_x_pixmap_paste(Ecore_X_Pixmap   pmap,
77                      Ecore_X_Drawable dest,
78                      Ecore_X_GC       gc,
79                      int              sx,
80                      int              sy,
81                      int              w,
82                      int              h,
83                      int              dx,
84                      int              dy)
85 {
86    xcb_copy_area(_ecore_xcb_conn, pmap, dest, gc, sx, sy, dx, dy, w, h);
87 }
88
89
90 /**
91  * Retrieves the size of the given pixmap.
92  * @param   pmap The given pixmap.
93  * @param   x    Pointer to an integer in which to store the X position.
94  * @param   y    Pointer to an integer in which to store the Y position.
95  * @param   w    Pointer to an integer in which to store the width.
96  * @param   h    Pointer to an integer in which to store the height.
97  * @ingroup Ecore_X_Pixmap_Group
98  */
99 EAPI void
100 ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap, int *x, int *y, int *w, int *h)
101 {
102    if (pmap)
103       ecore_x_drawable_geometry_get(pmap, x, y, w, h);
104 }
105
106
107 /**
108  * Retrieves the depth of the given pixmap.
109  * @param   pmap The given pixmap.
110  * @return  The depth of the pixmap.
111  * @ingroup Ecore_X_Pixmap_Group
112  */
113 EAPI int
114 ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap)
115 {
116    return ecore_x_drawable_depth_get(pmap);
117 }