[3/3] winex11: Don't accept zero gamma ramps

André Hentschel nerv at dawncrow.de
Wed Aug 10 15:59:44 CDT 2011


This fixes http://bugs.winehq.org/show_bug.cgi?id=24598 for the game "And Yet It Moves"
---
 dlls/gdi32/tests/dc.c       |    2 +-
 dlls/winex11.drv/xvidmode.c |   11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index f8ceccd..c433e1b 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -615,7 +615,7 @@ static void test_gamma(void)
 
         /* ramps are zero for every color */
         ret = SetDeviceGammaRamp(hdc, &ramp);
-        todo_wine ok(!ret, "SetDeviceGammaRamp succeeded\n");
+        ok(!ret, "SetDeviceGammaRamp succeeded\n");
 
         /* set a ramp part at the end of every color to non-zero */
         ramp.red[255] = 1;
diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c
index f866176..7122a0e 100644
--- a/dlls/winex11.drv/xvidmode.c
+++ b/dlls/winex11.drv/xvidmode.c
@@ -271,6 +271,15 @@ void X11DRV_XF86VM_Cleanup(void)
 
 #ifdef X_XF86VidModeSetGamma
 
+static BOOL GammaRampIsBad(WORD ramp[256])
+{
+  unsigned i;
+  /* FIXME: should check for more */
+  for (i=0; i<256; i++)
+    if (ramp[i] != 0) return FALSE;
+  return TRUE;
+}
+
 static void GenerateRampFromGamma(WORD ramp[256], float gamma)
 {
   float r_gamma = 1/gamma;
@@ -390,6 +399,8 @@ static BOOL X11DRV_XF86VM_SetGammaRamp(LPDDGAMMARAMP ramp)
   XF86VidModeGamma gamma;
 
   if (xf86vm_major < 2 || !usexvidmode) return FALSE; /* no gamma control */
+  else if (GammaRampIsBad(ramp->red) || GammaRampIsBad(ramp->green) || GammaRampIsBad(ramp->blue))
+      return FALSE;
 #ifdef X_XF86VidModeSetGammaRamp
   else if (xf86vm_use_gammaramp)
   {
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list