Beispiel #1
0
void
evas_gl_preload_pop(Evas_GL_Texture *tex)
{
   Evas_GL_Texture_Async_Preload *async;
   Eina_List *l;

   if (!async_loader_init) return ;

   eina_lock_take(&async_loader_lock);

   if (async_gl_make_current && async_current && async_current->tex == tex)
     {
        Eina_Bool running = async_loader_running;
        evas_gl_make_current_cb tmp_cb = async_gl_make_current;
        Evas_GL_Texture_Async_Preload *current = async_current;
        void *tmp_data = async_engine_data;

        async_current_cancel = EINA_TRUE;
        async_current = NULL;
        eina_lock_release(&async_loader_lock);

        if (running) evas_gl_preload_render_lock(tmp_cb, tmp_data);

        evas_gl_common_texture_free(current->tex, EINA_FALSE);
#ifdef EVAS_CSERVE2
        if (evas_cache2_image_cached(&current->im->cache_entry))
          evas_cache2_image_close(&current->im->cache_entry);
        else
#endif
        evas_cache_image_drop(&current->im->cache_entry);
        free(current);

        if (running) evas_gl_preload_render_unlock(tmp_cb, tmp_data);

        return ;
     }

   EINA_LIST_FOREACH(async_loader_tex, l, async)
     if (async->tex == tex)
       {
          async_loader_tex = eina_list_remove_list(async_loader_tex, l);

          evas_gl_common_texture_free(async->tex, EINA_FALSE);
#ifdef EVAS_CSERVE2
          if (evas_cache2_image_cached(&async->im->cache_entry))
            evas_cache2_image_close(&async->im->cache_entry);
          else
#endif
            evas_cache_image_drop(&async->im->cache_entry);
          free(async);

          break;
       }

   eina_lock_release(&async_loader_lock);
}
void 
evas_outbuf_free(Outbuf *ob) 
{
   if (!ob) return;
   if (ob->priv.buffer) evas_cache_image_drop(&ob->priv.buffer->cache_entry);
   free(ob);
}
Beispiel #3
0
void 
_evas_outbuf_free(Outbuf *ob)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);

   while (ob->priv.pending_writes)
     {
        RGBA_Image *img;
        Eina_Rectangle *rect;

        img = ob->priv.pending_writes->data;
        ob->priv.pending_writes = 
          eina_list_remove_list(ob->priv.pending_writes, ob->priv.pending_writes);

        rect = img->extended_info;

#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          evas_cache2_image_close(&img->cache_entry);
        else
#endif
          evas_cache_image_drop(&img->cache_entry);

        eina_rectangle_free(rect);
     }

   _evas_outbuf_flush(ob, NULL, MODE_FULL);
   _evas_outbuf_idle_flush(ob);

   if (ob->surface) _evas_shm_surface_destroy(ob->surface);

   eina_array_flush(&ob->priv.onebuf_regions);

   free(ob);
}
Beispiel #4
0
void
evas_buffer_outbuf_buf_switch_buffer(Outbuf *buf)
{
   if (buf->func.switch_buffer)
     {
        buf->dest = buf->func.switch_buffer(buf->switch_data, buf->dest);
        if (buf->priv.back_buf)
          {
#ifdef EVAS_CSERVE2
             if (evas_cserve2_use_get())
               {
                  evas_cache2_image_close(&buf->priv.back_buf->cache_entry);
                  buf->priv.back_buf = (RGBA_Image *) evas_cache2_image_data(evas_common_image_cache2_get(),
                                                                            buf->w, buf->h,
                                                                            buf->dest,
                                                                            buf->depth == OUTBUF_DEPTH_ARGB_32BPP_8888_8888 ? 1 : 0,
                                                                            EVAS_COLORSPACE_ARGB8888);
               }
             else
#endif
               {
                  evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
                  buf->priv.back_buf = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
                                                                            buf->w, buf->h,
                                                                            buf->dest,
                                                                            buf->depth == OUTBUF_DEPTH_ARGB_32BPP_8888_8888 ? 1 : 0,
                                                                            EVAS_COLORSPACE_ARGB8888);
               }
          }
     }
}
Beispiel #5
0
static void
_evas_gl_preload_main_loop_wakeup(void)
{
   Evas_GL_Texture_Async_Preload *async;
   evas_gl_make_current_cb cb = async_gl_make_current;
   void *data = async_engine_data;
   Eina_Bool running = async_loader_running;

   if (running) evas_gl_preload_render_lock(cb, data);
   EINA_LIST_FREE(async_loader_todie, async)
     {
        Eo *target;

        EINA_LIST_FREE(async->tex->targets, target)
          eo_do(target, evas_obj_image_pixels_dirty_set(EINA_TRUE));
        async->im->cache_entry.flags.preload_done = 0;
        async->tex->was_preloaded = EINA_TRUE;

        async->tex->ptt->allocations = eina_list_remove(async->tex->ptt->allocations, async->tex->aptt);
        pt_unref(async->tex->ptt);
        async->tex->ptt = NULL;
        free(async->tex->aptt);
        async->tex->aptt = NULL;

        evas_gl_common_texture_free(async->tex, EINA_FALSE);
        evas_cache_image_drop(&async->im->cache_entry);
        free(async);
     }
void
evas_fb_outbuf_fb_free(Outbuf *buf)
{
   /* FIXME: impliment */
   WRN("destroying fb info.. not implemented!!!! WARNING. LEAK!");
   if (buf->priv.back_buf)
     evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
   free(buf);
}
void 
evas_outbuf_resize(Outbuf *ob, int w, int h) 
{
   if (!ob) return;
   if ((ob->w == w) && (ob->h == h)) return;
   ob->w = w;
   ob->h = h;
   if (ob->priv.buffer) evas_cache_image_drop(&ob->priv.buffer->cache_entry);
   ob->priv.buffer = NULL;
}
Beispiel #8
0
void 
_evas_outbuf_idle_flush(Outbuf *ob)
{
   RGBA_Image *img;
   Eina_Rectangle *rect;

   if (ob->priv.onebuf)
     {
        img = ob->priv.onebuf;
        ob->priv.onebuf = NULL;

        rect = img->extended_info;
        eina_rectangle_free(rect);

#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          evas_cache2_image_close(&img->cache_entry);
        else
#endif
          evas_cache_image_drop(&img->cache_entry);
     }
   else
     {
        while (ob->priv.prev_pending_writes)
          {
             img = ob->priv.prev_pending_writes->data;
             ob->priv.prev_pending_writes = 
               eina_list_remove_list(ob->priv.prev_pending_writes, 
                                     ob->priv.prev_pending_writes);
             rect = img->extended_info;
#ifdef EVAS_CSERVE2
             if (evas_cserve2_use_get())
               evas_cache2_image_close(&img->cache_entry);
             else
#endif
               evas_cache_image_drop(&img->cache_entry);

             eina_rectangle_free(rect);
          }
     }
}
DDraw_Output_Buffer *
evas_software_ddraw_output_buffer_new(HWND                window,
                                      LPDIRECTDRAW        object,
                                      LPDIRECTDRAWSURFACE surface_primary,
                                      LPDIRECTDRAWSURFACE surface_back,
                                      LPDIRECTDRAWSURFACE surface_source,
                                      int                 width,
                                      int                 height)
{
   DDSURFACEDESC        surface_desc;
   DDraw_Output_Buffer *ddob;

   ddob = (DDraw_Output_Buffer *)calloc(1, sizeof(DDraw_Output_Buffer));
   if (!ddob) return NULL;

   ddob->dd.window = window;
   ddob->dd.object = object;
   ddob->dd.surface_primary = surface_primary;
   ddob->dd.surface_back = surface_back;
   ddob->dd.surface_source = surface_source;
   ddob->width = width;
   ddob->height = height;
   ddob->pitch = width * 2;

   ZeroMemory(&surface_desc, sizeof(surface_desc));
   surface_desc.dwSize = sizeof(surface_desc);

   if (FAILED(ddob->dd.surface_source->Lock(NULL,
                                            &surface_desc,
                                            DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                                            NULL)))
     {
        free(ddob);
        return NULL;
     }

   ddob->data = (DATA16 *)surface_desc.lpSurface;

   if (FAILED(ddob->dd.surface_source->Unlock(NULL)))
     {
        free(ddob);
        return NULL;
     }
   if (ddob->im)
     evas_cache_image_drop(&ddob->im->cache_entry);

   ddob->im =  (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *) ddob->data, 0, EVAS_COLORSPACE_RGB565_A5P);
   if (ddob->im)
     ddob->im->stride = ddob->pitch;

   return ddob;
}
Beispiel #10
0
void
evas_buffer_outbuf_buf_free_region_for_update(Outbuf *buf, RGBA_Image *update)
{
   if (update != buf->priv.back_buf)
     {
#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          evas_cache2_image_close(&update->cache_entry);
        else
#endif
          evas_cache_image_drop(&update->cache_entry);
     }
}
Beispiel #11
0
static Engine_Image_Entry *
_evas_cache_engine_image_alloc(Evas_Cache_Engine_Image *cache,
                               Image_Entry *ie,
                               const char *hkey)
{
   Engine_Image_Entry   *eim;

   assert(cache);

   if (cache->func.alloc)
     eim = cache->func.alloc();
   else
     eim = malloc(sizeof (Engine_Image_Entry));

   if (!eim) goto on_error;
   memset(eim, 0, sizeof (Engine_Image_Entry));

   eim->cache = cache;
   if (ie)
     {
        eim->w = ie->w;
        eim->h = ie->h;
        eim->src = ie;
        eim->flags.need_parent = 1;
     }
   else
     {
        eim->w = -1;
        eim->h = -1;
        eim->flags.need_parent = 0;
        eim->src = NULL;
     }

   eim->flags.cached = 0;
   eim->references = 0;
   eim->cache_key = hkey;

   if (hkey)
     _evas_cache_engine_image_make_active(cache, eim, hkey);
   else
     _evas_cache_engine_image_make_dirty(cache, eim);

   return eim;

 on_error:
   if (eim)
     evas_cache_engine_image_drop(eim);
   eina_stringshare_del(hkey);
   if (ie) evas_cache_image_drop(ie);
   return NULL;
}
Beispiel #12
0
void
evas_buffer_outbuf_buf_free(Outbuf *buf)
{
   if (buf->priv.back_buf)
     {
#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          evas_cache2_image_close(&buf->priv.back_buf->cache_entry);
        else
#endif
        evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
     }
   free(buf);
}
void
evas_fb_outbuf_fb_reconfigure(Outbuf *buf, int w, int h, int rot, Outbuf_Depth depth)
{
   if ((w == buf->w) && (h == buf->h) &&
       (rot == buf->rot) && (depth == buf->depth))
     return;
   if (buf->priv.back_buf)
     {
	evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
	buf->priv.back_buf = NULL;
     }
   if (buf->priv.fb.fb)
     {
	/* FIXME: impliment this */
     }
   /* if backbuf delet it */
   /* resize window or reset fb mode */
   /* if (dithered) create new backbuf */
}
Beispiel #14
0
void 
evas_software_xcb_outbuf_free(Outbuf *buf) 
{
   while (buf->priv.pending_writes) 
     {
        RGBA_Image *im = NULL;
        Outbuf_Region *obr = NULL;

        im = buf->priv.pending_writes->data;
        buf->priv.pending_writes = 
          eina_list_remove_list(buf->priv.pending_writes, 
                                buf->priv.pending_writes);
        obr = im->extended_info;
#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          evas_cache2_image_close(&im->cache_entry);
        else
#endif
          evas_cache_image_drop(&im->cache_entry);

        if (obr->xcbob) _unfind_xcbob(obr->xcbob, EINA_FALSE);
        if (obr->mask) _unfind_xcbob(obr->mask, EINA_FALSE);
        free(obr);
     }

   evas_software_xcb_outbuf_idle_flush(buf);
   evas_software_xcb_outbuf_flush(buf, NULL, MODE_FULL);

   if (buf->priv.x11.xcb.gc)
     xcb_free_gc(buf->priv.x11.xcb.conn, buf->priv.x11.xcb.gc);
   if (buf->priv.x11.xcb.gcm)
     xcb_free_gc(buf->priv.x11.xcb.conn, buf->priv.x11.xcb.gcm);
   if (buf->priv.pal)
     evas_software_xcb_color_deallocate(buf->priv.x11.xcb.conn, 
                                        buf->priv.x11.xcb.cmap, 
                                        buf->priv.x11.xcb.visual, 
                                        buf->priv.pal);

   eina_array_flush(&buf->priv.onebuf_regions);

   free(buf);
   _clear_xcbob(EINA_FALSE);
}
Beispiel #15
0
static void
_evas_gl_preload_main_loop_wakeup(void)
{
   Evas_GL_Texture_Async_Preload *async;
   evas_gl_make_current_cb cb = async_gl_make_current;
   void *data = async_engine_data;
   Eina_Bool running = async_loader_running;

   if (running) evas_gl_preload_render_lock(cb, data);
   EINA_LIST_FREE(async_loader_todie, async)
     {
        Eo *target;

        if (async->tex)
          {
             EINA_LIST_FREE(async->tex->targets, target)
               evas_object_image_pixels_dirty_set(target, EINA_TRUE);
          }
        async->im->cache_entry.flags.preload_done = 0;
        if (async->tex)
          {
             async->tex->was_preloaded = EINA_TRUE;

             async->tex->ptt->allocations = 
               eina_list_remove(async->tex->ptt->allocations,
                                async->tex->aptt);
             eina_rectangle_pool_release(async->tex->aptt);
             async->tex->aptt = NULL;
             pt_unref(async->tex->ptt);
             async->tex->ptt = NULL;

             evas_gl_common_texture_free(async->tex, EINA_FALSE);
          }
#ifdef EVAS_CSERVE2
        if (evas_cache2_image_cached(&async->im->cache_entry))
          evas_cache2_image_close(&async->im->cache_entry);
        else
#endif
        evas_cache_image_drop(&async->im->cache_entry);
        free(async);
     }
Beispiel #16
0
static void
_evas_cache_engine_image_dealloc(Evas_Cache_Engine_Image *cache,
                                 Engine_Image_Entry *eim)
{
   Image_Entry *im;

   if (cache->func.debug) cache->func.debug("delete", eim);

   _evas_cache_engine_image_remove_activ(cache, eim);

   im = eim->src;
   cache->func.destructor(eim);
   if (im) evas_cache_image_drop(im);

   if (cache->func.dealloc) cache->func.dealloc(eim);
   else
     {
        memset(eim, 0, sizeof(Engine_Image_Entry));
        eina_freeq_ptr_add(eina_freeq_main_get(), eim, free, sizeof(*eim));
     }
}
void
evas_fb_outbuf_fb_set_have_backbuf(Outbuf *buf, int have_backbuf)
{
   if (buf->priv.back_buf)
     {
	if (have_backbuf) return;
        evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
	buf->priv.back_buf = NULL;
     }
   else
     {
	if (!have_backbuf) return;
	if (buf->priv.fb.fb)
	  {
	     if (buf->priv.fb.fb->fb_var.bits_per_pixel  < 24)
	       {
		  buf->priv.back_buf = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
                  buf->priv.back_buf = (RGBA_Image *) evas_cache_image_size_set(&buf->priv.back_buf->cache_entry, buf->w, buf->h);
	       }
	  }
     }
}
void 
evas_outbuf_free_region_for_update(Outbuf *ob, RGBA_Image *update) 
{
   if (!ob) return;
   if (update != ob->priv.buffer) evas_cache_image_drop(&update->cache_entry);
}
void
evas_fb_outbuf_fb_free_region_for_update(Outbuf *buf, RGBA_Image *update)
{
   if (update != buf->priv.back_buf) evas_cache_image_drop(&update->cache_entry);
}
Beispiel #20
0
void *
evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch) 
{
   RGBA_Image *im = NULL;
   Outbuf_Region *obr = NULL;
   Eina_Bool use_shm = EINA_TRUE;
   Eina_Bool alpha = EINA_FALSE;
   int bpl = 0;

   if ((buf->onebuf) && (buf->priv.x11.xcb.shm)) 
     {
        Eina_Rectangle *rect;

        RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);

        if (!(obr = calloc(1, sizeof(Outbuf_Region))))
          return NULL;

        if (!(rect = eina_rectangle_new(x, y, w, h))) 
          {
             free(obr);
             return NULL;
          }

        if ((eina_array_push(&buf->priv.onebuf_regions, rect)) &&
            (buf->priv.onebuf))
          {
             if (cx) *cx = x;
             if (cy) *cy = y;
             if (cw) *cw = w;
             if (ch) *ch = h;
             if (!buf->priv.synced) 
               {
                  _xcbob_sync(buf->priv.x11.xcb.conn);
                  buf->priv.synced = EINA_TRUE;
               }
             free(obr);
             return buf->priv.onebuf;
          }
        obr->x = 0;
        obr->y = 0;
        obr->w = buf->w;
        obr->h = buf->h;
        if (cx) *cx = x;
        if (cy) *cy = y;
        if (cw) *cw = w;
        if (ch) *ch = h;

        alpha = ((buf->priv.x11.xcb.mask) || (buf->priv.destination_alpha));
        use_shm = buf->priv.x11.xcb.shm;

        if ((buf->rot == 0) &&
            (buf->priv.x11.xcb.imdepth == 32) &&
            (buf->priv.mask.r == 0xff0000) &&
            (buf->priv.mask.g == 0x00ff00) &&
            (buf->priv.mask.b == 0x0000ff))
          {
             obr->xcbob = 
               evas_software_xcb_output_buffer_new(buf->priv.x11.xcb.conn, 
                                                   buf->priv.x11.xcb.visual, 
                                                   buf->priv.x11.xcb.depth, 
                                                   buf->w, buf->h, use_shm, 
                                                   NULL);
             if (!obr->xcbob) 
               {
                  free(obr);
                  return NULL;
               }
#ifdef EVAS_CSERVE2
             if (evas_cserve2_use_get())
               {
                  im = 
                    (RGBA_Image *)evas_cache2_image_data(evas_common_image_cache2_get(), 
                                                         buf->w, buf->h, 
                                                         (DATA32 *)evas_software_xcb_output_buffer_data(obr->xcbob, &bpl), 
                                                         alpha, EVAS_COLORSPACE_ARGB8888);
               }
             else
#endif
               {
                  im = 
                    (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(), 
                                                        buf->w, buf->h, 
                                                        (DATA32 *)evas_software_xcb_output_buffer_data(obr->xcbob, &bpl), 
                                                        alpha, EVAS_COLORSPACE_ARGB8888);
               }

             if (!im) 
               {
                  evas_software_xcb_output_buffer_free(obr->xcbob, EINA_FALSE);
                  free(obr);
                  return NULL;
               }
             im->extended_info = obr;
             if (buf->priv.x11.xcb.mask) 
               {
                  obr->mask = 
                    evas_software_xcb_output_buffer_new(buf->priv.x11.xcb.conn, 
                                                        buf->priv.x11.xcb.visual, 
                                                        1, buf->w, buf->h, 
                                                        use_shm, NULL);
               }
          }
        else 
          {
             int bw = 0, bh = 0;

#ifdef EVAS_CSERVE2
             if (evas_cserve2_use_get())
               {
                  im = 
                    (RGBA_Image *)evas_cache2_image_empty(evas_common_image_cache2_get());
               }
             else
#endif
               {
                  im = 
                    (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
               }

             if (!im) 
               {
                  free(obr);
                  return NULL;
               }
             im->cache_entry.flags.alpha |= (alpha ? 1 : 0);
#ifdef EVAS_CSERVE2
             if (evas_cserve2_use_get())
               evas_cache2_image_surface_alloc(&im->cache_entry, buf->w, buf->h);
             else
#endif
               evas_cache_image_surface_alloc(&im->cache_entry, buf->w, buf->h);

             im->extended_info = obr;
             if ((buf->rot == 0) || (buf->rot == 180)) 
               {
                  bw = buf->w;
                  bh = buf->h;
               }
             else if ((buf->rot == 90) || (buf->rot == 270)) 
               {
                  bw = buf->h;
                  bh = buf->w;
               }
             obr->xcbob = 
               evas_software_xcb_output_buffer_new(buf->priv.x11.xcb.conn, 
                                                   buf->priv.x11.xcb.visual, 
                                                   buf->priv.x11.xcb.depth, 
                                                   bw, bh, use_shm, NULL);
             if (!obr->xcbob) 
               {
#ifdef EVAS_CSERVE2
                  if (evas_cserve2_use_get())
                    evas_cache2_image_close(&im->cache_entry);
                  else
#endif
                    evas_cache_image_drop(&im->cache_entry);

                  free(obr);
                  return NULL;
               }
             if (buf->priv.x11.xcb.mask) 
               {
                  obr->mask = 
                    evas_software_xcb_output_buffer_new(buf->priv.x11.xcb.conn, 
                                                        buf->priv.x11.xcb.visual, 
                                                        1, bw, bh, use_shm, 
                                                        NULL);
               }
          }
        /* FIXME: We should be able to remove this memset. */
        if ((alpha) && (im->image.data)) 
          {
             /* FIXME: Faster memset */
//             memset(im->image.data, 0, (w * h * sizeof(DATA32)));
          }
        buf->priv.onebuf = im;
        return im;
     }

   if (!(obr = calloc(1, sizeof(Outbuf_Region))))
     return NULL;

   obr->x = x;
   obr->y = y;
   obr->w = w;
   obr->h = h;
   if (cx) *cx = 0;
   if (cy) *cy = 0;
   if (cw) *cw = w;
   if (ch) *ch = h;

   use_shm = buf->priv.x11.xcb.shm;
   alpha = ((buf->priv.x11.xcb.mask) || (buf->priv.destination_alpha));
   if ((buf->rot == 0) &&
       (buf->priv.x11.xcb.imdepth == 32) &&
       (buf->priv.mask.r == 0xff0000) && 
       (buf->priv.mask.g == 0x00ff00) &&
       (buf->priv.mask.b == 0x0000ff)) 
     {
        obr->xcbob = 
          _find_xcbob(buf->priv.x11.xcb.conn, buf->priv.x11.xcb.visual, 
                      buf->priv.x11.xcb.depth, w, h, use_shm, NULL);
        if (!obr->xcbob) 
          {
             free(obr);
             return NULL;
          }
#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          {
             im = 
               (RGBA_Image *)evas_cache2_image_data(evas_common_image_cache2_get(), 
                                                   w, h, 
                                                   (DATA32 *)evas_software_xcb_output_buffer_data(obr->xcbob, &bpl), 
                                                   alpha, EVAS_COLORSPACE_ARGB8888);
          }
        else
#endif
          {
             im = 
               (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(), 
                                                   w, h, 
                                                   (DATA32 *)evas_software_xcb_output_buffer_data(obr->xcbob, &bpl), 
                                                   alpha, EVAS_COLORSPACE_ARGB8888);
          }

        if (!im) 
          {
             _unfind_xcbob(obr->xcbob, EINA_FALSE);
             free(obr);
             return NULL;
          }
        im->extended_info = obr;
        if (buf->priv.x11.xcb.mask) 
          {
             obr->mask = 
               _find_xcbob(buf->priv.x11.xcb.conn, buf->priv.x11.xcb.visual, 
                           1, w, h, use_shm, NULL);
          }
     }
   else 
     {
        int bw = 0, bh = 0;

#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          {
             im = 
               (RGBA_Image *)evas_cache2_image_empty(evas_common_image_cache2_get());
          }
        else
