[ros-diffs] [greatlrd] 37408: Fixed a old typo HelDdSurfLock it should be DIB_RGB_* not DIB_PAL_* when it try getting rgb bitmap pixel data Ported old experiment code for HelDdSurfUnLock it is not completed and can be very buggy Fixed smaller bug in Main_DDrawSurface_Unlock the rest of visrgn can fail on real hw. if it fail, it was not supported by the hw drv for most case. so it is safe to ignore if it fails

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Mon Nov 17 16:52:02 CET 2008


Author: greatlrd
Date: Mon Nov 17 09:52:02 2008
New Revision: 37408

URL: http://svn.reactos.org/svn/reactos?rev=37408&view=rev
Log:
Fixed a old typo HelDdSurfLock it should be DIB_RGB_* not DIB_PAL_* when it try getting rgb bitmap pixel data

Ported old experiment code for HelDdSurfUnLock it is not completed and can be very buggy

Fixed smaller bug in Main_DDrawSurface_Unlock the rest of visrgn can fail on real hw. if it fail, it was not supported by the hw drv for most case. so it is safe to ignore if it fails

Modified:
    branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c
    branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c

Modified: branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c
URL: http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c?rev=37408&r1=37407&r2=37408&view=diff
==============================================================================
--- branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c [iso-8859-1] Mon Nov 17 09:52:02 2008
@@ -8,54 +8,59 @@
 *
 */
 #include "rosdraw.h"
+
 DWORD CALLBACK HelDdSurfAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA lpDestroySurface)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)
 {
-if (lpBltData->dwFlags & DDBLT_COLORFILL)
-{
-HBRUSH hbr = CreateSolidBrush(lpBltData->bltFX.dwFillColor );
-FillRect( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
-(CONST RECT *)&lpBltData->rDest,
-hbr);
-DeleteObject(hbr);
-lpBltData->ddRVal = DD_OK;
-}
-
-else if (lpBltData->dwFlags & DDBLT_ROP)
-{
-
-BitBlt( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
-lpBltData->rDest.top,
-lpBltData->rDest.left,
-lpBltData->rDest.right,
-lpBltData->rDest.bottom,
-(HDC)lpBltData->lpDDSrcSurface->lpSurfMore->lpDD_lcl->hDC,
-lpBltData->rSrc.top,
-lpBltData->rSrc.right,
-lpBltData->bltFX.dwROP);
-lpBltData->ddRVal = DD_OK;
-}
-return DDHAL_DRIVER_HANDLED;
-}
+    if (lpBltData->dwFlags & DDBLT_COLORFILL)
+    {
+        HBRUSH hbr = CreateSolidBrush(lpBltData->bltFX.dwFillColor );
+        FillRect( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
+                  (CONST RECT *)&lpBltData->rDest,
+                  hbr);
+        DeleteObject(hbr);
+        lpBltData->ddRVal = DD_OK;
+    }
+    else if (lpBltData->dwFlags & DDBLT_ROP)
+    {
+        BitBlt( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
+                lpBltData->rDest.top,
+                lpBltData->rDest.left,
+                lpBltData->rDest.right,
+                lpBltData->rDest.bottom,
+                (HDC)lpBltData->lpDDSrcSurface->lpSurfMore->lpDD_lcl->hDC,
+                lpBltData->rSrc.top,
+                lpBltData->rSrc.right,
+                lpBltData->bltFX.dwROP);
+                lpBltData->ddRVal = DD_OK;
+    }
+    return DDHAL_DRIVER_HANDLED;
+}
+
 DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfFlip(LPDDHAL_FLIPDATA lpFlipData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfGetBltStatus(LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)
 {
     HDC hDC;
@@ -102,7 +107,7 @@
             else
             {
                 /* Extract the bitmap bits data from RGB bitmap */
-                retvalue = GetDIBits(hDC, hBmp, 0, bm.bmHeight, pixels, &bmi, DIB_PAL_COLORS);
+                retvalue = GetDIBits(hDC, hBmp, 0, bm.bmHeight, pixels, &bmi, DIB_RGB_COLORS);
             }
 
             /* Check see if we susccess it to get the memory pointer and fill it for the bitmap pixel data */
@@ -136,33 +141,83 @@
 
 DWORD CALLBACK HelDdSurfreserved4(DWORD *lpPtr)
 {
-/*
-This api is not doucment by MS So I leave it
-as stub.
-*/
-DX_STUB;
-}
+    /*
+    This api is not doucment by MS So I leave it
+    as stub.
+    */
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfSetClipList(LPDDHAL_SETCLIPLISTDATA lpSetClipListData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfSetColorKey(LPDDHAL_SETCOLORKEYDATA lpSetColorKeyData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfSetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA lpSetOverlayPositionData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfSetPalette(LPDDHAL_SETPALETTEDATA lpSetPaletteData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+
 DWORD CALLBACK HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData)
 {
-DX_STUB;
-}
+    HDC hDC;
+    BITMAP bm;
+    PDWORD pixels = NULL;
+    HGDIOBJ hBmp;
+    BITMAPINFO bmi;
+    int retvalue = 0;
+
+    /* Get our hdc for the surface */
+    hDC = (HDC)lpUnLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hDC;
+
+    /* Get our bitmap handle from hdc, we need it if we want extract the Bitmap pixel data */
+    hBmp = GetCurrentObject(hDC, OBJ_BITMAP);
+
+    /* Get our bitmap information from hBmp, we need it if we want extract the Bitmap pixel data */
+    if (GetObject(hBmp, sizeof(BITMAP), &bm) )
+    {
+        /* Zero out all members in bmi so no junk data are left */
+        ZeroMemory(&bmi, sizeof(BITMAPINFO));
+
+        /* Setup BITMAPINFOHEADER for bmi header */
+        bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+        bmi.bmiHeader.biWidth = bm.bmWidth;
+        bmi.bmiHeader.biHeight = bm.bmHeight;
+        bmi.bmiHeader.biPlanes = bm.bmPlanes;
+        bmi.bmiHeader.biBitCount = bm.bmBitsPixel;
+        bmi.bmiHeader.biCompression = BI_RGB;
+
+        /* Check if it the bitmap is palete or not */
+        if ( bm.bmBitsPixel <= 8)
+        {
+            /* Upload the bitmap bits data from palete bitmap */
+            retvalue = SetDIBits(hDC, hBmp, 0, bm.bmHeight, pixels, &bmi, DIB_PAL_COLORS);
+        }
+        else
+        {
+            /* Upload the bitmap bits data from RGB bitmap */
+            retvalue = SetDIBits(hDC, hBmp, 0, bm.bmHeight, pixels, &bmi, DIB_RGB_COLORS);
+        }
+    }
+    if (retvalue)
+    {
+        lpUnLockData->ddRVal = DD_OK;
+    }
+    return DDHAL_DRIVER_HANDLED;
+}
+
 DWORD CALLBACK HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOveryLayData)
 {
-DX_STUB;
-}
+    DX_STUB;
+}
+

Modified: branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c
URL: http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c?rev=37408&r1=37407&r2=37408&view=diff
==============================================================================
--- branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c [iso-8859-1] Mon Nov 17 09:52:02 2008
@@ -303,10 +303,10 @@
         mDdBlt.Blt = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt;
     }
 
