Changeset 3394 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display/enable.c
- Timestamp:
- Jul 3, 2007 4:24:33 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/enable.c
r3380 r3394 14 14 15 15 #include "driver.h" 16 #include "dd.h" 16 17 17 18 // The driver function table with all function index/address pairs … … 147 148 { INDEX_DrvEnableDirectDraw, (PFN) DrvEnableDirectDraw }, // 60 0x3c 148 149 { INDEX_DrvDisableDirectDraw, (PFN) DrvDisableDirectDraw }, // 61 0x3d 150 { INDEX_DrvDeriveSurface, (PFN) DrvDeriveSurface }, // 85 149 151 #endif 150 152 { INDEX_DrvNotify, (PFN) DrvNotify }, // 87 0x57 … … 852 854 } 853 855 } 856 857 #ifdef VBOX_WITH_DDRAW 858 //--------------------------Public Routine------------------------------------- 859 // 860 // HBITMAP DrvDeriveSurface 861 // 862 // This function derives and creates a GDI surface from the specified 863 // DirectDraw surface. 864 // 865 // Parameters 866 // pDirectDraw-----Points to a DD_DIRECTDRAW_GLOBAL structure that describes 867 // the DirectDraw object. 868 // pSurface--------Points to a DD_SURFACE_LOCAL structure that describes the 869 // DirectDraw surface around which to wrap a GDI surface. 870 // 871 // Return Value 872 // DrvDeriveSurface returns a handle to the created GDI surface upon success. 873 // It returns NULL if the call fails or if the driver cannot accelerate GDI 874 // drawing to the specified DirectDraw surface. 875 // 876 // Comments 877 // DrvDeriveSurface allows the driver to create a GDI surface around a 878 // DirectDraw video memory or AGP surface object in order to allow accelerated 879 // GDI drawing to the surface. If the driver does not hook this call, all GDI 880 // drawing to DirectDraw surfaces is done in software using the DIB engine. 881 // 882 // GDI calls DrvDeriveSurface with RGB surfaces only. 883 // 884 // The driver should call DrvCreateDeviceBitmap to create a GDI surface of the 885 // same size and format as that of the DirectDraw surface. Space for the 886 // actual pixels need not be allocated since it already exists. 887 // 888 //----------------------------------------------------------------------------- 889 HBITMAP DrvDeriveSurface(DD_DIRECTDRAW_GLOBAL* pDirectDraw, DD_SURFACE_LOCAL* pSurface) 890 { 891 PPDEV pDev = (PPDEV)pDirectDraw->dhpdev; 892 HBITMAP hbmDevice; 893 DD_SURFACE_GLOBAL* pSurfaceGlobal; 894 SIZEL sizl; 895 896 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 897 898 pSurfaceGlobal = pSurface->lpGbl; 899 900 // 901 // GDI should never call us for a non-RGB surface, but let's assert just 902 // to make sure they're doing their job properly. 903 // 904 AssertMsg(!(pSurfaceGlobal->ddpfSurface.dwFlags & DDPF_FOURCC), ("GDI called us with a non-RGB surface!")); 905 906 907 // The GDI driver does not accelerate surfaces in AGP memory, 908 // thus we fail the call 909 910 if (pSurface->ddsCaps.dwCaps & DDSCAPS_NONLOCALVIDMEM) 911 { 912 DISPDBG((0, "DrvDeriveSurface return NULL, surface in AGP memory")); 913 return 0; 914 } 915 916 // The GDI driver does not accelerate managed surface, 917 // thus we fail the call 918 if (pSurface->lpSurfMore->ddsCapsEx.dwCaps2 & DDSCAPS2_TEXTUREMANAGE) 919 { 920 DISPDBG((0, "DrvDeriveSurface return NULL, surface is managed")); 921 return 0; 922 } 923 924 // 925 // The rest of our driver expects GDI calls to come in with the same 926 // format as the primary surface. So we'd better not wrap a device 927 // bitmap around an RGB format that the rest of our driver doesn't 928 // understand. Also, we must check to see that it is not a surface 929 // whose pitch does not match the primary surface. 930 // 931 // NOTE: Most surfaces created by this driver are allocated as 2D surfaces 932 // whose lPitch's are equal to the screen pitch. However, overlay surfaces 933 // are allocated such that there lPitch's are usually different then the 934 // screen pitch. The hardware can not accelerate drawing operations to 935 // these surfaces and thus we fail to derive these surfaces. 936 // 937 if ( (pSurfaceGlobal->ddpfSurface.dwRGBBitCount == pDev->ulBitCount) ) 938 { 939 SIZEL sizel; 940 DWORD ulBitmapType, flHooks; 941 942 sizl.cx = pSurfaceGlobal->wWidth; 943 sizl.cy = pSurfaceGlobal->wHeight; 944 945 if (pDev->ulBitCount == 8) 946 { 947 if (!bInit256ColorPalette(pDev)) { 948 DISPDBG((0, "DISP DrvEnableSurface failed to init the 8bpp palette\n")); 949 return(FALSE); 950 } 951 ulBitmapType = BMF_8BPP; 952 flHooks = HOOKS_BMF8BPP; 953 } 954 else if (pDev->ulBitCount == 16) 955 { 956 ulBitmapType = BMF_16BPP; 957 flHooks = HOOKS_BMF16BPP; 958 } 959 else if (pDev->ulBitCount == 24) 960 { 961 ulBitmapType = BMF_24BPP; 962 flHooks = HOOKS_BMF24BPP; 963 } 964 else 965 { 966 ulBitmapType = BMF_32BPP; 967 flHooks = HOOKS_BMF32BPP; 968 } 969 970 hbmDevice = EngCreateBitmap(sizl, 971 pDev->lDeltaScreen, 972 ulBitmapType, 973 (pDev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0, 974 (PVOID) (pDev->pjScreen)); 975 if (hbmDevice) 976 { 977 VOID* pvScan0 = pDev->pjScreen + pSurfaceGlobal->fpVidMem; 978 979 // 980 // Note that HOOK_SYNCHRONIZE must always be hooked when we 981 // give GDI a pointer to the bitmap bits. We don't need to 982 // do it here since HOOK_SYNCHRONIZE is always set in our 983 // pdev->flHooks 984 // 985 ULONG flags = MS_NOTSYSTEMMEMORY; 986 987 if ( EngModifySurface((HSURF)hbmDevice, 988 pDev->hdevEng, 989 pDev->flHooks, 990 flags, 991 (DHSURF)hbmDevice, 992 pvScan0, 993 pSurfaceGlobal->lPitch, 994 NULL) ) 995 { 996 SURFOBJ* surfobj = EngLockSurface((HSURF) hbmDevice); 997 AssertMsg(surfobj->iType == STYPE_BITMAP, ("expected STYPE_BITMAP")); 998 surfobj->iType = STYPE_DEVBITMAP; 999 EngUnlockSurface(surfobj); 1000 1001 DISPDBG((0, "DrvDeriveSurface return succeed")); 1002 return(hbmDevice); 1003 } 1004 1005 DISPDBG((0, "DrvDeriveSurface: EngModifySurface failed")); 1006 EngDeleteSurface((HSURF)hbmDevice); 1007 } 1008 } 1009 1010 DISPDBG((0, "DrvDeriveSurface return NULL")); 1011 DISPDBG((0, "pSurfaceGlobal->ddpfSurface.dwRGBBitCount = %d, lPitch =%ld", pSurfaceGlobal->ddpfSurface.dwRGBBitCount,pSurfaceGlobal->lPitch)); 1012 1013 return(0); 1014 } 1015 #endif /* VBOX_WITH_DDRAW */
Note:
See TracChangeset
for help on using the changeset viewer.