wayland-shm: refactor _evas_shm_surface_data_get()
authorDerek Foreman <derekf@osg.samsung.com>
Thu, 30 Jul 2015 15:45:05 +0000 (11:45 -0400)
committerChris Michael <cp.michael@samsung.com>
Thu, 30 Jul 2015 15:45:05 +0000 (11:45 -0400)
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
src/modules/evas/engines/wayland_shm/evas_shm.c

index 72d071a..a702155 100644 (file)
@@ -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);
index a6d90be..ee01f12 100644 (file)
@@ -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