André Hentschel : winex11: Reject too bright gamma ramps.

Alexandre Julliard julliard at winehq.org
Wed Aug 24 14:05:23 CDT 2011


Module: wine
Branch: master
Commit: 56e804eea4c5976b59cb6adc94baa67dd83886c7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=56e804eea4c5976b59cb6adc94baa67dd83886c7

Author: André Hentschel <nerv at dawncrow.de>
Date:   Tue Aug 23 23:16:26 2011 +0200

winex11: Reject too bright gamma ramps.

---

 dlls/gdi32/tests/dc.c       |    7 +++++++
 dlls/winex11.drv/xvidmode.c |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index 0bc218c..9f26f41 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -644,6 +644,13 @@ static void test_gamma(void)
     ret = SetDeviceGammaRamp(hdc, &ramp);
     ok(ret, "SetDeviceGammaRamp failed\n");
 
+    /* try a bright gamma ramp */
+    ramp[0][0] = 0;
+    ramp[0][1] = 0x7FFF;
+    for (i = 2; i < 256; i++) ramp[0][i] = 0xFFFF;
+    ret = SetDeviceGammaRamp(hdc, &ramp);
+    ok(!ret, "SetDeviceGammaRamp succeeded\n");
+
     /* cleanup: set old ramp again */
     ret = SetDeviceGammaRamp(hdc, &oldramp);
     ok(ret, "SetDeviceGammaRamp failed\n");
diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c
index 732a2d7..2d8a4eb 100644
--- a/dlls/winex11.drv/xvidmode.c
+++ b/dlls/winex11.drv/xvidmode.c
@@ -339,6 +339,11 @@ static BOOL ComputeGammaFromRamp(WORD ramp[256], float *gamma)
     ERR("ramp not uniform (max=%f, min=%f, avg=%f), rejected\n", g_max, g_min, g_avg);
     return FALSE;
   }
+  /* check that the gamma is not too bright */
+  if (g_avg < 0.2) {
+    ERR("too bright gamma ( %5.3f), rejected\n", g_avg);
+    return FALSE;
+  }
   /* ok, now we're pretty sure we can set the desired gamma ramp,
    * so go for it */
   *gamma = 1/g_avg;




More information about the wine-cvs mailing list