Evas: Iterating the pixmap formats from xcb_setup can be expensive,
authordevilhorns <devilhorns@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 20 Aug 2011 10:59:53 +0000 (10:59 +0000)
committerdevilhorns <devilhorns@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 20 Aug 2011 10:59:53 +0000 (10:59 +0000)
so cache the found format for reuse so we don't have to keep iterating.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@62626 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/engines/software_x11/evas_xcb_buffer.c

index 03f2386..6b7e18a 100644 (file)
@@ -418,8 +418,9 @@ _xcbob_sync(xcb_connection_t *conn)
 static xcb_image_t *
 _xcbob_create_native(xcb_connection_t *conn, int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data) 
 {
+   static uint8_t dpth = 0;
+   static xcb_format_t *fmt = NULL;
    const xcb_setup_t *setup;
-   xcb_format_t *fmt = NULL;
    xcb_image_format_t xif;
 
    /* NB: We cannot use xcb_image_create_native as it only creates images 
@@ -431,21 +432,18 @@ _xcbob_create_native(xcb_connection_t *conn, int w, int h, xcb_image_format_t fo
    if ((xif == XCB_IMAGE_FORMAT_Z_PIXMAP) && (depth == 1))
      xif = XCB_IMAGE_FORMAT_XY_PIXMAP;
 
-   fmt = _xcbob_find_format(setup, depth);
-   if (!fmt) return 0;
+   if (dpth != depth) 
+     {
+        dpth = depth;
+        fmt = _xcbob_find_format(setup, depth);
+        if (!fmt) return 0;
+     }
 
    switch (xif) 
      {
       case XCB_IMAGE_FORMAT_XY_BITMAP:
         if (depth != 1) return 0;
       case XCB_IMAGE_FORMAT_XY_PIXMAP:
-        /* return xcb_image_create(w, h, xif,  */
-        /*                         fmt->scanline_pad,  */
-        /*                         fmt->depth, fmt->bits_per_pixel,  */
-        /*                         setup->bitmap_format_scanline_unit,  */
-        /*                         setup->image_byte_order,  */
-        /*                         setup->bitmap_format_bit_order,  */
-        /*                         base, bytes, data); */
       case XCB_IMAGE_FORMAT_Z_PIXMAP:
         return xcb_image_create(w, h, xif, 
                                 fmt->scanline_pad,