=?UTF-8?Q?Rico=20Sch=C3=BCller=20?=: d3dx9: Shift only as much as needed.

Alexandre Julliard julliard at winehq.org
Thu Jan 10 13:36:13 CST 2013


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

Author: Rico Schüller <kgbricola at web.de>
Date:   Thu Jan 10 17:57:25 2013 +0100

d3dx9: Shift only as much as needed.

---

 dlls/d3dx9_36/texture.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 2531ea6..c93d2df 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -1240,8 +1240,16 @@ static inline void fill_texture(const struct pixel_format_desc *format, BYTE *po
         {
             BYTE byte, mask;
 
-            mask = ((1 << format->bits[c]) - 1) << format->shift[c] >> i;
-            byte = (v << format->shift[c] >> i) & mask;
+            if (format->shift[c] > i)
+            {
+                mask = ((1 << format->bits[c]) - 1) << (format->shift[c] - i);
+                byte = (v << (format->shift[c] - i)) & mask;
+            }
+            else
+            {
+                mask = ((1 << format->bits[c]) - 1) >> (i - format->shift[c]);
+                byte = (v >> (i - format->shift[c])) & mask;
+            }
             pos[i / 8] |= byte;
         }
     }




More information about the wine-cvs mailing list