Commit f73e7680 authored by Paolo Borelli's avatar Paolo Borelli

gdk: factor out utility shared among backends

Removes duplicated code and makes sure we use the version which
is safe against infinite loops
parent 053e549d
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -59,6 +59,10 @@ struct _GdkVisualClass
GObjectClass parent_class;
};
void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
G_END_DECLS
#endif
......@@ -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)
......
......@@ -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;
}
}
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment