[gtk+] mir: support more pixel formats



commit af5792f14126382705b2de328e4266f03ad1f824
Author: William Hua <william hua canonical com>
Date:   Tue Oct 13 10:18:11 2015 +0100

    mir: support more pixel formats

 gdk/mir/gdkmirdisplay.c    |   23 ++++++++++++++---------
 gdk/mir/gdkmirwindowimpl.c |   37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 10 deletions(-)
---
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index 6eda352..73f8bcf 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -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;
+            }
         }
     }
 }
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index 9b3a249..05bec83 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]