📄 display.h
字号:
// DDraw.h: interface for the CDDraw class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#if !defined(AFX_DDRAW_H__CCCD41E0_FDEC_11D4_9F47_0000E82A9254__INCLUDED_)
#define AFX_DDRAW_H__CCCD41E0_FDEC_11D4_9F47_0000E82A9254__INCLUDED_
#include <windows.h>
#include "videowindow.h"
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define PRIMARY_OK 1
#define PRIMARY_OVERLAY_OK 2
#define CLASS_FAILED 0
typedef struct {
BYTE * psrcbuf;
int buflength;
} SubRgnSrcBuf;
typedef struct {
int errloc; //error location
HRESULT err; //if err<0x80000000 ,it is self define errcode,else it is microsoft define
} ErrDispCode;
//some m_Err define
//1: call GetPixelFormat err
//2: this class can not be used
//3: input params error
//errloc define
#define FN_InitDDraw_LOC 1 //Self fun err
#define DD_GetCaps_LOC 2 //ddraw fun err
#define DD_CreateSurface_LOC 3
#define DD_QueryIDDrawSurface3_LOC 4
#define DD_Lock_LOC 5
#define DD_GetPixelFormat_LOC 6
#define DD_BltFast_LOC 7
#define DD_PageLock_LOC 8
#define DD_GetDC_LOC 9
#define CHECK_INPUT_PARAMS_LOC 10
#define CHECK_PARAMS_LOC 11
#define CheckSubRegion_LOC 12
#define CreateOverlay_LOC 13
#define CreateOverlay_Lock_LOC 14
#define CreateOverlay_CreateSurface1_LOC 15
#define CreateOverlay_CreateSurface2_LOC 16
#define CreateDispRegion_LOC 17
#define DD_UpdateOverlay_LOC 18
#define IsSupportOverlay_LOC 19
#define CreateMutex_LOC 20
#define WAIT_LOCK_OUTOFTIME_LOC 21
#define CHECK_LOCK_LOC 22
//some err define
//if err>0x80000000 please reference Microsoft DDraw error code define in DDRAW.H
//(use only the err low 16 bit (change HEX->DEC) find err define in ddraw.h)
#define NO_ERR 0
#define INPUT_HANDLE_ERR 1
#define INPUT_POINTER_ZERO_ERR 2
#define INVALIDE_RARAMS_ERR 3
#define SUBREGION_TOO_LARGE_ERR 4
#define SUBREGION_TOO_SMALL_ERR 5
#define POINTER_ZERO_ERR 6
#define DO_NOT_SUPPORT_OVERLAY_ERR 7
#define NOT_SUPPORT_ERR 8
#define CALL_WINAPI_ERR 9
#define REGION_TYPE_ERR 10
#define NORMAL_ERR 11
#define DO_NOT_SUPPORT_MUTIL_DISP_REGION_ERR 12
//#define 1: call GetPixelFormat err
//2: this class can not be used
//3: input params error
//WorkMode = HARD_WARE_TO_SCREEN OR SYSMEM_TO_SCREEN
//Region Type mask define
//0x8000:Main region ; 0:Sub Region
#define MASKMAINREIGON 0x8000
//0:HardWare do not DIRECT write; not 0:HardWare DIRECT write
#define MASKHWDIRECTWRITE 0x1
//0:PRIMARY; not 0: Overlay
#define MASKPRIMARYOVERLAY 0x2
#define MASKMODE 0x3
//user RgnType define :4 work mode ie Region type define
#define PRIMARY_NODIRECTW 0
#define PRIMARY_DIRECTW 1
#define OVERLAY_NODIRECTW 2
#define OVERLAY_DIRECTW 3
//The Region const
#define MINREGION_W 16
#define MINREGION_H 16
//define SUPPORT Direct Draw Pixel Format ID (PixelID)
//Default is 0
//yuv
#define YUY2_FOURCCDD 4
//24 bits RGB
#define RGB888DD 2
//16 bits RGB
#define RGB565DD 1
//16 bits RGB
#define RGB555DD 0
//32 bits RGB
#define RGB888A 3
#define DESCOLORKEY RGB(255, 0, 255)
#define OVERLAYCLRCOLOR RGB(2, 0, 2)
//CDDrawOverlay Mode define
#define SUPPORT_VID_B 5
#define SUPPORT_OVERLAYFULL_WIN 3
#define SUPPORT_OVERLAY_WIN 1
#define SUPPORT_PRIMARY_WIN 0
#define SUPPORT_SINGLE_MAIN_REGION 0x10 //default support mutil MAIN Region
typedef struct {
//General Caps
BOOL Blt;
BOOL BltStetch;
BOOL BltSys;
BOOL BltFOURCC;
//BOOL BltQueue;
//BOOL ColorKey;
//BOOL Clip;
//Overlay Caps
BOOL Overlay;
BOOL OverlayFOURCC;
BOOL OverlayStretch;
//SUPPORT Src color ksy
BOOL OverlaySrcColorKey;
//SUPPORT Des color ksy
BOOL OverlayDesColorKey;
DWORD dwNumFourCCCodes;
//BOOL OverlayClip;
//BOOL AutoFlipOverlay;
DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
DWORD dwMaxVisibleOverlays; // maximum number of visible overlays
DWORD dwCurrVisibleOverlays; // current number of visible overlays
DWORD dwAlignBoundarySrc;
DWORD dwAlignSizeSrc;
DWORD dwAlignBoundaryDest;
DWORD dwAlignSizeDest;
//BLT Caps
//system to video
BOOL SysToVidBlt;
//video to system
BOOL VidToSysBlt;
//BOOL Cap3D;
//DWORD dwVidMemTotal; // total amount of video memory
//DWORD dwVidMemFree; // amount of free video memory
} MyCaps;
typedef struct {
int displaydepth; //bits
int left;
int top;
int right;
int bottom;
} DISPLAYPARAM,* PDISPLAYPARAM;
#ifdef _USRDLL //define in VC6 project
class __declspec(dllexport) CDDrawOverlay
#else
class __declspec( dllimport) CDDrawOverlay
#endif
{
public:
CDDrawOverlay(int Mode=SUPPORT_VID_B
|SUPPORT_OVERLAYFULL_WIN);
virtual ~CDDrawOverlay();
//if call this fun return FALSE,then you can not use this Class
BOOL IsTheClassOK();
BOOL CanSafeExit();
//Get the last error.the error code is cleared,after return error code
//see this h file head "m_Err define"
BOOL GetErrCode(ErrDispCode * pErr);
//create disp Region in Primary or Overlay surface with default piex format (RGB16 or RGB24 or YUY2)
//the Region is the the client region of the window
//if success return Region HANDLE >0 ,else RETURN 0
HANDLE CreateDispRegion(HWND hDispWnd,UINT RgnType,int PixelId=-1);
BOOL DestoryDispRegion(HANDLE hRgn);
// call this function in MFC Windows OnMove fun
BOOL MoveDispRegion(HANDLE hRgn,int x,int y);
// call this function in MFC Windows OnSize fun
BOOL SizeDispRegion(HANDLE hRgn,int dx,int dy);
//get the main region handle from the hwnd ,return hRgn,if false hRgn is 0
HANDLE GetDispRegionHandle(HWND hDispWnd);
//create disp SubRegion inside the Region
//if success return one SubRegion HANDLE>0,if failed return 0
// the destination RECT must be inside the Region,the coordinate is relative to the Region
// the source RECT can equal destination RECT,or less the destination RECT (NODIRECTW type).
// for type DIRECTW Region they are must be equal.
HANDLE CreateDispSubRegion(HANDLE hRgn,RECT * pDRect=0);
BOOL DestoryDispSubRegion(HANDLE hSubRgn);
//Lock UNLock function used for NODIRECTW work mode
//when you use CopyDataToSubRegion fun then you must use lock,unlock fun
BOOL UnLockSubRegionVideoBuf(HANDLE hSRgn);
//if you call lock,then you must call unlock
BOOL LockSubRegionVideoBuf(HANDLE hSRgn,int WaitTime);
//only use for PRIMARY_NODIRECTW or OVERLAY_NODIRECTW Mode (ie copy pic from sysmem to vidomem)
BOOL CopyDataToSubRegion(HANDLE hSubRgn);
// Sizing one sub region to full screen,the mode must be overlay type,not primary
BOOL FullScreenOverlaySubRegion(HANDLE hSubRgn);
// Restore the sub region to normal size,the mode must be overlay type,not primary
BOOL UnFullScreenOverlaySubRegion(HANDLE hSubRgn);
BOOL ZoomScreenOverlaySubRegion(HANDLE hSubRgn,RECT * pZoomRange);
BOOL ZoomScreenOverlaySubRegion2(HANDLE hSubRgn,RECT * pZoomRange,RECT * pSRgnRect);
BOOL UnZoomScreenOverlaySubRegion(HANDLE hSubRgn);
// after call this fun you must alloc sysmem and set pSrc->psrc
BOOL GetSubRgnSrcBuf(HANDLE hSubRgn,SubRgnSrcBuf * pSrc);
//before call this fun pSrc->psrc must be a valid dma sysmem (not 0)
BOOL SetSubRgnSrcBuf(HANDLE hSubRgn,SubRgnSrcBuf * pSrc);
//Fill main or sub region to some colour
BOOL ClearRegion(HANDLE hRgn,COLORREF rgb=0);
//the hRgn is main or sub region handle
//Get the main region RECT,the coordinate of Region RECT is screen coordinate;
//Get the Sub region RECT,the coordinate of SubRegion RECT is relative to Region RECT left,top point
BOOL GetDispRegion(HANDLE hRgn,RECT * pct);
//attach the S1000 Video main channel to this sub region
BOOL GetDispSubRegionVideoWindow(HANDLE hSubRgn,VIDEOWINDOW * pHWVidWind,BOOL VideoIsPAL);
//attach the S1000 Video sub channel to this sub region
BOOL GetDispSubRegionSubVideoWindow(HANDLE hSubRgn,SVIDEOWINDOW * pSVidWin,BOOL VideoIsPAL);
int GetCurrentRGBPixelID();
//get the display driver caps
BOOL GetCaps(MyCaps * pMyHWCaps,MyCaps * pMyHELCaps);
//Is the display driver support overlay?
BOOL IsSupportOverlay();
//get current overlay dest colour key
COLORREF GetOverlayDestColorKey();
//you can change default overlay dest colour key (DESCOLORKEY def in this h file).
BOOL SetOverlayDestColorKey(COLORREF rgb);
BOOL ClearFullScreen(COLORREF rgb);
private:
BOOL m_FirstObj;
//BOOL m_SupportRegionB;
//BOOL ClearSubRegion(void * hSRgn,COLORREF rgb);
int GetMatchRatioMode(int VideoMode,int width,int height,int * rwdith,int * rheight);
BOOL ConvertVidWinToSubVidWin(VIDEOWINDOW * pVidWin ,SVIDEOWINDOW * pSVidWin);
BOOL DisplayOverlay(void * hSubRgn,RECT * pRect=NULL);
BOOL DisplayOverlay2(void * hSubRgn,RECT * pRect=NULL,RECT * pSubRgnRect=NULL);
friend int ReSetSurfaceParams(CDDrawOverlay * pthis);
int m_PrimaryPixelID;
//int m_OverlayPixelID;
//DWORD m_ScreenW;
//DWORD m_ScreenH;
BOOL SizeOneSubRegion(void * pSRgn,double xc, double yc);
void MoveOneSubRegion(void * pSubRgn);
BOOL DestoryAllSubDispRegion(void * pmlist);
BOOL DestoryDispSubRegionI(void * p);
BOOL ProcessSubRegion(void * p,RECT * pDRect);
int CreateOverlay(int w,int h,int PixelId);
void DestoryOverlay();
BOOL CheckSubRegion(void * p,RECT * pSubRect);
//BOOL CheckSubRegion(void * p,RECT * pDRect, RECT * pSRect);
BOOL DestoryAllRegions();
BOOL CheckFourCCPixel(int PixelId);
BOOL CheckRGBPixel(int PixelId);
int GetRGBPixelID(int PixelID);
BOOL GetScreenDispParams();
BOOL GetCaps();
HRESULT InitDDraw();
void DestoryDDraw();
BOOL CreatePrimary(BOOL IsSupportFlip=FALSE);
void DestoryPrimary();
void * CreateSurface(int Mode, DWORD w, DWORD h );
void DestorySurface(void * pSurf);
void OutPutCaps();
MyCaps m_MyHWCaps;
MyCaps m_MyHELCaps;
DISPLAYPARAM m_display;
// UINT m_PrimarySufBase;
// UINT m_PrimaryPitch;
ErrDispCode m_Err;
int m_OK;
};
#endif // !defined(AFX_DDRAW_H__CCCD41E0_FDEC_11D4_9F47_0000E82A9254__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -