Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_damage.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif /* ifdef HAVE_CONFIG_H */
4
5 #include "ecore_x_private.h"
6 #include "Ecore_X.h"
7
8 static Eina_Bool _damage_available = EINA_FALSE;
9 #ifdef ECORE_XDAMAGE
10 static int _damage_major, _damage_minor;
11 #endif /* ifdef ECORE_XDAMAGE */
12
13 void
14 _ecore_x_damage_init(void)
15 {
16 #ifdef ECORE_XDAMAGE
17    _damage_major = 1;
18    _damage_minor = 0;
19
20    LOGFN(__FILE__, __LINE__, __FUNCTION__);
21    if (XDamageQueryVersion(_ecore_x_disp, &_damage_major, &_damage_minor))
22      _damage_available = EINA_TRUE;
23    else
24      _damage_available = EINA_FALSE;
25
26 #else /* ifdef ECORE_XDAMAGE */
27    _damage_available = EINA_FALSE;
28 #endif /* ifdef ECORE_XDAMAGE */
29 }
30
31 EAPI Eina_Bool
32 ecore_x_damage_query(void)
33 {
34    return _damage_available;
35 }
36
37 EAPI Ecore_X_Damage
38 ecore_x_damage_new(Ecore_X_Drawable d,
39                    Ecore_X_Damage_Report_Level level)
40 {
41 #ifdef ECORE_XDAMAGE
42    Ecore_X_Damage damage;
43
44    LOGFN(__FILE__, __LINE__, __FUNCTION__);
45    damage = XDamageCreate(_ecore_x_disp, d, level);
46    return damage;
47 #else /* ifdef ECORE_XDAMAGE */
48    return 0;
49 #endif /* ifdef ECORE_XDAMAGE */
50 }
51
52 EAPI void
53 ecore_x_damage_free(Ecore_X_Damage damage)
54 {
55 #ifdef ECORE_XDAMAGE
56    LOGFN(__FILE__, __LINE__, __FUNCTION__);
57    XDamageDestroy(_ecore_x_disp, damage);
58 #endif /* ifdef ECORE_XDAMAGE */
59 }
60
61 EAPI void
62 ecore_x_damage_subtract(Ecore_X_Damage damage,
63                         Ecore_X_Region repair,
64                         Ecore_X_Region parts)
65 {
66 #ifdef ECORE_XDAMAGE
67    LOGFN(__FILE__, __LINE__, __FUNCTION__);
68    XDamageSubtract(_ecore_x_disp, damage, repair, parts);
69 #endif /* ifdef ECORE_XDAMAGE */
70 }
71