-    /* check see if we got any of them */
     if (mDdBlt.Blt == NULL)
     {
-        return DDERR_GENERIC;
+        /* This api are unsupported */
+        return DDERR_UNSUPPORTED;
     }
 
     /* Prepare for draw, if we do not rest the DdResetVisrgn some graphice card will not draw on the screen */
@@ -412,8 +412,7 @@
 
     DX_WINDBG_trace_res( (DWORD)ThisDest->lpLcl->lpGbl->wWidth, (DWORD)ThisDest->lpLcl->lpGbl->wHeight, (DWORD)ThisDest->lpLcl->lpGbl->lPitch, (DWORD) 0);
 
-
-     /* Zero out members in DDHAL_BLTDATA */
+     /* Zero out members in DDHAL_LOCKDATA */
     ZeroMemory(&mdLock, sizeof(DDHAL_LOCKDATA));
 
      /* Check if we got HAL support for this api */
@@ -427,6 +426,12 @@
           DDHAL_SURFCB32_LOCK) == DDHAL_SURFCB32_LOCK)
     {
         mdLock.Lock = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock;
+    }
+
+    if (mdLock.Lock == NULL)
+    {
+        /* This api are unsupported */
+        return DDERR_UNSUPPORTED;
     }
 
     if (events != NULL)
@@ -505,30 +510,45 @@
 
 HRESULT WINAPI Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT pRect)
 {
-	DDHAL_UNLOCKDATA mdUnLock;
-
-	DX_WINDBG_trace();
-
-	if (!This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_UNLOCK)
-	{
-	   DX_STUB_str("DDERR_UNSUPPORTED");
-	   return DDERR_UNSUPPORTED;
-	}
+    DDHAL_UNLOCKDATA mdUnLock;
+
+    DX_WINDBG_trace();
+
+    /* Zero out members in DDHAL_UNLOCKDATA */
+    ZeroMemory(&mdUnLock, sizeof(DDHAL_UNLOCKDATA));
+
+     /* Check if we got HAL support for this api */
+    if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
+        DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
+    {
+        mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Unlock;
+    }
+    /* Check if we got HEL support for this api */
+    else if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
+          DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
+    {
+        mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock;
+    }
+
+    if (mdUnLock.Unlock == NULL)
+    {
+        /* This api are unsupported */
+        return DDERR_UNSUPPORTED;
+    }
 
     mdUnLock.ddRVal = DDERR_NOTPALETTIZED;
     mdUnLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
-	mdUnLock.lpDDSurface =  This->lpLcl->lpSurfMore->slist[0];
-	mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->HALDDSurface.Unlock;
+    mdUnLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
 
     if (!DdResetVisrgn( mdUnLock.lpDDSurface, NULL))
     {
-        DX_STUB_str("DDERR_UNSUPPORTED");
-		return DDERR_UNSUPPORTED;
+        DX_STUB_str("DdResetVisrgn fail");
+        //return DDERR_UNSUPPORTED; /* this can fail */
     }
 
     if (mdUnLock.Unlock(&mdUnLock)!= DDHAL_DRIVER_HANDLED)
     {
-		DX_STUB_str("unLock fail");
+        DX_STUB_str("unLock fail");
         return DDERR_UNSUPPORTED;
     }
 



More information about the Ros-diffs mailing list