[dx46] fixes renders lock and surface debug code (snapshots)

Raphaël Junqueira fenix at club-internet.fr
Sun Jun 1 05:26:19 CDT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

This patch fix some a stupid bug i had already solved but i forgot to 
copy/paste ... I'll take a brown paper bag.

 Changelog:
  - fix another time the stupid bug of locking (i had already fixed in 
ActiveRender)
  - fix stupid rescaling of colors values on SaveSnapshot

PS: Jason, this patch should fix your problem

Regards,
Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+2dTNp7NA3AmQTU4RAnsZAJ95xmF1uB4++v57Ob5ESw1E/9T4bwCfeVnO
pgRxU5Yk6Pzi34xLt4EpEW0=
=Ou7J
-----END PGP SIGNATURE-----
-------------- next part --------------
--- /cvs-src/wine-pending/d3d8_45/surface.c	2003-05-31 15:59:06.000000000 +0200
+++ dlls/d3d8/surface.c	2003-06-01 12:17:01.000000000 +0200
@@ -148,18 +148,19 @@
 
     pLockedRect->Pitch = This->bytesPerPixel * This->myDesc.Width;  /* Bytes / row */    
     
-    if (!pRect) {
+    if (NULL == pRect) {
       pLockedRect->pBits = This->allocatedMemory;
-      This->lockedRect.left = 0;
-      This->lockedRect.top = 0;
-      This->lockedRect.right = This->myDesc.Width;
+      This->lockedRect.left   = 0;
+      This->lockedRect.top    = 0;
+      This->lockedRect.right  = This->myDesc.Width;
       This->lockedRect.bottom = This->myDesc.Height;
+      TRACE("Locked Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", &This->lockedRect, This->lockedRect.left, This->lockedRect.top, This->lockedRect.right, This->lockedRect.bottom);
     } else {
       TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
       pLockedRect->pBits = This->allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
-      This->lockedRect.left = pRect->left;
-      This->lockedRect.top = pRect->top;
-      This->lockedRect.right = pRect->right;
+      This->lockedRect.left   = pRect->left;
+      This->lockedRect.top    = pRect->top;
+      This->lockedRect.right  = pRect->right;
       This->lockedRect.bottom = pRect->bottom;
     }
 
@@ -207,7 +208,7 @@
 			 1,
 			 D3DFmt2GLFmt(This->Device, This->myDesc.Format), 
                          D3DFmt2GLType(This->Device, This->myDesc.Format), 
-                         pLockedRect->pBits);
+                         pLockedRect->pBits + j * pLockedRect->Pitch);
 	    vcheckGLcall("glReadPixels");
 	  }
 	}
@@ -500,13 +501,13 @@
 		 This->allocatedMemory);
     checkGLcall("glTexImage2D");
 
-#if 0
+#if 1
     {
-      static int gen = 0;
+      static unsigned int gen = 0;
       char buffer[4096];
       ++gen;
       if ((gen % 10) == 0) {
-	snprintf(buffer, sizeof(buffer), "/tmp/surface%d_level%d_%d.png", gl_target, gl_level, gen);
+	snprintf(buffer, sizeof(buffer), "/tmp/surface%u_level%u_%u.png", gl_target, gl_level, gen);
 	IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This, buffer);
       }
     }
@@ -528,7 +529,7 @@
     return D3DERR_INVALIDCALL;
   }
 
-  TRACE("opened %s\n", filename);
+  TRACE("opened %s with format %s\n", filename, debug_d3dformat(This->myDesc.Format));
 
   fprintf(f, "P6\n%u %u\n255\n", This->myDesc.Width, This->myDesc.Height);
   switch (This->myDesc.Format) {
@@ -560,20 +561,32 @@
       WORD color;
       for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
 	color = ((WORD*) This->allocatedMemory)[i];
-	fputc((color >> 10) & 0xFF, f);
-	fputc((color >>  5) & 0xFF, f);
-	fputc((color >>  0) & 0xFF, f);
+	fputc(((color >> 10) & 0x1F) * 255 / 31, f);
+	fputc(((color >>  5) & 0x1F) * 255 / 31, f);
+	fputc(((color >>  0) & 0x1F) * 255 / 31, f);
       }
     }
     break;
+  case D3DFMT_A4R4G4B4:
+    {
+      WORD color;
+      for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
+	color = ((WORD*) This->allocatedMemory)[i];
+	fputc(((color >>  8) & 0x0F) * 255 / 15, f);
+	fputc(((color >>  4) & 0x0F) * 255 / 15, f);
+	fputc(((color >>  0) & 0x0F) * 255 / 15, f);
+      }
+    }
+    break;
+
   case D3DFMT_R5G6B5: 
     {
       WORD color;
       for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
 	color = ((WORD*) This->allocatedMemory)[i];
-	fputc((color >> 11) & 0xFF, f);
-	fputc((color >>  5) & 0xFF, f);
-	fputc((color >>  0) & 0xFF, f);
+	fputc(((color >> 11) & 0x1F) * 255 / 31, f);
+	fputc(((color >>  5) & 0x3F) * 255 / 63, f);
+	fputc(((color >>  0) & 0x1F) * 255 / 31, f);
       }
     }
     break;


More information about the wine-devel mailing list