summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten Maathuis <madman2003@gmail.com>2008-12-22 19:53:14 +0100
committerMaarten Maathuis <madman2003@gmail.com>2008-12-22 19:54:17 +0100
commitb5736d237a21d5e65d839c4d213dd3bda5a11e9d (patch)
treeb61aba3322573e3dcd4792498b25cda41a438f68
parentba9dc353a60e9a6bba64e854b23271011bff7015 (diff)
randr/xfree86: Fix initial gamma computation.
- The previous version overflowed sometimes.
-rw-r--r--hw/xfree86/modes/xf86Crtc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index fdbd38577..cb13debb3 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2248,24 +2248,23 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green,
* So take the default gamma size for lack of something better.
*/
for (i = 0; i < size; i++) {
- /* Code partially borrowed from ComputeGamma(). */
if (gamma_red == 1.0)
red[i] = i << 8;
else
- red[i] = (CARD16)((pow((double)i/(double)size,
- gamma_red) * (double)size + 0.5)*256);
+ red[i] = (CARD16)(pow((double)i/(double)(size - 1),
+ (double)gamma_red) * (double)(size - 1) * 256);
if (gamma_green == 1.0)
green[i] = i << 8;
else
- green[i] = (CARD16)((pow((double)i/(double)size,
- gamma_green) * (double)size + 0.5)*256);
+ green[i] = (CARD16)(pow((double)i/(double)(size - 1),
+ (double)gamma_green) * (double)(size - 1) * 256);
if (gamma_blue == 1.0)
blue[i] = i << 8;
else
- blue[i] = (CARD16)((pow((double)i/(double)size,
- gamma_blue) * (double)size + 0.5)*256);
+ blue[i] = (CARD16)(pow((double)i/(double)(size - 1),
+ (double)gamma_blue) * (double)(size - 1) * 256);
}
/* Default size is 256, so anything else is failure. */