discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=6aa9a9477e218b987424cf740b3f39020079a7d8

commit 6aa9a9477e218b987424cf740b3f39020079a7d8
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu Aug 6 19:16:10 2015 -0400

    add pixmap aliasing
    
    this provides the ability to alias one pixmap id as another pixmap
---
 src/bin/e_pixmap.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
 src/bin/e_pixmap.h |  2 ++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c
index 1ee17ac..2d5943e 100644
--- a/src/bin/e_pixmap.c
+++ b/src/bin/e_pixmap.c
@@ -10,6 +10,7 @@
 #include <uuid.h>
 
 static Eina_Hash *pixmaps[2] = {NULL};
+static Eina_Hash *aliases[2] = {NULL};
 
 struct _E_Pixmap
 {
@@ -155,6 +156,7 @@ _e_pixmap_find(E_Pixmap_Type type, va_list *l)
 #ifdef HAVE_WAYLAND
    uintptr_t id;
 #endif
+   E_Pixmap *cp;
    
    if (!pixmaps[type]) return NULL;
    switch (type)
@@ -162,13 +164,17 @@ _e_pixmap_find(E_Pixmap_Type type, va_list *l)
       case E_PIXMAP_TYPE_X:
 #ifndef HAVE_WAYLAND_ONLY
         xwin = va_arg(*l, uint32_t);
-        return eina_hash_find(pixmaps[type], &xwin);
+        cp = eina_hash_find(aliases[type], &xwin);
+        if (!cp) cp = eina_hash_find(pixmaps[type], &xwin);
+        return cp;
 #endif
         break;
       case E_PIXMAP_TYPE_WL:
 #ifdef HAVE_WAYLAND
         id = va_arg(*l, uintptr_t);
-        return eina_hash_find(pixmaps[type], &id);
+        cp = eina_hash_find(aliases[type], &id);
+        if (!cp) cp = eina_hash_find(pixmaps[type], &id);
+        return cp;
 #endif
         break;
       default: break;
@@ -881,3 +887,38 @@ e_pixmap_image_opaque_get(E_Pixmap *cp, int *x, int *y, 
int *w, int *h)
    if (h) *h = 0;
 #endif
 }
+
+E_API void
+e_pixmap_alias(E_Pixmap *cp, E_Pixmap_Type type, ...)
+{
+   va_list l;
+#ifndef HAVE_WAYLAND_ONLY
+   Ecore_X_Window xwin;
+#endif
+#ifdef HAVE_WAYLAND
+   uintptr_t id;
+#endif
+
+   va_start(l, type);
+   switch (type)
+     {
+      case E_PIXMAP_TYPE_X:
+#ifndef HAVE_WAYLAND_ONLY
+        xwin = va_arg(l, uint32_t);
+        if (!aliases[type])
+          aliases[type] = eina_hash_int32_new(NULL);
+        eina_hash_set(aliases[type], &xwin, cp);
+#endif
+        break;
+      case E_PIXMAP_TYPE_WL:
+#ifdef HAVE_WAYLAND
+        id = va_arg(l, uintptr_t);
+        if (!aliases[type])
+          aliases[type] = eina_hash_pointer_new(NULL);
+        eina_hash_set(aliases[type], &id, cp);
+#endif
+        break;
+      default: break;
+     }
+   va_end(l);
+}
diff --git a/src/bin/e_pixmap.h b/src/bin/e_pixmap.h
index 98ffe4a..c7c7a0c 100644
--- a/src/bin/e_pixmap.h
+++ b/src/bin/e_pixmap.h
@@ -49,6 +49,8 @@ E_API Eina_Bool e_pixmap_image_draw(E_Pixmap *cp, const 
Eina_Rectangle *r);
 E_API void e_pixmap_image_opaque_set(E_Pixmap *cp, int x, int y, int w, int h);
 E_API void e_pixmap_image_opaque_get(E_Pixmap *cp, int *x, int *y, int *w, int 
*h);
 
+E_API void e_pixmap_alias(E_Pixmap *cp, E_Pixmap_Type type, ...);
+
 static inline Eina_Bool
 e_pixmap_is_x(const E_Pixmap *cp)
 {

-- 


Reply via email to