mi: use common implementation of bit counting function
Reduce a bit of unexplained magic, and use ISA extensions where available Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1984>
This commit is contained in:
parent
73f3c47608
commit
7aa1f121e4
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include "dix/colormap_priv.h"
|
#include "dix/colormap_priv.h"
|
||||||
#include "mi/mi_priv.h"
|
#include "mi/mi_priv.h"
|
||||||
|
#include "os/osdep.h"
|
||||||
|
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
#include "colormapst.h"
|
#include "colormapst.h"
|
||||||
|
@ -329,7 +330,6 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
|
||||||
Pixel redMask, Pixel greenMask, Pixel blueMask)
|
Pixel redMask, Pixel greenMask, Pixel blueMask)
|
||||||
{
|
{
|
||||||
miVisualsPtr new, *prev, v;
|
miVisualsPtr new, *prev, v;
|
||||||
int count;
|
|
||||||
|
|
||||||
new = malloc(sizeof *new);
|
new = malloc(sizeof *new);
|
||||||
if (!new)
|
if (!new)
|
||||||
|
@ -347,10 +347,7 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
|
||||||
new->redMask = redMask;
|
new->redMask = redMask;
|
||||||
new->greenMask = greenMask;
|
new->greenMask = greenMask;
|
||||||
new->blueMask = blueMask;
|
new->blueMask = blueMask;
|
||||||
count = (visuals >> 1) & 033333333333;
|
new->count = Ones(visuals);
|
||||||
count = visuals - count - ((count >> 1) & 033333333333);
|
|
||||||
count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */
|
|
||||||
new->count = count;
|
|
||||||
for (prev = &miVisuals; (v = *prev); prev = &v->next);
|
for (prev = &miVisuals; (v = *prev); prev = &v->next);
|
||||||
*prev = new;
|
*prev = new;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue