mir: support more pixel formats

This commit is contained in:
William Hua 2015-10-13 10:18:11 +01:00
parent 364732f2e6
commit af5792f141
2 changed files with 50 additions and 10 deletions

View File

@ -539,12 +539,19 @@ get_pixel_formats (MirConnection *connection,
{
*sw_pixel_format = mir_pixel_format_invalid;
for (i = 0; i < n_formats; i++)
for (i = 0; i < n_formats && *sw_pixel_format == mir_pixel_format_invalid; i++)
{
if (formats[i] == mir_pixel_format_argb_8888)
switch (formats[i])
{
case mir_pixel_format_abgr_8888:
case mir_pixel_format_xbgr_8888:
case mir_pixel_format_argb_8888:
case mir_pixel_format_xrgb_8888:
case mir_pixel_format_rgb_565:
*sw_pixel_format = formats[i];
break;
default:
break;
}
}
}
@ -553,22 +560,20 @@ get_pixel_formats (MirConnection *connection,
{
*hw_pixel_format = mir_pixel_format_invalid;
for (i = 0; i < n_formats; i++)
for (i = 0; i < n_formats && *hw_pixel_format == mir_pixel_format_invalid; i++)
{
switch (formats[i])
{
{
case mir_pixel_format_abgr_8888:
case mir_pixel_format_xbgr_8888:
case mir_pixel_format_argb_8888:
case mir_pixel_format_xrgb_8888:
case mir_pixel_format_rgb_565:
*hw_pixel_format = formats[i];
break;
default:
continue;
}
if (*hw_pixel_format != mir_pixel_format_invalid)
break;
break;
}
}
}
}

View File

@ -423,7 +423,42 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
ensure_surface (window);
mir_buffer_stream_get_graphics_region (mir_surface_get_buffer_stream (impl->surface), &region);
g_assert (region.pixel_format == mir_pixel_format_argb_8888);
switch (region.pixel_format)
{
case mir_pixel_format_abgr_8888:
g_warning ("pixel format ABGR 8888 not supported, using ARGB 8888");
pixel_format = CAIRO_FORMAT_ARGB32;
break;
case mir_pixel_format_xbgr_8888:
g_warning ("pixel format XBGR 8888 not supported, using XRGB 8888");
pixel_format = CAIRO_FORMAT_RGB24;
break;
case mir_pixel_format_argb_8888:
pixel_format = CAIRO_FORMAT_ARGB32;
break;
case mir_pixel_format_xrgb_8888:
pixel_format = CAIRO_FORMAT_RGB24;
break;
case mir_pixel_format_bgr_888:
g_error ("pixel format BGR 888 not supported");
break;
case mir_pixel_format_rgb_888:
g_error ("pixel format RGB 888 not supported");
break;
case mir_pixel_format_rgb_565:
pixel_format = CAIRO_FORMAT_RGB16_565;
break;
case mir_pixel_format_rgba_5551:
g_error ("pixel format RGBA 5551 not supported");
break;
case mir_pixel_format_rgba_4444:
g_error ("pixel format RGBA 4444 not supported");
break;
default:
g_error ("unknown pixel format");
break;
}
cairo_surface = cairo_image_surface_create_for_data ((unsigned char *) region.vaddr,
pixel_format,