Re: winex11.drv: SetDIBits fails when startscan != 0

2009-03-26 Thread Massimo Del Fedele

Alexandre Julliard ha scritto:

-  descr.bits  = bits;
+  descr.bits  = (BYTE *)bits + widthBytes * (tmpheight > 0 ? (height - 
startscan - lines) : startscan);


You shouldn't need to change the bits address.



After a deeper look at it, I think there's no other (simple) way to do it.
Using ySrc parameter and changing the behaviour inside X11DRV_DIB_SetImageBits()
will work for SetDIBits() BUT will break SetDIBitsToDevice() on which ySrc has
a completely different meaning, as:

- in SetDIBits, ySrc is not needed and it should be 0; startscan and lines 
specify
  the start line and number of lines to copy from dib

- in SetDIBitsToDevice ySrc IS needed and represent the start line of DIB that 
must be
  transfered, and startscan and lines are useful just for banding the transfer 
in
  repeating calls.

So, as both use X11DRV_SetImageBits(), we can't fix one without breaking the 
other if
we do using ySrc and working from inside X11DRV_DIB_SetImageBits().
A cleaner way would mean extend the X11DRV_DIB_IMAGEBITS_DESCR descriptor adding
startscan and scanlines parameters, and fiddle with about ALL 
X11DRV_DIB_SetImageBits_xxx
functions and others not worth the effort, IMHO.

Ciao

Max





Re: winex11.drv: SetDIBits fails when startscan != 0

2009-03-25 Thread Massimo Del Fedele

Massimo Del Fedele ha scritto:

p.s.: of course, it needs also

widthBytes * (.)

I just shorted it to show the problem :-)

Ciao

Max





Re: winex11.drv: SetDIBits fails when startscan != 0

2009-03-25 Thread Massimo Del Fedele

Alexandre Julliard ha scritto:

Massimo Del Fedele  writes:

 
-  descr.bits  = bits;

+  descr.bits  = (BYTE *)bits + widthBytes * (tmpheight > 0 ? (height - 
startscan - lines) : startscan);


You shouldn't need to change the bits address.



Well, original code was

  descr.bits  = bits;
  descr.image = NULL;
  descr.palentry  = NULL;
  descr.infoWidth = width;
  descr.lines = tmpheight >= 0 ? lines : -lines;
  descr.depth = physBitmap->pixmap_depth;
  descr.drawable  = physBitmap->pixmap;
  descr.gc= BITMAP_GC(physBitmap);
  descr.xSrc  = 0;
  descr.ySrc  = 0;
  descr.xDest = 0;
  descr.yDest = height - startscan - lines;  <-- HERE
  descr.width = ds.dsBm.bmWidth;
  descr.height= lines;

So, wrongly setting DESTINATION bitmap range, instead of SOURCE, which is the 
correct behaviour for SetDIBits().
I tried this one :
  descr.xSrc  = 0;
  descr.ySrc  = height - startscan - lines;  <-- HERE
  descr.xDest = 0;
  descr.yDest = 0;

But it didn't work either, so, or I didn't understand how X11DRV_DIB_SetImageBits( 
&descr ) works, or it has some bug.
Looking more in depth inside X11DRV_DIB_SetImageBits(); it shows, for example :

< NO FIXING OF bits BEFORE>
case 1:
X11DRV_DIB_SetImageBits_1( descr->lines, descr->bits, descr->infoWidth,
   descr->width, descr->xSrc, (int 
*)(descr->colorMap),
   bmpImage, descr->dibpitch );

So, X11DRV_DIB_SetImageBits() and X11DRV_DIB_SetImageBits_XXX() don't set 
correctly the starting of DIB image when transfering.
I could do
bits += height - startscan - lines;
inside X11DRV_DIB_SetImageBits() instead of X11DRV_SetDIBits(), but somewhere 
it must be done.
Please tell me how you prefere it's done.

Ciao

Max





Re: winex11.drv: SetDIBits fails when startscan != 0

2009-03-25 Thread Alexandre Julliard
Massimo Del Fedele  writes:

> diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
> index 6df4137..42d9082 100644
> --- a/dlls/winex11.drv/dib.c
> +++ b/dlls/winex11.drv/dib.c
> @@ -3927,6 +3927,7 @@ INT CDECL X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, 
> HBITMAP hbitmap, UINT start
>X11DRV_DIB_IMAGEBITS_DESCR descr;
>DIBSECTION ds;
>LONG width, height, tmpheight;
> +  LONG widthBytes;
>INT result;
>  
>descr.physDev = physDev;
> @@ -3936,6 +3937,7 @@ INT CDECL X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, 
> HBITMAP hbitmap, UINT start
>if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height,
>&descr.infoBpp, &descr.compression ) == -1)
>return 0;
> +  widthBytes = ((width * descr.infoBpp +31) &~31) / 8;
>  
>tmpheight = height;
>if (height < 0) height = -height;
> @@ -3977,7 +3979,7 @@ INT CDECL X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, 
> HBITMAP hbitmap, UINT start
> default: break;
>}
>  
> -  descr.bits  = bits;
> +  descr.bits  = (BYTE *)bits + widthBytes * (tmpheight > 0 ? (height - 
> startscan - lines) : startscan);

You shouldn't need to change the bits address.

-- 
Alexandre Julliard
julli...@winehq.org