DWORD WINAPI HalFlip(LPDDHAL_FLIPDATA lpfd) { DEBUGENTER( HalFlip ); /* typedef struct _DDHAL_FLIPDATA { LPDDRAWI_DIRECTDRAW_GBL lpDD; LPDDRAWI_DDRAWSURFACE_LCL lpSurfCurr; LPDDRAWI_DDRAWSURFACE_LCL lpSurfTarg; DWORD dwFlags; HRESULT ddRVal; } DDHAL_FLIPDATA; */ S3C6410Disp *pDDGPE = (S3C6410Disp *)GetDDGPE(); DWORD dwFlags = lpfd->dwFlags; if (dwFlags & (DDFLIP_INTERVAL1|DDFLIP_INTERVAL2|DDFLIP_INTERVAL4)) { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalFlip() : DDFLIP_INTERVAL is not supported\n\r"))); lpfd->ddRVal = DDERR_UNSUPPORTED; } else { if (dwFlags & DDFLIP_WAITNOTBUSY) { // Our H/W always not busy.. This will be skipped while(((S3C6410Disp *)GetDDGPE())->IsBusy()); } DDGPESurf* surfTarg = DDGPESurf::GetDDGPESurf(lpfd->lpSurfTarg); if (dwFlags & DDFLIP_WAITVSYNC) { pDDGPE->SetVisibleSurface(surfTarg, TRUE); } else { pDDGPE->SetVisibleSurface(surfTarg, FALSE); } lpfd->ddRVal = DD_OK; } DEBUGLEAVE( HalFlip ); return DDHAL_DRIVER_HANDLED; }
DWORD WINAPI HalSetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA lpsopd) { DEBUGENTER( HalSetOverlayPosition ); /* typedef struct _DDHAL_SETOVERLAYPOSITIONDATA { LPDDRAWI_DIRECTDRAW_GBL lpDD; LPDDRAWI_DDRAWSURFACE_LCL lpDDSrcSurface; LPDDRAWI_DDRAWSURFACE_LCL lpDDDestSurface; LONG lXPos; LONG lYPos; HRESULT ddRVal; } DDHAL_SETOVERLAYPOSITIONDATA; */ S3C6410Disp *pDDGPE; //S3C6410Surf *pSrcSurf; pDDGPE = (S3C6410Disp *)GetDDGPE(); //pSrcSurf = (S3C6410Surf *)DDGPESurf::GetDDGPESurf(lpsopd->lpDDSrcSurface); pDDGPE->OverlaySetPosition((unsigned int)lpsopd->lXPos, (unsigned int)lpsopd->lYPos); lpsopd->ddRVal = DD_OK; return DDHAL_DRIVER_HANDLED; }
DWORD WINAPI HalCreateSurface(LPDDHAL_CREATESURFACEDATA lpcsd) { DEBUGENTER( HalCreateSurface ); /* typedef struct _DDHAL_CREATESURFACEDATA { LPDDRAWI_DIRECTDRAW_GBL lpDD; LPDDSURFACEDESC lpDDSurfaceDesc; LPDDRAWI_DDRAWSURFACE_LCL lplpSList; DWORD dwSCnt; HRESULT ddRVal; } DDHAL_CREATESURFACEDATA; */ DWORD dwCaps = lpcsd->lpDDSurfaceDesc->ddsCaps.dwCaps; DWORD dwFlags = lpcsd->lpDDSurfaceDesc->dwFlags; // Handle Overlay Surface if (dwCaps & DDSCAPS_OVERLAY) { EGPEFormat format; EDDGPEPixelFormat pixelFormat; S3C6410Disp *pDDGPE = (S3C6410Disp *)GetDDGPE(); lpcsd->ddRVal = pDDGPE->DetectPixelFormat(dwCaps, &lpcsd->lpDDSurfaceDesc->ddpfPixelFormat, &format, &pixelFormat); RETAILMSG(TRUE,(TEXT("CreateSurface:%d\n"),lpcsd->ddRVal)); if (FAILED(lpcsd->ddRVal)) { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalCreateSurface() : Unsupported format\n\r"))); return DDHAL_DRIVER_HANDLED; } // Create Overlay Surface with DDGPECreateSurface() function return DDGPECreateSurface(lpcsd); } else { // Pass to Non-overlay surface to DDGPECreateSurface() function return DDGPECreateSurface(lpcsd); } }
EXTERN_C void buildDDHALInfo(LPDDHALINFO lpddhi, DWORD modeidx) { DDHAL_MSG((_T("[DDHAL] ++buildDDHALInfo()\r\n"))); S3C6400Disp *pS3C6400Disp = ((S3C6400Disp *)GetDDGPE()); #if 0 // Make sure that we don't rotate untill DDraw is done. //pS3C6400Disp->m_InDDraw = TRUE; #endif if(g_pVideoMemory == NULL) // to avoid confilct in case of called more than once... { unsigned long VideoMemoryStart; unsigned long VideoMemorySize; pS3C6400Disp->GetVirtualVideoMemory(&VideoMemoryStart, &VideoMemorySize); g_pVideoMemory = (unsigned char *)VideoMemoryStart; g_nVideoMemorySize = (DWORD)VideoMemorySize; DDHAL_INF((_T("[DDHAL:INF] buildDDHALInfo() : VideoMemory = 0x%08x\r\n"), g_pVideoMemory)); DDHAL_INF((_T("[DDHAL:INF] buildDDHALInfo() : VideoMemorySize = 0x%08x\r\n"), g_nVideoMemorySize)); } // Clear the DDHALINFO structure memset(lpddhi, 0, sizeof(DDHALINFO)); //---------------------- // Fill DDHALINFO Structure //---------------------- lpddhi->dwSize = sizeof(DDHALINFO); lpddhi->dwFlags = 0; // Reserved. Set to 0 for future compatibility. // Callbacks lpddhi->lpDDCallbacks = &cbDDCallbacks; lpddhi->lpDDSurfaceCallbacks = &cbDDSurfaceCallbacks; lpddhi->lpDDPaletteCallbacks = NULL; // WinCE6.0 WM6.0 Unsupport. Must be set to NULL lpddhi->GetDriverInfo = HalGetDriverInfo; lpddhi->lpdwFourCC = lpdwFourCC; // fourcc codes supported //-------------------------------------------------- // Capabilities that are supported in the display hardware. //-------------------------------------------------- lpddhi->ddCaps.dwSize = sizeof(DDCAPS); // size of the DDDRIVERCAPS structure // Surface capabilities lpddhi->ddCaps.dwVidMemTotal = g_nVideoMemorySize; // total amount of video memory lpddhi->ddCaps.dwVidMemFree = g_nVideoMemorySize; // amount of free video memory lpddhi->ddCaps.dwVidMemStride = 0; // This value is 0 if the stride is linear. // Capabilities of the surface. lpddhi->ddCaps.ddsCaps.dwCaps = //DDSCAPS_ALPHA | // Indicates that this surface contains alpha-only information. DDSCAPS_BACKBUFFER | // Indicates that this surface is the back buffer of a surface flipping structure. // DDSCAPS_DYNAMIC | // Unsupported. DDSCAPS_FLIP | // Indicates that this surface is a part of a surface flipping structure. DDSCAPS_FRONTBUFFER | // Indicates that this surface is the front buffer of a surface flipping structure. //DDSCAPS_NOTUSERLOCKABLE | // Unsupported. DDSCAPS_OVERLAY | // Indicates that this surface is an overlay. //DDSCAPS_PALETTE | // Not supported. DDSCAPS_PRIMARYSURFACE | // Indicates the surface is the primary surface. //DDSCAPS_READONLY | // Indicates that only read access is permitted to the surface. When locking the surface with IDirectDrawSurface::Lock, the DDLOCK_READONLY flag must be specified. DDSCAPS_SYSTEMMEMORY | // Indicates that this surface memory was allocated in system memory. DDSCAPS_VIDEOMEMORY | // Indicates that this surface exists in display memory. //DDSCAPS_WRITEONLY | // Indicates that only write access is permitted to the surface. 0; lpddhi->ddCaps.dwNumFourCCCodes = MAX_FOURCC; // number of four cc codes // Palette capabilities. lpddhi->ddCaps.dwPalCaps = //DDPCAPS_ALPHA | // Supports palettes that include an alpha component. For alpha-capable palettes, the peFlags member of for each PALETTEENTRY structure the palette contains is to be interpreted as a single 8-bit alpha value (in addition to the color data in the peRed, peGreen, and peBlue members). A palette created with this flag can only be attached to a texture surface. //DDPCAPS_PRIMARYSURFACE | // Indicates that the palette is attached to the primary surface. Changing the palette has an immediate effect on the display unless the DDPCAPS_VSYNC capability is specified and supported. 0; // Hardware blitting capabilities // // Driver specific blitting capabilities. lpddhi->ddCaps.dwBltCaps = //DDBLTCAPS_READSYSMEM | // Supports blitting from system memory. //DDBLTCAPS_WRITESYSMEM | // Supports blitting to system memory. //DDBLTCAPS_FOURCCTORGB | // Supports blitting from a surface with a FOURCC pixel format to a surface with an RGB pixel format. //DDBLTCAPS_COPYFOURCC | // Supports blitting from a surface with a FOURCC pixel format to another surface with the same pixel format, or to the same surface. DDBLTCAPS_FILLFOURCC Supports color-fill blitting to a surface with a FOURCC pixel format. //DDBLTCAPS_FILLFOURCC | // Supports color-fill blitting to a surface with a FOURCC pixel format. 0; // Color key capabilities lpddhi->ddCaps.dwCKeyCaps = //DDCKEYCAPS_BOTHBLT | // Supports transparent blitting with for both source and destination surfaces. //DDCKEYCAPS_DESTBLT | // Supports transparent blitting with a color key that identifies the replaceable bits of the destination surface for RGB colors. //DDCKEYCAPS_DESTBLTCLRSPACE | // Supports transparent blitting with a color space that identifies the replaceable bits of the destination surface for RGB colors. //DDCKEYCAPS_DESTBLTCLRSPACEYUv | // Supports transparent blitting with a color space that identifies the replaceable bits of the destination surface for YUV colors. //DDCKEYCAPS_SRCBLT | // Supports transparent blitting using the color key for the source with this surface for RGB colors. //DDCKEYCAPS_SRCBLTCLRSPACE | // Supports transparent blitting using a color space for the source with this surface for RGB colors. //DDCKEYCAPS_SRCBLTCLRSPACEYUV | // Supports transparent blitting using a color space for the source with this surface for YUV colors. 0; // Alpha blitting capabilities. lpddhi->ddCaps.dwAlphaCaps = //DDALPHACAPS_ALPHAPIXELS | // Supports per-pixel alpha values specified alongside with the RGB values in the pixel structure. //DDALPHACAPS_ALPHASURFACE | // Unsupported. //DDALPHACAPS_ALPHAPALETTE | // Unsupported. //DDALPHACAPS_ALPHACONSTANT | // Unsupported. //DDALPHACAPS_ARGBSCALE | // Unsupported. //DDALPHACAPS_SATURATE | // Unsupported. //DDALPHACAPS_PREMULT | // Supports pixel formats with premultiplied alpha values. //DDALPHACAPS_NONPREMULT | // Supports pixel formats with non-premultiplied alpha values. //DDALPHACAPS_ALPHAFILL | // Supports color-fill blitting using an alpha value. //DDALPHACAPS_ALPHANEG | // Supports inverted-alpha pixel formats, where 0 indicates fully opaque and 255 indicates fully transparent. 0; SETROPBIT(lpddhi->ddCaps.dwRops, SRCCOPY); // Set bits for ROPS supported SETROPBIT(lpddhi->ddCaps.dwRops, PATCOPY); SETROPBIT(lpddhi->ddCaps.dwRops, BLACKNESS); SETROPBIT(lpddhi->ddCaps.dwRops, WHITENESS); // General overlay capabilities. lpddhi->ddCaps.dwOverlayCaps = DDOVERLAYCAPS_FLIP | // Supports surface flipping with overlays. DDOVERLAYCAPS_FOURCC | // Supports FOURCC pixel formats with overlays. Use IDirectDraw::GetFourCCCodes to determine which FOURCC formats are supported. //DDOVERLAYCAPS_ZORDER | // Supports changing Z order of overlays. //DDOVERLAYCAPS_MIRRORLEFTRIGHT | // Supports surface mirroring in the left-to-right direction for overlays. //DDOVERLAYCAPS_MIRRORUPDOWN | // Supports surface mirroring in the up-to-down direction for overlays. DDOVERLAYCAPS_CKEYSRC | // Supports source color keying for overlays. DDOVERLAYCAPS_CKEYSRCCLRSPACE | // Supports source color-space keying for overlays. DDOVERLAYCAPS_CKEYSRCCLRSPACEYUV | // Supports source color-space keying for overlays with FOURCC pixel formats. DDOVERLAYCAPS_CKEYDEST | // Supports destination color keying for overlays. DDOVERLAYCAPS_CKEYDESTCLRSPACE | // Supports destination colo-space keying for overlays. DDOVERLAYCAPS_CKEYDESTCLRSPACEYUV | // Supports destination color-space keying for overlays with FOURCC pixel formats. //DDOVERLAYCAPS_CKEYBOTH | // Supports simultaneous source and destination color keying for overlays. //DDOVERLAYCAPS_ALPHADEST | // Supports destination alpha blending for overlays. DDOVERLAYCAPS_ALPHASRC | // Supports source alpha blending for overlays. //DDOVERLAYCAPS_ALPHADESTNEG | // Supports inverted destination alpha blending for overlays. //DDOVERLAYCAPS_ALPHASRCNEG | // Supports inverted source alpha blending for overlays. DDOVERLAYCAPS_ALPHACONSTANT | // Supports constant alpha blending for overlays (specified in the DDOVERLAYFX structure). //DDOVERLAYCAPS_ALPHAPREMULT | // Supports premultiplied alpha pixel formats for overlay alpha blending. //DDOVERLAYCAPS_ALPHANONPREMULT | // Supports non-premultiplied alpha pixel formats for overlay alpha blending. //DDOVERLAYCAPS_ALPHAANDKEYDEST | // Supports simultaneous source alpha blending with a destination color key for overlays. DDOVERLAYCAPS_OVERLAYSUPPORT | // Supports overlay surfaces. 0; lpddhi->ddCaps.dwMaxVisibleOverlays = 1; // Maximum number of visible overlays or overlay sprites. lpddhi->ddCaps.dwCurrVisibleOverlays = 0; // Current number of visible overlays or overlay sprites. lpddhi->ddCaps.dwAlignBoundarySrc = 8; // Source rectangle alignment, in pixels, for an overlay surface lpddhi->ddCaps.dwAlignSizeSrc = 8; // Source rectangle size alignment, in pixels, for an overlay surface. lpddhi->ddCaps.dwAlignBoundaryDest = 2; // Destination rectangle alignment, in pixels, for an overlay surface. lpddhi->ddCaps.dwAlignSizeDest = 8; // Destination rectangle size alignment, in pixels, for an overlay surface. lpddhi->ddCaps.dwMinOverlayStretch = 250; // 1x 1000 lpddhi->ddCaps.dwMaxOverlayStretch = 4000; // 1x 1000 // Miscellaneous video capabilities. lpddhi->ddCaps.dwMiscCaps = DDMISCCAPS_READSCANLINE | // Supports reading the current scanline being drawn. //DDMISCCAPS_READMONITORFREQ | // Unsupported. DDMISCCAPS_READVBLANKSTATUS | // Supports reading the current V-Blank status of the hardware. //DDMISCCAPS_FLIPINTERVAL | // Supports interval flipping. //DDMISCCAPS_FLIPODDEVEN | // Supports Even/Odd flipping. DDMISCCAPS_FLIPVSYNCWITHVBI | // Supports V-Sync-coordinated flipping. //DDMISCCAPS_COLORCONTROLOVERLAY | // Supports color controls on overlay surfaces. //DDMISCCAPS_COLORCONTROLPRIMARY | // Supports color controls on primary surfaces. //DDMISCCAPS_GAMMACONTROLOVERLAY | // Supports gamma controls on overlay surfaces. //DDMISCCAPS_GAMMACONTROLPRIMARY | // Supports gamma controls on primary surfaces. 0; // Video port capabilities. //lpddhi->ddCaps.dwMinVideoStretch = 1000; // minimum video port stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 //lpddhi->ddCaps.dwMaxVideoStretch = 1000; // maximum video port stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 //lpddhi->ddCaps.dwMaxVideoPorts = 0; // maximum number of usable video ports //lpddhi->ddCaps.dwCurrVideoPorts = 0; // current number of video ports used #if 0 // TODO: //--------------------------------------------------------- // Capabilities that are supported in software emulation by the driver. //--------------------------------------------------------- lpddhi->ddHelCaps.dwSize = sizeof(DDCAPS); // size of the DDDRIVERCAPS structure // Surface capabilities lpddhi->ddHelCaps.dwVidMemTotal = g_nVideoMemorySize; // total amount of video memory lpddhi->ddHelCaps.dwVidMemFree = g_nVideoMemorySize; // amount of free video memory lpddhi->ddHelCaps.dwVidMemStride = 0; // This value is 0 if the stride is linear. // Capabilities of the surface. lpddhi->ddHelCaps.ddsCaps.dwCaps = //DDSCAPS_ALPHA | // Indicates that this surface contains alpha-only information. DDSCAPS_BACKBUFFER | // Indicates that this surface is the back buffer of a surface flipping structure. // DDSCAPS_DYNAMIC | // Unsupported. DDSCAPS_FLIP | // Indicates that this surface is a part of a surface flipping structure. DDSCAPS_FRONTBUFFER | // Indicates that this surface is the front buffer of a surface flipping structure. //DDSCAPS_NOTUSERLOCKABLE | // Unsupported. DDSCAPS_OVERLAY | // Indicates that this surface is an overlay. //DDSCAPS_PALETTE | // Not supported. DDSCAPS_PRIMARYSURFACE | // Indicates the surface is the primary surface. //DDSCAPS_READONLY | // Indicates that only read access is permitted to the surface. When locking the surface with IDirectDrawSurface::Lock, the DDLOCK_READONLY flag must be specified. DDSCAPS_SYSTEMMEMORY | // Indicates that this surface memory was allocated in system memory. DDSCAPS_VIDEOMEMORY | // Indicates that this surface exists in display memory. //DDSCAPS_WRITEONLY | // Indicates that only write access is permitted to the surface. 0; lpddhi->ddHelCaps.dwNumFourCCCodes = MAX_FOURCC; // number of four cc codes // Palette capabilities. lpddhi->ddHelCaps.dwPalCaps = //DDPCAPS_ALPHA | // Supports palettes that include an alpha component. For alpha-capable palettes, the peFlags member of for each PALETTEENTRY structure the palette contains is to be interpreted as a single 8-bit alpha value (in addition to the color data in the peRed, peGreen, and peBlue members). A palette created with this flag can only be attached to a texture surface. //DDPCAPS_PRIMARYSURFACE | // Indicates that the palette is attached to the primary surface. Changing the palette has an immediate effect on the display unless the DDPCAPS_VSYNC capability is specified and supported. 0; // Hardware blitting capabilities // // Driver specific blitting capabilities. lpddhi->ddHelCaps.dwBltCaps = //DDBLTCAPS_READSYSMEM | // Supports blitting from system memory. //DDBLTCAPS_WRITESYSMEM | // Supports blitting to system memory. //DDBLTCAPS_FOURCCTORGB | // Supports blitting from a surface with a FOURCC pixel format to a surface with an RGB pixel format. //DDBLTCAPS_COPYFOURCC | // Supports blitting from a surface with a FOURCC pixel format to another surface with the same pixel format, or to the same surface. DDBLTCAPS_FILLFOURCC Supports color-fill blitting to a surface with a FOURCC pixel format. 0; // Color key capabilities lpddhi->ddHelCaps.dwCKeyCaps = //DDCKEYCAPS_BOTHBLT | // Supports transparent blitting with for both source and destination surfaces. //DDCKEYCAPS_DESTBLT | // Supports transparent blitting with a color key that identifies the replaceable bits of the destination surface for RGB colors. //DDCKEYCAPS_DESTBLTCLRSPACE | // Supports transparent blitting with a color space that identifies the replaceable bits of the destination surface for RGB colors. //DDCKEYCAPS_DESTBLTCLRSPACEYUv | // Supports transparent blitting with a color space that identifies the replaceable bits of the destination surface for YUV colors. //DDCKEYCAPS_SRCBLT | // Supports transparent blitting using the color key for the source with this surface for RGB colors. //DDCKEYCAPS_SRCBLTCLRSPACE | // Supports transparent blitting using a color space for the source with this surface for RGB colors. //DDCKEYCAPS_SRCBLTCLRSPACEYUV | // Supports transparent blitting using a color space for the source with this surface for YUV colors. 0; // Alpha blitting capabilities. lpddhi->ddHelCaps.dwAlphaCaps = //DDALPHACAPS_ALPHAPIXELS | // Supports per-pixel alpha values specified alongside with the RGB values in the pixel structure. //DDALPHACAPS_ALPHASURFACE | // Unsupported. //DDALPHACAPS_ALPHAPALETTE | // Unsupported. //DDALPHACAPS_ALPHACONSTANT | // Unsupported. //DDALPHACAPS_ARGBSCALE | // Unsupported. //DDALPHACAPS_SATURATE | // Unsupported. //DDALPHACAPS_PREMULT | // Supports pixel formats with premultiplied alpha values. //DDALPHACAPS_NONPREMULT | // Supports pixel formats with non-premultiplied alpha values. //DDALPHACAPS_ALPHAFILL | // Supports color-fill blitting using an alpha value. //DDALPHACAPS_ALPHANEG | // Supports inverted-alpha pixel formats, where 0 indicates fully opaque and 255 indicates fully transparent. 0; SETROPBIT(lpddhi->ddHelCaps.dwRops,SRCCOPY); // Set bits for ROPS supported SETROPBIT(lpddhi->ddHelCaps.dwRops,PATCOPY); SETROPBIT(lpddhi->ddHelCaps.dwRops,BLACKNESS); SETROPBIT(lpddhi->ddHelCaps.dwRops,WHITENESS); // General overlay capabilities. lpddhi->ddHelCaps.dwOverlayCaps = DDOVERLAYCAPS_FLIP | // Supports surface flipping with overlays. DDOVERLAYCAPS_FOURCC | // Supports FOURCC pixel formats with overlays. Use IDirectDraw::GetFourCCCodes to determine which FOURCC formats are supported. //DDOVERLAYCAPS_ZORDER | // Supports changing Z order of overlays. //DDOVERLAYCAPS_MIRRORLEFTRIGHT | // Supports surface mirroring in the left-to-right direction for overlays. //DDOVERLAYCAPS_MIRRORUPDOWN | // Supports surface mirroring in the up-to-down direction for overlays. DDOVERLAYCAPS_CKEYSRC | // Supports source color keying for overlays. DDOVERLAYCAPS_CKEYSRCCLRSPACE | // Supports source color-space keying for overlays. DDOVERLAYCAPS_CKEYSRCCLRSPACEYUV | // Supports source color-space keying for overlays with FOURCC pixel formats. DDOVERLAYCAPS_CKEYDEST | // Supports destination color keying for overlays. DDOVERLAYCAPS_CKEYDESTCLRSPACE | // Supports destination colo-space keying for overlays. DDOVERLAYCAPS_CKEYDESTCLRSPACEYUV | // Supports destination color-space keying for overlays with FOURCC pixel formats. //DDOVERLAYCAPS_CKEYBOTH | // Supports simultaneous source and destination color keying for overlays. //DDOVERLAYCAPS_ALPHADEST | // Supports destination alpha blending for overlays. DDOVERLAYCAPS_ALPHASRC | // Supports source alpha blending for overlays. //DDOVERLAYCAPS_ALPHADESTNEG | // Supports inverted destination alpha blending for overlays. //DDOVERLAYCAPS_ALPHASRCNEG | // Supports inverted source alpha blending for overlays. DDOVERLAYCAPS_ALPHACONSTANT | // Supports constant alpha blending for overlays (specified in the DDOVERLAYFX structure). //DDOVERLAYCAPS_ALPHAPREMULT | // Supports premultiplied alpha pixel formats for overlay alpha blending. //DDOVERLAYCAPS_ALPHANONPREMULT | // Supports non-premultiplied alpha pixel formats for overlay alpha blending. //DDOVERLAYCAPS_ALPHAANDKEYDEST | // Supports simultaneous source alpha blending with a destination color key for overlays. DDOVERLAYCAPS_OVERLAYSUPPORT | // Supports overlay surfaces. 0; lpddhi->ddHelCaps.dwMaxVisibleOverlays = 1; // Maximum number of visible overlays or overlay sprites. lpddhi->ddHelCaps.dwCurrVisibleOverlays = 0; // Current number of visible overlays or overlay sprites. lpddhi->ddHelCaps.dwAlignBoundarySrc = 4; // Source rectangle alignment, in pixels, for an overlay surface lpddhi->ddHelCaps.dwAlignSizeSrc = 4; // Source rectangle size alignment, in pixels, for an overlay surface. lpddhi->ddHelCaps.dwAlignBoundaryDest = 4; // Destination rectangle alignment, in pixels, for an overlay surface. lpddhi->ddHelCaps.dwAlignSizeDest = 4; // Destination rectangle size alignment, in pixels, for an overlay surface. lpddhi->ddHelCaps.dwMinOverlayStretch = 1000; // 1x 1000 lpddhi->ddHelCaps.dwMaxOverlayStretch = 1000; // 1x 1000 // Miscellaneous video capabilities. lpddhi->ddHelCaps.dwMiscCaps = DDMISCCAPS_READSCANLINE | // Supports reading the current scanline being drawn. //DDMISCCAPS_READMONITORFREQ | // Unsupported. DDMISCCAPS_READVBLANKSTATUS | // Supports reading the current V-Blank status of the hardware. //DDMISCCAPS_FLIPINTERVAL | // Supports interval flipping. //DDMISCCAPS_FLIPODDEVEN | // Supports Even/Odd flipping. DDMISCCAPS_FLIPVSYNCWITHVBI | // Supports V-Sync-coordinated flipping. //DDMISCCAPS_COLORCONTROLOVERLAY | // Supports color controls on overlay surfaces. //DDMISCCAPS_COLORCONTROLPRIMARY | // Supports color controls on primary surfaces. //DDMISCCAPS_GAMMACONTROLOVERLAY | // Supports gamma controls on overlay surfaces. //DDMISCCAPS_GAMMACONTROLPRIMARY | // Supports gamma controls on primary surfaces. 0; // Video port capabilities. lpddhi->ddHelCaps.dwMinVideoStretch = 1000; // minimum video port stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 lpddhi->ddHelCaps.dwMaxVideoStretch = 1000; // maximum video port stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 lpddhi->ddHelCaps.dwMaxVideoPorts = 0; // maximum number of usable video ports lpddhi->ddHelCaps.dwCurrVideoPorts = 0; // current number of video ports used #endif DDHAL_MSG((_T("[DDHAL] --buildDDHALInfo()\r\n"))); }
DWORD WINAPI HalCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA lpccsd) { DEBUGENTER( HalCanCreateSurface ); /* typedef struct _DDHAL_CANCREATESURFACEDATA { LPDDRAWI_DIRECTDRAW_GBL lpDD; LPDDSURFACEDESC lpDDSurfaceDesc; DWORD bIsDifferentPixelFormat; HRESULT ddRVal; } DDHAL_CANCREATESURFACEDATA; */ DDPIXELFORMAT *pddpf = &lpccsd->lpDDSurfaceDesc->ddpfPixelFormat; DWORD dwCaps = lpccsd->lpDDSurfaceDesc->ddsCaps.dwCaps; DWORD dwWidth = lpccsd->lpDDSurfaceDesc->dwWidth; DWORD dwHeight = lpccsd->lpDDSurfaceDesc->dwHeight; RETAILMSG(DISP_ZONE_TEMP, (_T("HalCanCreateSurface. dwCaps : 0x%x, dwWidth:%d, dwHeight:%d\n"), dwCaps, dwWidth, dwHeight)); S3C6410Disp *pDDGPE = (S3C6410Disp *)GetDDGPE(); // We do Not allow Primary Surface in System Memory if ((dwCaps & DDSCAPS_PRIMARYSURFACE) && (dwCaps & DDSCAPS_SYSTEMMEMORY)) { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalCanCreateSurface() : Can Not create Primary Surface in System Memory\n\r"))); goto CannotCreate; } if ((dwCaps & DDSCAPS_OVERLAY) && (dwCaps & DDSCAPS_SYSTEMMEMORY)) { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalCanCreateSurface() : Can Not create Overlay Surface in System Memory\n\r"))); goto CannotCreate; } if (dwCaps & DDSCAPS_PRIMARYSURFACE) { RETAILMSG(TRUE, (_T("DiffPixel:%d\n"), lpccsd->bIsDifferentPixelFormat)); if (lpccsd->bIsDifferentPixelFormat) { goto CannotCreate; } else { goto CanCreate; } } else if (dwCaps & DDSCAPS_OVERLAY) { EGPEFormat Format; EDDGPEPixelFormat PixelFormat; lpccsd->ddRVal = pDDGPE->DetectPixelFormat(dwCaps, pddpf, &Format, &PixelFormat); if (FAILED(lpccsd->ddRVal)) { goto CannotCreate; } else { RETAILMSG(TRUE, (_T("PixelFormat :%d\n"), PixelFormat)); switch(PixelFormat) { case ddgpePixelFormat_565: //case ddgpePixelFormat_8880: // FIMD can not support Packed RGB888 case ddgpePixelFormat_8888: case ddgpePixelFormat_I420: case ddgpePixelFormat_YV12: case ddgpePixelFormat_YUYV: case ddgpePixelFormat_YUY2: case ddgpePixelFormat_UYVY: case ddgpePixelFormat_YVYU: case ddgpePixelFormat_VYUY: goto CanCreate; break; default: goto CannotCreate; break; } } } else // Non Primary, Non Overlay Surface (Maybe Offscreen Surface) { return DDGPECanCreateSurface(lpccsd); } CanCreate: RETAILMSG(DISP_ZONE_ENTER,(_T("[DDHAL] HalCanCreateSurface() OK\n\r"))); lpccsd->ddRVal = DD_OK; return DDHAL_DRIVER_HANDLED; CannotCreate: RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalCanCreateSurface() : Unsupported Surface\n\r"))); lpccsd->ddRVal = DDERR_UNSUPPORTEDFORMAT; return DDHAL_DRIVER_HANDLED; }
DWORD WINAPI HalUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpuod) { DEBUGENTER( HalUpdateOverlay ); /* typedef struct _DDHAL_UPDATEOVERLAYDATA { LPDDRAWI_DIRECTDRAW_GBL lpDD; LPDDRAWI_DDRAWSURFACE_LCL lpDDDestSurface; RECT rDest; LPDDRAWI_DDRAWSURFACE_LCL lpDDSrcSurface; RECT rSrc; DWORD dwFlags; DDOVERLAYFX overlayFX; HRESULT ddRVal; } DDHAL_UPDATEOVERLAYDATA; */ S3C6410Disp *pDDGPE; S3C6410Surf *pSrcSurf; S3C6410Surf *pDestSurf; LPDDRAWI_DDRAWSURFACE_LCL lpSrcLCL; LPDDRAWI_DDRAWSURFACE_LCL lpDestLCL; BOOL bEnableOverlay = FALSE; /* 'Source' is the overlay surface, 'destination' is the surface to * be overlayed: */ lpSrcLCL = lpuod->lpDDSrcSurface; lpDestLCL = lpuod->lpDDDestSurface; pDDGPE = (S3C6410Disp *)GetDDGPE(); pSrcSurf = (S3C6410Surf *)DDGPESurf::GetDDGPESurf(lpSrcLCL); pDestSurf = (S3C6410Surf *)DDGPESurf::GetDDGPESurf(lpDestLCL); if (lpuod->dwFlags & DDOVER_HIDE) { // If overlay surface is valid, Turn off overlay if (pSrcSurf->OffsetInVideoMemory() != NULL) { if ( (pSrcSurf == pDDGPE->GetCurrentOverlaySurf()) || (pSrcSurf == pDDGPE->GetPreviousOverlaySurf()) ) { pDDGPE->OverlayDisable(); } lpuod->ddRVal = DD_OK; } else { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalUpdateOverlay() : pSrcSurf->OffsetInVideoMemory() = NULL\n\r"))); lpuod->ddRVal = DDERR_INVALIDPARAMS; } return (DDHAL_DRIVER_HANDLED); } else if (lpuod->dwFlags & DDOVER_SHOW) { if (pSrcSurf->OffsetInVideoMemory() != NULL) { if ( (pSrcSurf != pDDGPE->GetCurrentOverlaySurf()) && (pSrcSurf != pDDGPE->GetPreviousOverlaySurf()) && (pDDGPE->GetCurrentOverlaySurf() != NULL)) { // Some other overlay surface is already visible: RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalUpdateOverlay() : Overlay is already in use by another surface\n\r"))); lpuod->ddRVal = DDERR_OUTOFCAPS; return (DDHAL_DRIVER_HANDLED); } else { // Initialize Overlay if (pDDGPE->OverlayInitialize(pSrcSurf, &lpuod->rSrc, &lpuod->rDest) == FALSE) { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalUpdateOverlay() : OverlayInitialize() Failed\n\r"))); lpuod->ddRVal = DDERR_OUTOFCAPS; return (DDHAL_DRIVER_HANDLED); } // Enable Overlay below... after set up blending bEnableOverlay = TRUE; } } else { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalUpdateOverlay() : pSrcSurf->OffsetInVideoMemory() = NULL\n\r"))); lpuod->ddRVal = DDERR_INVALIDPARAMS; return (DDHAL_DRIVER_HANDLED); } } else { // If overlay surface is not visiable, Nothing to do lpuod->ddRVal = DD_OK; return (DDHAL_DRIVER_HANDLED); } if ((lpuod->dwFlags & (DDOVER_KEYSRC|DDOVER_KEYSRCOVERRIDE|DDOVER_KEYDEST|DDOVER_KEYDESTOVERRIDE)) && (lpuod->dwFlags & (DDOVER_ALPHASRC|DDOVER_ALPHACONSTOVERRIDE))) { RETAILMSG(DISP_ZONE_ERROR, (_T("[DDHAL:ERR] HalUpdateOverlay() : Driver Not Support ColorKey & Alpha at the same time (dwFlags = 0x%08x)\n\r"), lpuod->dwFlags)); } // Source Color Key if ((lpuod->dwFlags & (DDOVER_KEYSRCOVERRIDE | DDOVER_KEYSRC)) ||(lpSrcLCL->dwFlags & DDRAWISURF_HASCKEYSRCOVERLAY) ) { DWORD dwColorKey; if (lpuod->dwFlags & DDOVER_KEYSRCOVERRIDE) { dwColorKey = lpuod->overlayFX.dckSrcColorkey.dwColorSpaceLowValue; } else { dwColorKey = lpSrcLCL->ddckCKSrcOverlay.dwColorSpaceLowValue; } pDDGPE->OverlaySetColorKey(TRUE, pSrcSurf->PixelFormat(), dwColorKey); } // Destination Color Key else if ((lpuod->dwFlags & (DDOVER_KEYDESTOVERRIDE | DDOVER_KEYDEST)) ||(lpSrcLCL->dwFlags & DDRAWISURF_HASCKEYDESTOVERLAY) ) { DWORD dwColorKey; if (lpuod->dwFlags & DDOVER_KEYDESTOVERRIDE) { dwColorKey = lpuod->overlayFX.dckDestColorkey.dwColorSpaceLowValue; } else if(lpuod->dwFlags & DDOVER_KEYDEST) { dwColorKey = lpDestLCL->ddckCKDestOverlay.dwColorSpaceLowValue; } else { dwColorKey = lpSrcLCL->ddckCKDestOverlay.dwColorSpaceLowValue; } pDDGPE->OverlaySetColorKey(FALSE, pDestSurf->PixelFormat(), dwColorKey); } // Alpha Blending else if ((lpuod->dwFlags & DDOVER_ALPHASRC) || (lpuod->dwFlags & DDOVER_ALPHACONSTOVERRIDE)) { if (lpuod->dwFlags & DDOVER_ALPHACONSTOVERRIDE) // Per Plane Alpha Blending { pDDGPE->OverlaySetAlpha(FALSE, lpuod->overlayFX.dwAlphaConst); } else { pDDGPE->OverlaySetAlpha(TRUE, lpuod->overlayFX.dwAlphaConst); } } // No Blending Effect else { pDDGPE->OverlayBlendDisable(); } // Enable Overlay after set up blending if (bEnableOverlay) pDDGPE->OverlayEnable(); lpuod->ddRVal = DD_OK; return (DDHAL_DRIVER_HANDLED); }