Re: [PATCH 1/5] ddraw/tests: Add test for bad size of surface caps in CreateSurface. (try 5)

2010-08-10 Thread Oldrich Jedlicka
Hi Stefan,

 10.8.2010 15:40:40, Stefan Dösinger stefandoesin...@gmx.at:
 Diff -u doesn't find any difference between try 4 and try 5, and probably 
 older 
 tries. If you're resending them because the older ones weren't applied, 
 that's 
 futile - Alexandre is on vacation.
 
 Also it is generally a bad idea to keep resending a unchanged patch. If you 
 think the patch has been lost(e.g. Alexandre is waiting for my review and I 
 am 
 not at home, etc) it is better to ask on Wine-devel what is up with the 
 patches.

Ok, I understand. I'm just sending the whole patchset with changed/unchanged 
patches (the number of patches changed, because some of them had been applied 
and some of them I removed, because they don't implement things properly).

Is there some recommended way to send updated patchsets when only some patches 
need to be improved (but the sequence of applying should stay)? Would the 
introductionary mail describing changes and patches as follow-ups help?

Thanks,
Oldřich.

 Am Sonntag 08 August 2010, 07:09:24 schrieb Oldřich Jedlička:
  ---
   dlls/ddraw/tests/dsurface.c |  138
  +++ 1 files changed, 138
  insertions(+), 0 deletions(-)
  
  diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
  index 76bfc7e..8cdcd92 100644
  --- a/dlls/ddraw/tests/dsurface.c
  +++ b/dlls/ddraw/tests/dsurface.c
  @@ -25,6 +25,7 @@
  
   #include assert.h
   #include wine/test.h
  +#include wine/exception.h
   #include ddraw.h
   #include d3d.h
   #include unknwn.h
  @@ -3569,6 +3570,142 @@ static void BackBufferAttachmentFlipTest(void)
   DestroyWindow(window);
   }
  
  +static void CreateSurfaceBadCapsSizeTest(void)
  +{
  +DDSURFACEDESC ddsd_ok;
  +DDSURFACEDESC ddsd_bad1;
  +DDSURFACEDESC ddsd_bad2;
  +DDSURFACEDESC ddsd_bad3;
  +DDSURFACEDESC ddsd_bad4;
  +DDSURFACEDESC2 ddsd2_ok;
  +DDSURFACEDESC2 ddsd2_bad1;
  +DDSURFACEDESC2 ddsd2_bad2;
  +DDSURFACEDESC2 ddsd2_bad3;
  +DDSURFACEDESC2 ddsd2_bad4;
  +IDirectDrawSurface *surf;
  +IDirectDrawSurface4 *surf4;
  +IDirectDrawSurface7 *surf7;
  +HRESULT hr;
  +IDirectDraw2 *dd2;
  +IDirectDraw4 *dd4;
  +IDirectDraw7 *dd7;
  +
  +const DWORD caps = DDSCAPS_OFFSCREENPLAIN;
  +
  +memset(ddsd_ok, 0, sizeof(ddsd_ok));
  +ddsd_ok.dwSize = sizeof(ddsd_ok);
  +ddsd_ok.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
  +ddsd_ok.dwWidth = 64;
  +ddsd_ok.dwHeight = 64;
  +ddsd_ok.ddsCaps.dwCaps = caps;
  +memcpy(ddsd_bad1, ddsd_ok, sizeof(ddsd_bad1));
  +ddsd_bad1.dwSize--;
  +memcpy(ddsd_bad2, ddsd_ok, sizeof(ddsd_bad2));
  +ddsd_bad2.dwSize++;
  +memcpy(ddsd_bad3, ddsd_ok, sizeof(ddsd_bad3));
  +ddsd_bad3.dwSize = 0;
  +memcpy(ddsd_bad4, ddsd_ok, sizeof(ddsd_bad4));
  +ddsd_bad4.dwSize = sizeof(DDSURFACEDESC2);
  +
  +memset(ddsd2_ok, 0, sizeof(ddsd2_ok));
  +ddsd2_ok.dwSize = sizeof(ddsd2_ok);
  +ddsd2_ok.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
  +ddsd2_ok.dwWidth = 64;
  +ddsd2_ok.dwHeight = 64;
  +ddsd2_ok.ddsCaps.dwCaps = caps;
  +memcpy(ddsd2_bad1, ddsd2_ok, sizeof(ddsd2_bad1));
  +ddsd2_bad1.dwSize--;
  +memcpy(ddsd2_bad2, ddsd2_ok, sizeof(ddsd2_bad2));
  +ddsd2_bad2.dwSize++;
  +memcpy(ddsd2_bad3, ddsd2_ok, sizeof(ddsd2_bad3));
  +ddsd2_bad3.dwSize = 0;
  +memcpy(ddsd2_bad4, ddsd2_ok, sizeof(ddsd2_bad4));
  +ddsd2_bad4.dwSize = sizeof(DDSURFACEDESC);
  +
  +hr = IDirectDraw_CreateSurface(lpDD, ddsd_ok, surf, NULL);
  +ok(SUCCEEDED(hr), IDirectDraw_CreateSurface failed: 0x%08x\n, hr);
  +IDirectDrawSurface_Release(surf);
  +
  +hr = IDirectDraw_CreateSurface(lpDD, ddsd_bad1, surf, NULL);
  +todo_wine ok(hr == DDERR_INVALIDPARAMS, IDirectDraw_CreateSurface
  didn't return 0x%08x, but 0x%08x\n, +   DDERR_INVALIDPARAMS, hr);
  +hr = IDirectDraw_CreateSurface(lpDD, ddsd_bad2, surf, NULL);
  +todo_wine ok(hr == DDERR_INVALIDPARAMS, IDirectDraw_CreateSurface
  didn't return 0x%08x, but 0x%08x\n, +   DDERR_INVALIDPARAMS, hr);
  +hr = IDirectDraw_CreateSurface(lpDD, ddsd_bad3, surf, NULL);
  +ok(hr == DDERR_INVALIDPARAMS, IDirectDraw_CreateSurface didn't return
  0x%08x, but 0x%08x\n, +   DDERR_INVALIDPARAMS, hr);
  +hr = IDirectDraw_CreateSurface(lpDD, ddsd_bad4, surf, NULL);
  +todo_wine ok(hr == DDERR_INVALIDPARAMS, IDirectDraw_CreateSurface
  didn't return 0x%08x, but 0x%08x\n, +   DDERR_INVALIDPARAMS, hr);
  +
  +hr = IDirectDraw_QueryInterface(lpDD, IID_IDirectDraw2, (void **)
  dd2); +ok(SUCCEEDED(hr), IDirectDraw_QueryInterface failed:
  0x%08x\n, hr); +
  +hr = IDirectDraw2_CreateSurface(dd2, ddsd_ok, surf, NULL);
  +ok(SUCCEEDED(hr), IDirectDraw2_CreateSurface failed: 0x%08x\n, hr);
  +IDirectDrawSurface_Release(surf);
  +
  +hr = IDirectDraw2_CreateSurface(dd2, ddsd_bad1, surf, NULL);
  +todo_wine ok(hr == 

Re: Re: [PATCH 03/10] ddraw/tests: Add test for NULL/bad size of surface caps in CreateSurface. (try 3)

2010-08-04 Thread Oldrich Jedlicka
Hi Stefan,

4.8.2010 13:04:43, Stefan Dösinger stefandoesin...@gmx.at:
 
 Am 04.08.2010 um 12:29 schrieb Alexandre Julliard:
 
  Oldřich Jedlička oldium@seznam.cz writes:
  
  +__TRY
  +{
  +hr = IDirectDraw_CreateSurface(lpDD, NULL, surf, NULL);
  +todo_wine ok(hr == DDERR_INVALIDPARAMS, IDirectDraw_CreateSurface
 didn't return 0x%08x, but 0x%08x\n,
  +   DDERR_INVALIDPARAMS, hr);
  +}
  +__EXCEPT_PAGE_FAULT
  +{
  +todo_wine ok(FALSE, IDirectDraw_CreateSurface dereferenced NULL
 pointer\n);
  +}
  +__ENDTRY
  
  You can't use Wine exception macros in tests.
 In this case it is better not to include the NULL pointer tests in this patch
 and add them in the patch that adds the NULL pointer checks in ddraw.

Ok, otherwise there would be a page fault in the test, which is not good. I 
will send updated patchset in the evening.

Oldřich.
 
 @Alexandre: I didn't know about that either, otherwise I'd have caught it when
 looking at the patch.




Re: [dib.c] 3. Remove identity colormap changing for monochrome bitmaps

2005-12-02 Thread Oldrich Jedlicka
Hi again,

I did not find the problem, but I found different solution - for 
consideration:

There is problem that with pixmap_depth we loose the color information - there 
can be workaround found for this (what I suggested in the second patch). I 
removed now all the pixmap_depth stuff (just to test it) and received what I 
expected - tests are running correctly (and some todos passed) and the game 
Neighbours from Hell is also working correctly - I know that this doesn't 
mean that it is the correct way to do it.

So there are two ways:
* Find a solution with monochrome bitmaps
* Change monochrome bitmaps to use pixmap_depth=screen as other DIBs

Any hint - which way to go? I think I do not have time during the weekend, so 
I will probably look at it next week on Monday.

Used patch for colored monochrome bitmaps is attached.

Cheers,

  Oldrich.

Dne Thursday 01 of December 2005 18:37 Alexandre Julliard napsal(a):
 Oldrich Jedlicka [EMAIL PROTECTED] writes:
  This fixes colors in monochrome bitmaps that were overwritten by identity
  colormap every time.
 
  Changelog:
 
  * Remove the identity color map overwriting on all monochrome bitmaps

 This breaks the tests:

 bitmap.c:399: Test failed: lower left pixel is 00ff00ff
 bitmap.c:400: Test failed: bottom but one, left pixel is ff00
Index: dlls/x11drv/dib.c
===
RCS file: /home/wine/wine/dlls/x11drv/dib.c,v
retrieving revision 1.47
diff -u -r1.47 dib.c
--- dlls/x11drv/dib.c	1 Dec 2005 17:15:21 -	1.47
+++ dlls/x11drv/dib.c	2 Dec 2005 08:22:08 -
@@ -290,29 +290,19 @@
 {
 const RGBQUAD * rgb = (const RGBQUAD *)colorPtr;
 
-if (depth == 1)  /* Monochrome */
-for (i = start; i  end; i++, rgb++)
-colorMapping[i] = (rgb-rgbRed + rgb-rgbGreen +
-   rgb-rgbBlue  255*3/2);
-else
-for (i = start; i  end; i++, rgb++)
-colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, RGB(rgb-rgbRed,
-rgb-rgbGreen,
-rgb-rgbBlue));
+for (i = start; i  end; i++, rgb++)
+colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, RGB(rgb-rgbRed,
+rgb-rgbGreen,
+rgb-rgbBlue));
 }
 else
 {
 const RGBTRIPLE * rgb = (const RGBTRIPLE *)colorPtr;
 
-if (depth == 1)  /* Monochrome */
-for (i = start; i  end; i++, rgb++)
-colorMapping[i] = (rgb-rgbtRed + rgb-rgbtGreen +
-   rgb-rgbtBlue  255*3/2);
-else
-for (i = start; i  end; i++, rgb++)
-colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, RGB(rgb-rgbtRed,
-   rgb-rgbtGreen,
-   rgb-rgbtBlue));
+for (i = start; i  end; i++, rgb++)
+colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, RGB(rgb-rgbtRed,
+   rgb-rgbtGreen,
+   rgb-rgbtBlue));
 }
 }
 else  /* DIB_PAL_COLORS */
