Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
4.6 KiB

  1. #define DECLARE_MEMCLEAR_NEW_DELETE \
  2. void * __cdecl operator new(size_t cb) { void *pv = malloc(cb); if (pv) ZeroMemory(pv, cb); return pv; } \
  3. void __cdecl operator delete(void * pv) { free(pv); }
  4. class CVoid
  5. {
  6. };
  7. class CBaseFT : public CVoid
  8. {
  9. public:
  10. DECLARE_MEMCLEAR_NEW_DELETE
  11. ULONG AddRef() { return((ULONG)InterlockedIncrement((LONG *)&_ulRefs)); }
  12. ULONG Release();
  13. ULONG SubAddRef() { return((ULONG)InterlockedIncrement((LONG *)&_ulAllRefs)); }
  14. ULONG SubRelease();
  15. CRITICAL_SECTION * GetPcs() { return(_pcs); }
  16. void SetPcs(CRITICAL_SECTION *pcs) { _pcs = pcs; }
  17. ULONG GetRefs() { return(_ulRefs); }
  18. ULONG GetAllRefs() { return(_ulAllRefs); }
  19. void EnterCriticalSection() { if (_pcs) ::EnterCriticalSection(_pcs); }
  20. void LeaveCriticalSection() { if (_pcs) ::LeaveCriticalSection(_pcs); }
  21. protected:
  22. CBaseFT(CRITICAL_SECTION * pcs = NULL);
  23. virtual ~CBaseFT();
  24. virtual void Passivate();
  25. ULONG InterlockedRelease() { return((ULONG)InterlockedDecrement((LONG *)&_ulRefs)); }
  26. private:
  27. CRITICAL_SECTION * _pcs;
  28. ULONG _ulRefs;
  29. ULONG _ulAllRefs;
  30. };
  31. class CDDrawWrapper : public CBaseFT, public IDirectDrawSurface, public IDirectDrawPalette
  32. {
  33. typedef CBaseFT super;
  34. public:
  35. CDDrawWrapper(HBITMAP hbmDib);
  36. ~CDDrawWrapper();
  37. ULONG STDMETHODCALLTYPE AddRef();
  38. ULONG STDMETHODCALLTYPE Release();
  39. STDMETHOD(QueryInterface)(REFIID iid, void** ppInterface);
  40. // IDirectDrawSurface
  41. STDMETHOD(AddAttachedSurface)(LPDIRECTDRAWSURFACE lpdds);
  42. STDMETHOD(AddOverlayDirtyRect)(LPRECT lprc);
  43. STDMETHOD(Blt)(LPRECT lprcDest, LPDIRECTDRAWSURFACE lpdds, LPRECT lprcSrc, DWORD dw, LPDDBLTFX lpfx);
  44. STDMETHOD(BltBatch)(LPDDBLTBATCH lpBlt, DWORD dwCount, DWORD dwFlags);
  45. STDMETHOD(BltFast)(DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE lpdds, LPRECT lprcSrc, DWORD dwTrans);
  46. STDMETHOD(DeleteAttachedSurface)(DWORD dwFlags, LPDIRECTDRAWSURFACE lpdds);
  47. STDMETHOD(EnumAttachedSurfaces)(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfn);
  48. STDMETHOD(EnumOverlayZOrders)(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfn);
  49. STDMETHOD(Flip)(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags);
  50. STDMETHOD(GetAttachedSurface)(LPDDSCAPS lpCaps, LPDIRECTDRAWSURFACE FAR * lpdds);
  51. STDMETHOD(GetBltStatus)(DWORD dw);
  52. STDMETHOD(GetCaps)(LPDDSCAPS lpCaps);
  53. STDMETHOD(GetClipper)(LPDIRECTDRAWCLIPPER FAR* lpClipper);
  54. STDMETHOD(GetColorKey)(DWORD dw, LPDDCOLORKEY lpKey);
  55. STDMETHOD(GetDC)(HDC FAR * lphdc);
  56. STDMETHOD(GetFlipStatus)(DWORD dw);
  57. STDMETHOD(GetOverlayPosition)(LPLONG lpl1, LPLONG lpl2);
  58. STDMETHOD(GetPalette)(LPDIRECTDRAWPALETTE FAR* ppPal);
  59. STDMETHOD(GetPixelFormat)(LPDDPIXELFORMAT pPixelFormat);
  60. STDMETHOD(GetSurfaceDesc)(LPDDSURFACEDESC pSurfaceDesc);
  61. STDMETHOD(Initialize)(LPDIRECTDRAW pDD, LPDDSURFACEDESC pSurfaceDesc);
  62. STDMETHOD(IsLost)();
  63. STDMETHOD(Lock)(LPRECT pRect, LPDDSURFACEDESC pSurfaceDesc, DWORD dwFlags, HANDLE hEvent);
  64. STDMETHOD(ReleaseDC)(HDC hdc);
  65. STDMETHOD(Restore)();
  66. STDMETHOD(SetClipper)(LPDIRECTDRAWCLIPPER pClipper);
  67. STDMETHOD(SetColorKey)(DWORD dwFlags, LPDDCOLORKEY pDDColorKey);
  68. STDMETHOD(SetOverlayPosition)(LONG x, LONG y);
  69. STDMETHOD(SetPalette)(LPDIRECTDRAWPALETTE pDDPal);
  70. STDMETHOD(Unlock)(LPVOID pBits);
  71. STDMETHOD(UpdateOverlay)(LPRECT prc, LPDIRECTDRAWSURFACE pdds, LPRECT prc2, DWORD dw, LPDDOVERLAYFX pfx);
  72. STDMETHOD(UpdateOverlayDisplay)(DWORD dw);
  73. STDMETHOD(UpdateOverlayZOrder)(DWORD dw, LPDIRECTDRAWSURFACE pdds);
  74. // IDirectDrawPalette
  75. STDMETHOD(SetEntries)(DWORD dwFlags, DWORD dwStart, DWORD dwCount, LPPALETTEENTRY pEntries);
  76. STDMETHOD(GetCaps)(LPDWORD lpdw);
  77. STDMETHOD(GetEntries)(DWORD dwFlags, DWORD dwStart, DWORD dwCount, LPPALETTEENTRY pEntries);
  78. STDMETHOD(Initialize)(LPDIRECTDRAW lpdd, DWORD dwCount, LPPALETTEENTRY pEntries);
  79. protected:
  80. HBITMAP m_hbmDib;
  81. DIBSECTION m_dsSurface;
  82. DDCOLORKEY m_ddColorKey;
  83. LONG m_lPitch;
  84. RECT m_rcSurface;
  85. BYTE * m_pbBits;
  86. };
  87. HBITMAP ImgCreateDib(LONG xWid, LONG yHei, BOOL fPal, int cBitsPerPix,
  88. int cEnt, PALETTEENTRY * ppe, BYTE ** ppbBits, int * pcbRow);
  89. HBITMAP ImgCreateDibFromInfo(BITMAPINFO * pbmi, UINT wUsage, BYTE ** ppbBits, int * pcbRow);