Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_pixmap.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif /* ifdef HAVE_CONFIG_H */
4
5 #include "Ecore.h"
6 #include "ecore_x_private.h"
7 #include "Ecore_X.h"
8
9 /**
10  * @defgroup Ecore_X_Pixmap_Group X Pixmap Functions
11  *
12  * Functions that operate on pixmaps.
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    LOGFN(__FILE__, __LINE__, __FUNCTION__);
34    if (win == 0)
35      win = DefaultRootWindow(_ecore_x_disp);
36
37    if (dep == 0)
38      dep = DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
39
40    return XCreatePixmap(_ecore_x_disp, win, w, h, dep);
41 }
42
43 /**
44  * Deletes the reference to the given pixmap.
45  *
46  * If no other clients have a reference to the given pixmap, the server
47  * will destroy it.
48  *
49  * @param   pmap The given pixmap.
50  * @ingroup Ecore_X_Pixmap_Group
51  */
52 EAPI void
53 ecore_x_pixmap_free(Ecore_X_Pixmap pmap)
54 {
55    LOGFN(__FILE__, __LINE__, __FUNCTION__);
56    XFreePixmap(_ecore_x_disp, pmap);
57 }
58
59 /**
60  * Pastes a rectangular area of the given pixmap onto the given drawable.
61  * @param   pmap The given pixmap.
62  * @param   dest The given drawable.
63  * @param   gc   The graphics context which governs which operation will
64  *               be used to paste the area onto the drawable.
65  * @param   sx   The X position of the area on the pixmap.
66  * @param   sy   The Y position of the area on the pixmap.
67  * @param   w    The width of the area.
68  * @param   h    The height of the area.
69  * @param   dx   The X position at which to paste the area on @p dest.
70  * @param   dy   The Y position at which to paste the area on @p dest.
71  * @ingroup Ecore_X_Pixmap_Group
72  */
73 EAPI void
74 ecore_x_pixmap_paste(Ecore_X_Pixmap pmap,
75                      Ecore_X_Drawable dest,
76                      Ecore_X_GC gc,
77                      int sx,
78                      int sy,
79                      int w,
80                      int h,
81                      int dx,
82                      int dy)
83 {
84    LOGFN(__FILE__, __LINE__, __FUNCTION__);
85    XCopyArea(_ecore_x_disp, pmap, dest, gc, sx, sy, w, h, dx, dy);
86 }
87
88 /**
89  * Retrieves the size of the given pixmap.
90  * @param   pmap The given pixmap.
91  * @param   x    Pointer to an integer in which to store the X position.
92  * @param   y    Pointer to an integer in which to store the Y position.
93  * @param   w    Pointer to an integer in which to store the width.
94  * @param   h    Pointer to an integer in which to store the height.
95  * @ingroup Ecore_X_Pixmap_Group
96  */
97 EAPI void
98 ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap,
99                             int *x,
100                             int *y,
101                             int *w,
102                             int *h)
103 {
104    LOGFN(__FILE__, __LINE__, __FUNCTION__);
105    if (pmap)
106      ecore_x_drawable_geometry_get(pmap, x, y, w, h);
107 }
108
109 /**
110  * Retrieves the depth of the given pixmap.
111  * @param   pmap The given pixmap.
112  * @return  The depth of the pixmap.
113  * @ingroup Ecore_X_Pixmap_Group
114  */
115 EAPI int
116 ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap)
117 {
118    LOGFN(__FILE__, __LINE__, __FUNCTION__);
119    return ecore_x_drawable_depth_get(pmap);
120 }
121