#endif
          {
             im = 
               (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
          }

        if (!im) 
          {
             free(obr);
             return NULL;
          }
        im->cache_entry.flags.alpha |= (alpha ? 1 : 0);
#ifdef EVAS_CSERVE2
        if (evas_cserve2_use_get())
          evas_cache2_image_surface_alloc(&im->cache_entry, w, h);
        else
#endif
          evas_cache_image_surface_alloc(&im->cache_entry, w, h);

        im->extended_info = obr;
        if ((buf->rot == 0) || (buf->rot == 180)) 
          {
             bw = w;
             bh = h;
          }
        else if ((buf->rot == 90) || (buf->rot == 270)) 
          {
             bw = h;
             bh = w;
          }
        obr->xcbob = 
          _find_xcbob(buf->priv.x11.xcb.conn, buf->priv.x11.xcb.visual, 
                      buf->priv.x11.xcb.depth, bw, bh, use_shm, NULL);
        if (!obr->xcbob) 
          {
#ifdef EVAS_CSERVE2
             if (evas_cserve2_use_get())
               evas_cache2_image_close(&im->cache_entry);
             else
#endif
               evas_cache_image_drop(&im->cache_entry);
             free(obr);
             return NULL;
          }
        if (buf->priv.x11.xcb.mask) 
          {
             obr->mask = 
               _find_xcbob(buf->priv.x11.xcb.conn, buf->priv.x11.xcb.visual, 1, 
                           bw, bh, use_shm, NULL);
          }
     }
   /* FIXME: We should be able to remove this memset. */
   if (((buf->priv.x11.xcb.mask) || (buf->priv.destination_alpha)) && 
       (im->image.data)) 
     {
        /* FIXME: Faster memset */
//        memset(im->image.data, 0, (w * h * sizeof(DATA32)));
     }

   buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);

   return im;
}