When evas png loader meets png files with color type PNG_COLOR_TYPE_PALETTE,
it expands the palette into rgb data right away and from that moment, the data is handled as normal 32bit data.
If the colormap data is expanded to rgba data at rendering time, we can reduce memory usage roughly by 3/4.
Here is a simple draft of such implementation
- add color type
typedef enum { ... EFL_GFX_COLORSPACE_PALETTE } Efl_Gfx_Colorspace;
- in png head loader, save palette info
evas_image_load_file_head_png() { switch (color_type) { case PNG_COLOR_TYPE_PALETTE: png_get_PLTE(palette, &num_palette); prop->palette_size = *num_palette; prop->palette = (DATA32*)palette; break; } }
- allocate surface: 8bits/pixel
_evas_common_rgba_image_surface_size() { switch (cspace) { case EVAS_COLORSPACE_PALETTE: siz = w * h * sizeof(DATA8); break; } }
- expand colormap data into rgba at rendering time
SCALE_FUNC(RGBA_Image *src, RGBA_Image *dst) { DATA32 *real_src = malloc(); for (i = 0; i < h; i++) { for (j = 0; j < w; i++) { *(tmpptr) = src->cache_entry->palette[ ]; } } // copy real_src to dst here free(real_src); }