Re: X11DRV-Patch

Jarmo <[email protected]>
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
Patch update, fixes problem with 24 bpp

Jarmo
patch2_1.diff (text/x-diff, 2.6 KB)
--- wine/graphics/x11drv/dib.c	2003-05-29 05:23:54.000000000 +0300
+++ wine_patch/graphics/x11drv/dib.c	2003-07-24 16:32:11.000000000 +0300
@@ -109,6 +109,7 @@
  */
 inline static int X11DRV_DIB_GetXImageWidthBytes( int width, int depth )
 {
+    TRACE("OPTIMIZE THIS\n");
     if (!depth || depth > 32) goto error;
 
     if (!ximageDepthTable[depth-1])
@@ -6036,7 +6037,20 @@
 
   wine_tsx11_lock();
 
-  tmpXImage = XShmCreateImage (gdi_display, visual, depth, ZPixmap, NULL, shminfo, bm->bmWidth, bm->bmHeight);
+  /* Convert bmWidthBytes to ext_width */
+  int ext_width=bm->bmWidth;
+  switch(bm->bmBitsPixel) { /*(bm->bmBitsPixel) { */
+        case 16:
+        case 15: ext_width = bm->bmWidthBytes>>1; break;
+	case 8:  ext_width = bm->bmWidthBytes;    break;
+	case 32: ext_width = bm->bmWidthBytes>>2; break;
+	case 24: ext_width = bm->bmWidthBytes/3;  break;
+	default: FIXME("Unsupported BitDepth\n");
+  }
+
+  tmpXImage = XShmCreateImage (gdi_display, visual, depth, ZPixmap, NULL, shminfo, ext_width, bm->bmHeight);
+
+  /* now this should be uptodate */
   pitch = tmpXImage->bytes_per_line;
   imgsize = pitch * tmpXImage->height;
   shminfo->shmid = shmget(IPC_PRIVATE, imgsize, IPC_CREAT|0777);
@@ -6064,9 +6078,9 @@
       {
         TRACE( "bm->bmWidth %i, bm->bmHeight %i, bm->bmBitsPixel %i\n",
                bm->bmWidth, bm->bmHeight, bm->bmBitsPixel );
-        TRACE( "pitch=%d, imgsize=%d\n", pitch, imgsize);
+        TRACE( "pitch=%d, imgsize=%d ext_width=%d depth=%d\n", pitch, imgsize, ext_width, depth);
         sharedPixmap = XShmCreatePixmap( gdi_display, root_window, shminfo->shmaddr,
-		                         shminfo, bm->bmWidth, bm->bmHeight, depth );
+		                         shminfo, ext_width, bm->bmHeight, depth );
 
         /* register shared memory so DIB protections work */
         if (protectable) VirtualAlloc(shminfo->shmaddr, imgsize, MEM_RESERVE | MEM_SYSTEM, PAGE_READWRITE);
@@ -6107,6 +6121,9 @@
 	BITMAPOBJ *bmp;
 	int bpp;
 
+        int warn_pitch = dib->dibSection.dsBm.bmWidthBytes;
+	WARN("Check this out, Should we use width=%d or pitch=%d\n",width,warn_pitch);
+
 	/* GetObject isn't useful because it will return the DIB's bpp. */
 	bmp = (BITMAPOBJ *)GDI_GetObjPtr(dib->bmp, BITMAP_MAGIC);
 	bpp = bmp->bitmap.bmBitsPixel;
@@ -6183,7 +6200,7 @@
   bm.bmWidth = bi->biWidth;
   bm.bmHeight = effHeight;
   bm.bmWidthBytes = ovr_pitch ? ovr_pitch
-			      : DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount);
+			      : DIB_GetDIBWidthBytes(bi->biWidth, bi->biBitCount);
   bm.bmPlanes = bi->biPlanes;
   bm.bmBitsPixel = bi->biBitCount;
   bm.bmBits = NULL;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.