From a58dd678bf952560e5422845e186d80a189953fe Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 17 Sep 2016 11:42:09 +0200 Subject: [PATCH] xf86RandR12: Move calculating of shift inside init_one_component This is a preparation patch to allow easier usage of init_one_component outside of xf86RandR12CrtcInitGamma. Signed-off-by: Hans de Goede Reviewed-by: Alex Deucher --- hw/xfree86/modes/xf86RandR12.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index d34bce2f6..b1ca8b41d 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1325,9 +1325,12 @@ xf86RandR12CrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc) } static void -init_one_component(CARD16 *comp, unsigned size, unsigned shift, float gamma) +init_one_component(CARD16 *comp, unsigned size, float gamma) { int i; + unsigned shift; + + for (shift = 0; (size << shift) < (1 << 16); shift++); if (gamma == 1.0) { for (i = 0; i < size; i++) @@ -1344,7 +1347,7 @@ static Bool xf86RandR12CrtcInitGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, float gamma_blue) { - unsigned size = crtc->randr_crtc->gammaSize, shift; + unsigned size = crtc->randr_crtc->gammaSize; CARD16 *red, *green, *blue; if (!crtc->funcs->gamma_set && @@ -1358,11 +1361,9 @@ xf86RandR12CrtcInitGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, green = red + size; blue = green + size; - for (shift = 0; (size << shift) < (1 << 16); shift++); - - init_one_component(red, size, shift, gamma_red); - init_one_component(green, size, shift, gamma_green); - init_one_component(blue, size, shift, gamma_blue); + init_one_component(red, size, gamma_red); + init_one_component(green, size, gamma_green); + init_one_component(blue, size, gamma_blue); RRCrtcGammaSet(crtc->randr_crtc, red, green, blue); free(red);