[gtk+] mir: don't initialize the display if the required pixel formats aren't available
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] mir: don't initialize the display if the required pixel formats aren't available
- Date: Mon, 1 Dec 2014 17:22:36 +0000 (UTC)
commit cf64f8a76ad0de7453de4fef8e31c435f1ddd9ea
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Mon Dec 1 18:05:30 2014 +0100
mir: don't initialize the display if the required pixel formats aren't available
gdk/mir/gdkmirdisplay.c | 74 ++++++++++++++++++++++++++++++----------------
1 files changed, 48 insertions(+), 26 deletions(-)
---
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index a0a2052..5c27b53 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -62,7 +62,7 @@ typedef struct GdkMirDisplayClass
GdkDisplayClass parent_class;
} GdkMirDisplayClass;
-static void initialize_pixel_formats (GdkMirDisplay *display);
+static void get_pixel_formats (MirConnection *, MirPixelFormat *sw, MirPixelFormat *hw);
/**
* SECTION:mir_interaction
@@ -104,6 +104,7 @@ GdkDisplay *
_gdk_mir_display_open (const gchar *display_name)
{
MirConnection *connection;
+ MirPixelFormat sw_pixel_format, hw_pixel_format;
GdkMirDisplay *display;
g_printerr ("gdk_mir_display_open\n");
@@ -111,6 +112,7 @@ _gdk_mir_display_open (const gchar *display_name)
connection = mir_connect_sync (NULL, "GDK-Mir");
if (!connection)
return NULL;
+
if (!mir_connection_is_valid (connection))
{
g_printerr ("Failed to connect to Mir: %s\n", mir_connection_get_error_message (connection));
@@ -118,12 +120,23 @@ _gdk_mir_display_open (const gchar *display_name)
return NULL;
}
+ get_pixel_formats (connection, &sw_pixel_format, &hw_pixel_format);
+
+ if (sw_pixel_format == mir_pixel_format_invalid ||
+ hw_pixel_format == mir_pixel_format_invalid)
+ {
+ g_printerr ("Mir display does not support required pixel formats\n");
+ mir_connection_release (connection);
+ return NULL;
+ }
+
display = g_object_new (GDK_TYPE_MIR_DISPLAY, NULL);
display->connection = connection;
GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
- initialize_pixel_formats (display);
+ display->sw_pixel_format = sw_pixel_format;
+ display->hw_pixel_format = hw_pixel_format;
g_signal_emit_by_name (display, "opened");
@@ -501,41 +514,50 @@ gdk_mir_display_utf8_to_string_target (GdkDisplay *display,
}
static void
-initialize_pixel_formats (GdkMirDisplay *display)
+get_pixel_formats (MirConnection *connection,
+ MirPixelFormat *sw_pixel_format,
+ MirPixelFormat *hw_pixel_format)
{
MirPixelFormat formats[mir_pixel_formats];
unsigned int n_formats, i;
- mir_connection_get_available_surface_formats (display->connection, formats,
+ mir_connection_get_available_surface_formats (connection, formats,
mir_pixel_formats, &n_formats);
- display->sw_pixel_format = mir_pixel_format_invalid;
- display->hw_pixel_format = mir_pixel_format_invalid;
-
- for (i = 0; i < n_formats; i++)
+ if (sw_pixel_format)
{
- 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:
- display->hw_pixel_format = formats[i];
- break;
- default:
- continue;
- }
-
- if (display->hw_pixel_format != mir_pixel_format_invalid)
- break;
+ *sw_pixel_format = mir_pixel_format_invalid;
+
+ for (i = 0; i < n_formats; i++)
+ {
+ if (formats[i] == mir_pixel_format_argb_8888)
+ {
+ *sw_pixel_format = formats[i];
+ break;
+ }
+ }
}
- for (i = 0; i < n_formats; i++)
+ if (hw_pixel_format)
{
- if (formats[i] == mir_pixel_format_argb_8888)
+ *hw_pixel_format = mir_pixel_format_invalid;
+
+ for (i = 0; i < n_formats; i++)
{
- display->sw_pixel_format = formats[i];
- break;
+ 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:
+ *hw_pixel_format = formats[i];
+ break;
+ default:
+ continue;
+ }
+
+ if (*hw_pixel_format != mir_pixel_format_invalid)
+ break;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]