@@ -896,26 +885,19 @@
 notsupported:
 {
 BYTE* dstbyte;
-BYTE neg = 0;
 unsigned long white = (1  bmpImage-bits_per_pixel) - 1;
 
 /*  any bmp format - pal 1 dib  */
-if ((unsigned)colors[0].rgbRed+colors[0].rgbGreen+colors[0].rgbBlue =
-(unsigned)colors[1].rgbRed+colors[1].rgbGreen+colors[1].rgbBlue )
-neg = 1;
-
-WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB, 
- %s color mapping\n,
+WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB\n,
   bmpImage-bits_per_pixel, bmpImage-red_mask,
-  bmpImage-green_mask, bmpImage-blue_mask,
-  neg?negative:direct );
+  bmpImage-green_mask, bmpImage-blue_mask);
 
 for (h=lines-1; h=0; h--) {
 BYTE dstval;
 dstbyte=dstbits;
 dstval=0;
 for (x=0; xwidth; x++) {
-dstval|=((XGetPixel( bmpImage, x, h) = white) ^ neg)  (7 - (x7));
+dstval|=(XGetPixel( bmpImage, x, h) = white)  (7 - (x7));
 if ((x7)==7) {
 *dstbyte++=dstval;
 dstval=0;
@@ -4159,7 +4141,6 @@
 {
   DIBSECTION dibSection;
   X11DRV_DIB_IMAGEBITS_DESCR descr;
-  int identity[2] = {0,1};
 
   if (!GetObjectW( physBitmap-hbitmap, sizeof

Re: [dib.c] 3. Remove identity colormap changing for monochrome bitmaps

2005-12-02 Thread Oldrich Jedlicka
I have to read my emails four times before sending :-)

So what I meant: I did not find exactly the solution for the problem with 
failed tests (which keeps my second path in the game), but completely 
different approach by removing pixmap_depth=1 (and also my second patch that 
is unneeded then).

Regards,

  Oldrich.




Re: [dib.c] 3. Remove identity colormap changing for monochrome bitmaps

2005-12-01 Thread Oldrich Jedlicka
Thanks Alexandre,

I will have a look at it more closely as the inverted colors in monochrome 
bitmaps are maybe a more general problem - if BitBlt is using palette of both 
bitmaps and in copying from XImage into DIB it is inverted again - I will 
check it.

Actually I discovered this first time as the palette is set to NULL 
(descr.palentry = NULL) in X11DRV_DIB_DoCopyDIBSection.

Oldrich.

Dne Thursday 01 of December 2005 18:37 Alexandre Julliard napsal(a):
 Oldrich Jedlicka [EMAIL PROTECTED] writes:
  This fixes colors in monochrome bitmaps that were overwritten by identity
  colormap every time.
 
  Changelog:
 
  * Remove the identity color map overwriting on all monochrome bitmaps

 This breaks the tests:

 bitmap.c:399: Test failed: lower left pixel is 00ff00ff
 bitmap.c:400: Test failed: bottom but one, left pixel is ff00




Monochrome bitmaps again

2005-11-30 Thread Oldrich Jedlicka
Hi all,

again I go here to ask what is wrong with my patch sent on 23 Nov 2005 to 
wine-patches (still not in CVS).

The problem with monochrome bitmaps with inverted colors was discovered in 
game Neighbours from Hell. I tested the patch with simulated inverted 
colors monochrome bitmap and it is working perfectly. Also the game is 
working fully. I do not see any reason why it was (probably) ignored again 
(last time there was a hidden compile problem).

Find attached patch.

Regards,

  Oldrich.
Index: dlls/x11drv/dib.c
===
RCS file: /home/wine/wine/dlls/x11drv/dib.c,v
retrieving revision 1.45
diff -u -r1.45 dib.c
--- dlls/x11drv/dib.c	22 Sep 2005 10:44:40 -	1.45
+++ dlls/x11drv/dib.c	23 Nov 2005 10:45:38 -
@@ -521,6 +521,18 @@
 }
 
 /***
+ *   X11DRV_DIB_CheckMask
+ *
+ * Check RGB mask if it is either 0 or matches visual's mask.
+ */
+static inline int X11DRV_DIB_CheckMask(int red_mask, int green_mask, int blue_mask)
+{
+return ( red_mask == 0  green_mask == 0  blue_mask == 0 ) ||
+   ( red_mask == visual-red_mask  green_mask == visual-green_mask 
+ blue_mask == visual-blue_mask );
+}
+
+/***
  *   X11DRV_DIB_SetImageBits_1
  *
  * SetDIBits for a 1-bit deep DIB.
@@ -602,7 +614,8 @@
 {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 1 or 4 bmp - pal 1 dib  */
 BYTE* dstbyte;
 
@@ -634,7 +647,8 @@
 break;
 
 case 8:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask, bmpImage-green_mask, bmpImage-blue_mask)
+ srccolors) {
 /*  pal 8 bmp - pal 1 dib  */
 const void* srcbits;
 const BYTE* srcpixel;
@@ -882,19 +896,30 @@
 notsupported:
 {
 BYTE* dstbyte;
+BYTE neg = 0;
 unsigned long white = (1  bmpImage-bits_per_pixel) - 1;
 
 /*  any bmp format - pal 1 dib  */
-WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB\n,
+if ((unsigned)colors[0].rgbRed+colors[0].rgbGreen+
+ colors[0].rgbBlue =
+(unsigned)colors[1].rgbRed+colors[1].rgbGreen+
+ colors[1].rgbBlue ) {
+neg = 1;
+}
+
+WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB, 
+ %s color mapping\n,
   bmpImage-bits_per_pixel, bmpImage-red_mask,
-  bmpImage-green_mask, bmpImage-blue_mask );
+  bmpImage-green_mask, bmpImage-blue_mask,
+  neg?negative:direct );
 
 for (h=lines-1; h=0; h--) {
 BYTE dstval;
 dstbyte=dstbits;
 dstval=0;
 for (x=0; xwidth; x++) {
-dstval|=(XGetPixel( bmpImage, x, h) = white)  (7 - (x7));
+dstval|=((XGetPixel( bmpImage, x, h) = white) ^ neg)  
+(7 - (x7));
 if ((x7)==7) {
 *dstbyte++=dstval;
 dstval=0;
@@ -978,7 +1003,8 @@
 switch (bmpImage-depth) {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 1 or 4 bmp - pal 4 dib  */
 BYTE* dstbyte;
 
@@ -1010,7 +1036,8 @@
 break;
 
 case 8:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 8 bmp - pal 4 dib  */
 const void* srcbits;
 const BYTE *srcpixel;
@@ -1568,7 +1595,8 @@
 switch (bmpImage-depth) {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 
 /*  pal 1 bmp - pal 8 dib  */
 /*  pal 4 bmp - pal 8 dib  */
@@ -1590,7 +1618,8 @@
 break;
 
 case 8:
-   if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+   if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+srccolors) {
 

Re: Monochrome bitmaps again

2005-11-30 Thread Oldrich Jedlicka
Thanks,

I will split it into three parts and send them separately into wine-patches:

* Fix for the RGB mask
* Fix for the monochrome bitmap with inverted colors
* Remove the identity color map settings for monochrome bitmaps as it is 
needed for the previous fix

Is it ok?

Oldrich.

Dne Wednesday 30 of November 2005 12:42 Alexandre Julliard napsal(a):
 Oldrich Jedlicka [EMAIL PROTECTED] writes:
  Hi all,
 
  again I go here to ask what is wrong with my patch sent on 23 Nov 2005 to
  wine-patches (still not in CVS).
 
  The problem with monochrome bitmaps with inverted colors was discovered
  in game Neighbours from Hell. I tested the patch with simulated
  inverted colors monochrome bitmap and it is working perfectly. Also the
  game is working fully. I do not see any reason why it was (probably)
  ignored again (last time there was a hidden compile problem).

 The changes look ok, but please send separate fixes as separate
 patches, there are really 3 different fixes in your patch.




Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Hi all,

I found a bug in monochrome bitmaps with inverted colors (color[0]=0xFF, 
color[1]=0x00). It is problem in translation from XImage into DIB created 
by CreateDIBSection.

Description can be found in my mail from 08 Oct 2005 and 03 Nov 2005. Patch is 
also attached to this mail.

I've got no response and CVS is untouched. So what is wrong with my patch? 
People from cedega team at least said 'thank you', there is nothing :-(

Thanks for reply,

  Oldrich Jedlicka.
--- dlls/x11drv/dib.c.orig	2005-10-07 01:23:58.0 +
+++ dlls/x11drv/dib.c	2005-10-08 10:02:03.0 +
@@ -521,6 +521,18 @@
 }
 
 /***
+ *   X11DRV_DIB_CheckMask
+ *
+ * Check RGB mask if it is either 0 or matches visual's mask.
+ */
+static inline int X11DRV_DIB_CheckMask(int red_mask, int green_mask, int blue_mask)
+{
+return ( red_mask == 0  green_mask == 0  blue_mask == 0 ) ||
+   ( red_mask == visual-red_mask  green_mask == visual-green_mask 
+ blue_mask == visual-blue_mask );
+}
+
+/***
  *   X11DRV_DIB_SetImageBits_1
  *
  * SetDIBits for a 1-bit deep DIB.
@@ -602,7 +614,8 @@
 {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 1 or 4 bmp - pal 1 dib  */
 BYTE* dstbyte;
 
@@ -634,7 +647,8 @@
 break;
 
 case 8:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask, bmpImage-green_mask, bmpImage-blue_mask)
+ srccolors) {
 /*  pal 8 bmp - pal 1 dib  */
 const void* srcbits;
 const BYTE* srcpixel;
@@ -882,19 +896,30 @@
 notsupported:
 {
 BYTE* dstbyte;
+BYTE neg = 0;
 unsigned long white = (1  bmpImage-bits_per_pixel) - 1;
 
 /*  any bmp format - pal 1 dib  */
-WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB\n,
+if ((unsigned)colors[0].rgbRed+colors[0].rgbGreen+
+ colors[0].rgbBlue =
+(unsigned)colors[1].rgbRed+colors[1].rgbGreen+
+ colors[1].rgbBlue ) {
+neg = 1;
+}
+
+WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB, 
+ %s color mapping\n,
   bmpImage-bits_per_pixel, bmpImage-red_mask,
-  bmpImage-green_mask, bmpImage-blue_mask );
+  bmpImage-green_mask, bmpImage-blue_mask,
+  neg?negative:direct );
 
 for (h=lines-1; h=0; h--) {
 BYTE dstval;
 dstbyte=dstbits;
 dstval=0;
 for (x=0; xwidth; x++) {
-dstval|=(XGetPixel( bmpImage, x, h) = white)  (7 - (x7));
+dstval|=((XGetPixel( bmpImage, x, h) = white) ^ neg)  
+(7 - (x7));
 if ((x7)==7) {
 *dstbyte++=dstval;
 dstval=0;
@@ -978,7 +1003,8 @@
 switch (bmpImage-depth) {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 1 or 4 bmp - pal 4 dib  */
 BYTE* dstbyte;
 
@@ -1010,7 +1036,8 @@
 break;
 
 case 8:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 8 bmp - pal 4 dib  */
 const void* srcbits;
 const BYTE *srcpixel;
@@ -1568,7 +1595,8 @@
 switch (bmpImage-depth) {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 
 /*  pal 1 bmp - pal 8 dib  */
 /*  pal 4 bmp - pal 8 dib  */
@@ -1590,7 +1618,8 @@
 break;
 
 case 8:
-   if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+   if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+srccolors) {
 /*  pal 8 bmp - pal 8 dib  */
const void* srcbits;
const BYTE* srcpixel;
@@ -2374,7 +2403,8 @@
 
 case 1:
 case 4:
-if (bmpImage-red_mask

Re: Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Thanks Willie,

ok, that's it. I didn't try to compile it after I sent the patch first time 
(it was working for me). I will fix it and resend a patch to wine-patches.

Cheers,

  Oldrich.

Dne Wednesday 23 of November 2005 10:35 Willie Sippel napsal(a):
 Am Mittwoch, 23. November 2005 09:41 schrieb Oldrich Jedlicka:
  Hi all,
 
  I found a bug in monochrome bitmaps with inverted colors
  (color[0]=0xFF, color[1]=0x00). It is problem in translation from
  XImage into DIB created by CreateDIBSection.
 
  Description can be found in my mail from 08 Oct 2005 and 03 Nov 2005.
  Patch is also attached to this mail.
 
  I've got no response and CVS is untouched. So what is wrong with my
  patch? People from cedega team at least said 'thank you', there is
  nothing :-(

 Well, it seems that Wine doesn't even compile with your patch applied (just
 tried with gcc 4.0.2) - I guess that's at least one of the reasons why it
 wasn't applied...?

 See:
 dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
 dib.c:4186: error: invalid operands to binary ==
 make[2]: *** [dib.o] Error 1

  Thanks for reply,
 
Oldrich Jedlicka.

 Ciao,
 Willie




Re: Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Hi,

 See:
 dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
 dib.c:4186: error: invalid operands to binary ==
 make[2]: *** [dib.o] Error 1

just to be sure it compiles also on gcc 4. Here is the corrected patch.

Cheers,

  Oldrich.

Index: dlls/x11drv/dib.c
===
RCS file: /home/wine/wine/dlls/x11drv/dib.c,v
retrieving revision 1.45
diff -u -r1.45 dib.c
--- dlls/x11drv/dib.c	22 Sep 2005 10:44:40 -	1.45
+++ dlls/x11drv/dib.c	23 Nov 2005 10:45:38 -
@@ -521,6 +521,18 @@
 }
 
 /***
+ *   X11DRV_DIB_CheckMask
+ *
+ * Check RGB mask if it is either 0 or matches visual's mask.
+ */
+static inline int X11DRV_DIB_CheckMask(int red_mask, int green_mask, int blue_mask)
+{
+return ( red_mask == 0  green_mask == 0  blue_mask == 0 ) ||
+   ( red_mask == visual-red_mask  green_mask == visual-green_mask 
+ blue_mask == visual-blue_mask );
+}
+
+/***
  *   X11DRV_DIB_SetImageBits_1
  *
  * SetDIBits for a 1-bit deep DIB.
@@ -602,7 +614,8 @@
 {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 1 or 4 bmp - pal 1 dib  */
 BYTE* dstbyte;
 
@@ -634,7 +647,8 @@
 break;
 
 case 8:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask, bmpImage-green_mask, bmpImage-blue_mask)
+ srccolors) {
 /*  pal 8 bmp - pal 1 dib  */
 const void* srcbits;
 const BYTE* srcpixel;
@@ -882,19 +896,30 @@
 notsupported:
 {
 BYTE* dstbyte;
+BYTE neg = 0;
 unsigned long white = (1  bmpImage-bits_per_pixel) - 1;
 
 /*  any bmp format - pal 1 dib  */
-WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB\n,
+if ((unsigned)colors[0].rgbRed+colors[0].rgbGreen+
+ colors[0].rgbBlue =
+(unsigned)colors[1].rgbRed+colors[1].rgbGreen+
+ colors[1].rgbBlue ) {
+neg = 1;
+}
+
+WARN(from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB, 
+ %s color mapping\n,
   bmpImage-bits_per_pixel, bmpImage-red_mask,
-  bmpImage-green_mask, bmpImage-blue_mask );
+  bmpImage-green_mask, bmpImage-blue_mask,
+  neg?negative:direct );
 
 for (h=lines-1; h=0; h--) {
 BYTE dstval;
 dstbyte=dstbits;
 dstval=0;
 for (x=0; xwidth; x++) {
-dstval|=(XGetPixel( bmpImage, x, h) = white)  (7 - (x7));
+dstval|=((XGetPixel( bmpImage, x, h) = white) ^ neg)  
+(7 - (x7));
 if ((x7)==7) {
 *dstbyte++=dstval;
 dstval=0;
@@ -978,7 +1003,8 @@
 switch (bmpImage-depth) {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 1 or 4 bmp - pal 4 dib  */
 BYTE* dstbyte;
 
@@ -1010,7 +1036,8 @@
 break;
 
 case 8:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 /*  pal 8 bmp - pal 4 dib  */
 const void* srcbits;
 const BYTE *srcpixel;
@@ -1568,7 +1595,8 @@
 switch (bmpImage-depth) {
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+ srccolors) {
 
 /*  pal 1 bmp - pal 8 dib  */
 /*  pal 4 bmp - pal 8 dib  */
@@ -1590,7 +1618,8 @@
 break;
 
 case 8:
-   if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+   if (X11DRV_DIB_CheckMask(bmpImage-red_mask,bmpImage-green_mask,bmpImage-blue_mask)
+srccolors) {
 /*  pal 8 bmp - pal 8 dib  */
const void* srcbits;
const BYTE* srcpixel;
@@ -2374,7 +2403,8 @@
 
 case 1:
 case 4:
-if (bmpImage-red_mask==0  bmpImage-green_mask==0  bmpImage-blue_mask==0  srccolors) {
+if 

Re: Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Good, submitting to wine-patches.

Thanks :-)

Dne Wednesday 23 of November 2005 13:52 Willie Sippel napsal(a):
 Am Mittwoch, 23. November 2005 12:08 schrieb Oldrich Jedlicka:
  Hi,
 
   See:
   dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
   dib.c:4186: error: invalid operands to binary ==
   make[2]: *** [dib.o] Error 1
 
  just to be sure it compiles also on gcc 4. Here is the corrected patch.

 Works... :-)