gdk: factor out utility shared among backends

Removes duplicated code and makes sure we use the version which
is safe against infinite loops
This commit is contained in:
Paolo Borelli 2016-02-27 10:46:59 +01:00
parent 053e549dbc
commit f73e7680ed
6 changed files with 31 additions and 108 deletions

View File

@ -40,11 +40,6 @@ struct _GdkBroadwayVisualClass
GObjectClass parent_class;
};
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
G_DEFINE_TYPE (GdkBroadwayVisual, gdk_broadway_visual, GDK_TYPE_VISUAL)
static void
@ -259,30 +254,3 @@ _gdk_broadway_screen_list_visuals (GdkScreen *screen)
return list;
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
if (mask == 0)
{
g_warning ("Mask is 0 in visual. Server bug ?");
return;
}
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}

View File

@ -467,3 +467,30 @@ gdk_visual_get_screen (GdkVisual *visual)
return visual->screen;
}
void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
if (mask == 0)
{
g_warning ("Mask is 0 in visual. Server bug ?");
return;
}
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}

View File

@ -59,6 +59,10 @@ struct _GdkVisualClass
GObjectClass parent_class;
};
void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
G_END_DECLS
#endif

View File

@ -38,27 +38,6 @@ static GdkVisual *system_visual;
static GdkVisual *rgba_visual;
static GdkVisual *gray_visual;
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}
static GdkVisual *
create_standard_visual (GdkScreen *screen,
gint depth)

View File

@ -31,10 +31,6 @@
#include "gdkprivate-win32.h"
#include "gdkvisualprivate.h"
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
static GdkVisual *system_visual = NULL;
static GdkVisual *rgba_visual = NULL;
@ -353,24 +349,3 @@ _gdk_win32_screen_list_visuals (GdkScreen *screen)
return result;
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}

View File

@ -45,9 +45,6 @@ struct _GdkX11VisualClass
};
static void gdk_visual_add (GdkVisual *visual);
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
static guint gdk_visual_hash (Visual *key);
static gboolean gdk_visual_equal (Visual *a,
Visual *b);
@ -501,33 +498,6 @@ gdk_visual_add (GdkVisual *visual)
g_hash_table_insert (x11_screen->visual_hash, GDK_X11_VISUAL (visual)->xvisual, visual);
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
if (mask == 0)
{
g_warning ("Mask is 0 in visual. Server bug ?");
return;
}
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}
static guint
gdk_visual_hash (Visual *key)
{