devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=157ad667b491071a92d1480256b79f859c045783

commit 157ad667b491071a92d1480256b79f859c045783
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Thu Jul 30 11:45:05 2015 -0400

    wayland-shm: refactor _evas_shm_surface_data_get()
    
    Summary:
    Split out the buffer picking stuff because we're going to want to call
    it from somewhere else.
    
    Reviewers: zmike, devilhorns
    
    Reviewed By: devilhorns
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2889
---
 src/modules/evas/engines/wayland_shm/evas_engine.h |  1 +
 src/modules/evas/engines/wayland_shm/evas_shm.c    | 42 ++++++++++++----------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h 
b/src/modules/evas/engines/wayland_shm/evas_engine.h
index 72d071a..a702155 100644
--- a/src/modules/evas/engines/wayland_shm/evas_engine.h
+++ b/src/modules/evas/engines/wayland_shm/evas_engine.h
@@ -120,6 +120,7 @@ Shm_Surface *_evas_shm_surface_create(struct wl_shm *shm, 
struct wl_surface *sur
 void _evas_shm_surface_destroy(Shm_Surface *surface);
 void _evas_shm_surface_reconfigure(Shm_Surface *surface, int dx, int dy, int 
w, int h, int num_buff, uint32_t flags);
 void *_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h);
+Eina_Bool _evas_shm_surface_assign(Shm_Surface *surface);
 void _evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle *rects, 
unsigned int count);
 
 Outbuf *_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, 
Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface);
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c 
b/src/modules/evas/engines/wayland_shm/evas_shm.c
index a6d90be..ee01f12 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -404,28 +404,34 @@ _evas_shm_surface_reconfigure(Shm_Surface *surface, int 
dx, int dy, int w, int h
      }
 }
 
-void *
-_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h)
+Eina_Bool
+_evas_shm_surface_assign(Shm_Surface *surface)
 {
-   Shm_Leaf *leaf = NULL;
-   int i = 0;
+   int i;
 
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
-   if (w) *w = 0;
-   if (h) *h = 0;
-
-   for (; i < surface->num_buff; i++)
+   for (i = 0; i < surface->num_buff; i++)
      {
         if (surface->leaf[i].busy) continue;
-        if ((!leaf) || (leaf->valid))
+        if (surface->leaf[i].valid)
           {
-             leaf = &surface->leaf[i];
-             break;
+             surface->current = &surface->leaf[i];
+             return EINA_TRUE;
           }
      }
+   return EINA_FALSE;
+}
+
+void *
+_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h)
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (!leaf)
+   _evas_shm_surface_assign(surface);
+
+   if (w) *w = 0;
+   if (h) *h = 0;
+
+   if (!surface->current)
      {
         /* WRN("All buffers held by server"); */
         return NULL;
@@ -433,12 +439,10 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, 
int *h)
 
    /* DBG("Leaf Data Get %d", (int)(leaf - &surface->leaf[0])); */
 
-   if (w) *w = leaf->w;
-   if (h) *h = leaf->h;
-
-   surface->curr_buff = (int)(leaf - &surface->leaf[0]);
+   if (w) *w = surface->current->w;
+   if (h) *h = surface->current->h;
 
-   return leaf->data->map;
+   return surface->current->data->map;
 }
 
 void

-- 


Reply via email to