Source code of Windows XP (NT5)
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.

572 lines
21 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: ddfactry.h
  6. * Content: DirectDraw factory class header
  7. * includes defns for CDDFactory, CDirectDrawEx,
  8. * and CDDSurface
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 24-feb-97 ralphl initial implementation
  13. * 25-feb-97 craige minor tweaks for dx checkin; integrated IBitmapSurface
  14. * stuff
  15. * 03-mar-97 craige added IRGBColorTable support
  16. * 06-mar-97 craige IDirectDrawSurface3 support
  17. * 14-mar-97 jeffort SetBits changed to reflect DX5 as SetSurfaceDesc
  18. * 01-apr-97 jeffort Following changes checked in:
  19. * D3D Interface support
  20. * Linked list of surfaces real/internal interfaces kept
  21. * Complex surface/Attach list handleing
  22. * Handle for palettes added
  23. * Add/GetAttachedSurface, Flip, and Blit are aggregated
  24. *
  25. * 04-apr-97 jeffort TRIDENT ifdef's removed.
  26. * IDirectDraw3 Class implementation
  27. * 09-apr-97 jeffort Added #defines for version and member function for OWNDC stuff
  28. * 28-apr-97 jeffort Palette wrapping added/DX5 support
  29. * 02-may-97 jeffort Removed commented code, added GetDDInterface function wrapping
  30. * 06-may-97 jeffort DeleteAttachedSurface wrapping added
  31. * 20-may-97 jeffort Added fields in surface object for NT4.0 gold
  32. * 02-jul-97 jeffort Added m_bSaveDC boolean if a DX5 surface with OWNDC set
  33. * we need to not NULL out the DC when ReleaseDC is called
  34. * so that a call to GetSurfaceFromDC will work
  35. * 07-jul-97 jeffort Added GetSurfaceDesc internal function for wrapping
  36. * 10-jul-97 jeffort Added m_hBMOld to store old bitmap handle to reset at destruction
  37. * 18-jul-97 jeffort Added D3D MMX Device support
  38. * 22-jul-97 jeffort Removed IBitmapSurface and associated interfaces
  39. * 02-aug-97 jeffort New structure added to surface object to store attached
  40. * surfaces created with a different ddrawex object
  41. * 20-feb-98 stevela Added Chrome rasterizers
  42. ***************************************************************************/
  43. #undef WIN32_LEAN_AND_MEAN
  44. #define WIN32_LEAN_AND_MEAN
  45. #include <windows.h>
  46. #include "crtfree.h"
  47. #include "ddraw.h"
  48. #include "d3d.h"
  49. #include "ddrawex.h"
  50. #include "ddraw3i.h"
  51. #include "comdll.h"
  52. #ifdef INITGUID
  53. #include <initguid.h>
  54. #endif
  55. /*
  56. * reminder
  57. */
  58. #define QUOTE(x) #x
  59. #define QQUOTE(y) QUOTE(y)
  60. #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) "):" str
  61. #ifndef ARRAYSIZE
  62. #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
  63. #endif
  64. class CDirectDrawEx;
  65. class CDDSurface;
  66. class CDDPalette;
  67. #ifndef CINTERFACE
  68. #define IDirectDrawVtbl void
  69. #define IDirectDraw2Vtbl void
  70. #define IDirectDraw4Vtbl void
  71. #define IDirectDrawSurfaceVtbl void
  72. #define IDirectDrawSurface2Vtbl void
  73. #define IDirectDrawSurface3Vtbl void
  74. #define IDirectDrawPaletteVtbl void
  75. #define IDirectDrawSurface4Vtbl void
  76. #endif
  77. #ifndef DIRECTDRAW_VERSION
  78. //these are not included in DX3 include files, define them here
  79. DEFINE_GUID( IID_IDirect3DRampDevice, 0xF2086B20,0x259F,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 );
  80. DEFINE_GUID( IID_IDirect3DRGBDevice, 0xA4665C60,0x2673,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 );
  81. DEFINE_GUID( IID_IDirect3DHALDevice, 0x84E63dE0,0x46AA,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E );
  82. DEFINE_GUID( IID_IDirect3DMMXDevice, 0x881949a1,0xd6f3,0x11d0,0x89,0xab,0x00,0xa0,0xc9,0x05,0x41,0x29 );
  83. DEFINE_GUID( IID_IDirect3DChrmDevice, 0x2f4d2045,0x9764,0x11d1,0x91,0xf2,0x0,0x0,0xf8,0x75,0x8e,0x66 );
  84. #endif
  85. #ifndef IID_IDirect3DChrmDevice
  86. DEFINE_GUID( IID_IDirect3DChrmDevice, 0x2f4d2045,0x9764,0x11d1,0x91,0xf2,0x0,0x0,0xf8,0x75,0x8e,0x66 );
  87. #endif
  88. #define SURFACE_DATAEXCHANGE 0x00000001
  89. //defines for our version information
  90. #define WIN95_DX2 0x00000001
  91. #define WIN95_DX3 0x00000002
  92. #define WIN95_DX5 0x00000003
  93. #define WINNT_DX2 0x00000004
  94. #define WINNT_DX3 0x00000005
  95. #define WINNT_DX5 0x00000006
  96. extern "C" {
  97. void WINAPI AcquireDDThreadLock(void);
  98. void WINAPI ReleaseDDThreadLock(void);
  99. };
  100. #define ENTER_DDEX() AcquireDDThreadLock();
  101. #define LEAVE_DDEX() ReleaseDDThreadLock();
  102. /*
  103. * ddraw's internal interface structure
  104. */
  105. typedef struct _REALDDINTSTRUC
  106. {
  107. void *lpVtbl;
  108. void *pDDInternal1;
  109. void *pDDInternal2;
  110. void *pDDInternal3;
  111. } REALDDINTSTRUC;
  112. /*
  113. * Our version of the IDirectDraw interface internal structure
  114. */
  115. typedef struct _DDINTSTRUC
  116. {
  117. IDirectDrawVtbl *lpVtbl;
  118. void *pDDInternal1;
  119. void *pDDInternal2;
  120. void *pDDInternal3;
  121. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  122. CDirectDrawEx *m_pDirectDrawEx;
  123. IDirectDraw *m_pRealInterface;
  124. } INTSTRUC_IDirectDraw;
  125. /*
  126. * Our version of the IDirectDraw2 interface internal structure
  127. */
  128. typedef struct _DD2INTSTRUC
  129. {
  130. IDirectDraw2Vtbl *lpVtbl;
  131. void *pDDInternal1;
  132. void *pDDInternal2;
  133. void *pDDInternal3;
  134. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  135. CDirectDrawEx *m_pDirectDrawEx;
  136. IDirectDraw2 *m_pRealInterface;
  137. } INTSTRUC_IDirectDraw2;
  138. typedef struct _DD4INTSTRUC
  139. {
  140. IDirectDraw4Vtbl *lpVtbl;
  141. void *pDDInternal1;
  142. void *pDDInternal2;
  143. void *pDDInternal3;
  144. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  145. CDirectDrawEx *m_pDirectDrawEx;
  146. IDirectDraw4 *m_pRealInterface;
  147. } INTSTRUC_IDirectDraw4;
  148. /*
  149. * Our version of the IDirectDrawSurface interface internal structure
  150. */
  151. typedef struct _DDSURFINTSTRUC
  152. {
  153. IDirectDrawSurfaceVtbl *lpVtbl;
  154. void *pDDInternal1;
  155. void *pDDInternal2;
  156. void *pDDInternal3;
  157. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  158. CDDSurface *m_pSimpleSurface;
  159. IDirectDrawSurface *m_pRealInterface;
  160. } INTSTRUC_IDirectDrawSurface;
  161. /*
  162. * Our version of the IDirectDrawSurface2 interface internal structure
  163. */
  164. typedef struct _DDSURF2INTSTRUC
  165. {
  166. IDirectDrawSurface2Vtbl *lpVtbl;
  167. void *pDDInternal1;
  168. void *pDDInternal2;
  169. void *pDDInternal3;
  170. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  171. CDDSurface *m_pSimpleSurface;
  172. IDirectDrawSurface2 *m_pRealInterface;
  173. } INTSTRUC_IDirectDrawSurface2;
  174. /*
  175. * Our version of the IDirectDrawSurface3 interface internal structure
  176. */
  177. typedef struct _DDSURF3INTSTRUC
  178. {
  179. IDirectDrawSurface3Vtbl *lpVtbl;
  180. void *pDDInternal1;
  181. void *pDDInternal2;
  182. void *pDDInternal3;
  183. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  184. CDDSurface *m_pSimpleSurface;
  185. IDirectDrawSurface3 *m_pRealInterface;
  186. } INTSTRUC_IDirectDrawSurface3;
  187. typedef struct _DDSURF4INTSTRUC
  188. {
  189. IDirectDrawSurface4Vtbl *lpVtbl;
  190. void *pDDInternal1;
  191. void *pDDInternal2;
  192. void *pDDInternal3;
  193. // ONLY ADD STUFF AFTER THESE 4 ENTRIES!!!
  194. CDDSurface *m_pSimpleSurface;
  195. IDirectDrawSurface4 *m_pRealInterface;
  196. } INTSTRUC_IDirectDrawSurface4;
  197. /*
  198. * Our version of IDirectDrawPalette interface internal structure
  199. */
  200. typedef struct _DDPALINTSTRUC
  201. {
  202. IDirectDrawPaletteVtbl *lpVtbl;
  203. void *pDDInternal1;
  204. void *pDDInternal2;
  205. void *pDDInternal3;
  206. CDDPalette *m_pSimplePalette;
  207. IDirectDrawPalette *m_pRealInterface;
  208. } INTSTRUC_IDirectDrawPalette;
  209. typedef struct tagDDAttachSurface
  210. {
  211. CDDSurface * pSurface;
  212. struct tagDDAttachSurface * pNext;
  213. }DDAttachSurface;
  214. /*
  215. * Non Delegating IUnknown interface
  216. */
  217. interface INonDelegatingUnknown
  218. {
  219. virtual STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv) = 0;
  220. virtual STDMETHODIMP_(ULONG) NonDelegatingAddRef(void) = 0;
  221. virtual STDMETHODIMP_(ULONG) NonDelegatingRelease(void) = 0;
  222. };
  223. #pragma warning (disable:4355)
  224. #define CAST_TO_IUNKNOWN(object) (reinterpret_cast<IUnknown *>(static_cast<INonDelegatingUnknown *>(object)))
  225. typedef HRESULT (WINAPI *LPDIRECTDRAWCREATE)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
  226. typedef HRESULT (WINAPI *LPDIRECTDRAWENUMW)( LPDDENUMCALLBACKW lpCallback, LPVOID lpContext );
  227. typedef HRESULT (WINAPI *LPDIRECTDRAWENUMA)( LPDDENUMCALLBACKA lpCallback, LPVOID lpContext );
  228. /*
  229. * DDFactor class definition
  230. */
  231. class CDDFactory : public INonDelegatingUnknown, public IDirectDrawFactory
  232. {
  233. public:
  234. // Non-Delegating versions of IUnknown
  235. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
  236. STDMETHODIMP_(ULONG) NonDelegatingAddRef(void);
  237. STDMETHODIMP_(ULONG) NonDelegatingRelease(void);
  238. // IUnknown
  239. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  240. STDMETHODIMP_(ULONG) AddRef(void);
  241. STDMETHODIMP_(ULONG) Release(void);
  242. // IDirectDrawFactory
  243. STDMETHODIMP CreateDirectDraw(GUID * pGUID, HWND hWnd, DWORD dwCoopLevelFlags, DWORD dwReserved, IUnknown *pUnkOuter, IDirectDraw **ppDirectDraw);
  244. STDMETHODIMP DirectDrawEnumerate(LPDDENUMCALLBACK lpCallback, LPVOID lpContext);
  245. CDDFactory(IUnknown *pUnkOuter);
  246. public:
  247. LONG m_cRef;
  248. IUnknown *m_pUnkOuter;
  249. HANDLE m_hDDrawDLL;
  250. DWORD m_dwDDVerMS;
  251. LPDIRECTDRAWCREATE m_pDirectDrawCreate;
  252. LPDIRECTDRAWENUMW m_pDirectDrawEnumerateW;
  253. LPDIRECTDRAWENUMA m_pDirectDrawEnumerateA;
  254. };
  255. /*
  256. * DirectDrawEx class definition
  257. */
  258. class CDirectDrawEx : public INonDelegatingUnknown, public IDirectDraw3
  259. {
  260. public:
  261. // Non-Delegating versions of IUnknown
  262. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
  263. STDMETHODIMP_(ULONG) NonDelegatingAddRef(void);
  264. STDMETHODIMP_(ULONG) NonDelegatingRelease(void);
  265. // IUnknown
  266. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  267. STDMETHODIMP_(ULONG) AddRef(void);
  268. STDMETHODIMP_(ULONG) Release(void);
  269. // IDirectDraw3
  270. STDMETHODIMP Compact();
  271. STDMETHODIMP CreateClipper(DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * );
  272. STDMETHODIMP DuplicateSurface(LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * );
  273. STDMETHODIMP EnumDisplayModes(DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK );
  274. STDMETHODIMP EnumSurfaces(DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK );
  275. STDMETHODIMP FlipToGDISurface();
  276. STDMETHODIMP GetCaps(LPDDCAPS, LPDDCAPS);
  277. STDMETHODIMP GetDisplayMode(LPDDSURFACEDESC);
  278. STDMETHODIMP GetFourCCCodes(LPDWORD, LPDWORD );
  279. STDMETHODIMP GetGDISurface(LPDIRECTDRAWSURFACE FAR *);
  280. STDMETHODIMP GetMonitorFrequency(LPDWORD);
  281. STDMETHODIMP GetScanLine(LPDWORD);
  282. STDMETHODIMP GetVerticalBlankStatus(LPBOOL );
  283. STDMETHODIMP Initialize(GUID FAR *);
  284. STDMETHODIMP RestoreDisplayMode();
  285. STDMETHODIMP SetDisplayMode(DWORD, DWORD,DWORD, DWORD, DWORD);
  286. STDMETHODIMP WaitForVerticalBlank(DWORD, HANDLE );
  287. STDMETHODIMP GetAvailableVidMem(LPDDSCAPS, LPDWORD, LPDWORD);
  288. STDMETHODIMP GetSurfaceFromDC(HDC, IDirectDrawSurface **);
  289. // Internal goop
  290. CDirectDrawEx(IUnknown *pUnkOuter);
  291. ~CDirectDrawEx();
  292. HRESULT Init(GUID * pGUID, HWND hWnd, DWORD dwCoopLevelFlags, DWORD dwReserved, LPDIRECTDRAWCREATE pDirectDrawCreate );
  293. STDMETHODIMP CreateSurface(LPDDSURFACEDESC pSurfaceDesc, IDirectDrawSurface **ppNewSurface, IUnknown *pUnkOuter);
  294. STDMETHODIMP CreateSurface(LPDDSURFACEDESC2 pSurfaceDesc, IDirectDrawSurface4 **ppNewSurface4, IUnknown *pUnkOuter);
  295. STDMETHODIMP CreatePalette(DWORD dwFlags, LPPALETTEENTRY pEntries, LPDIRECTDRAWPALETTE FAR * ppPal, IUnknown FAR * pUnkOuter);
  296. STDMETHODIMP SetCooperativeLevel(HWND hwnd, DWORD dwFlags);
  297. void AddSurfaceToList(CDDSurface *pSurface);
  298. void RemoveSurfaceFromList(CDDSurface *pSurface);
  299. void AddSurfaceToPrimaryList(CDDSurface *pSurface);
  300. void RemoveSurfaceFromPrimaryList(CDDSurface *pSurface);
  301. void AddPaletteToList(CDDPalette *pPalette);
  302. void RemovePaletteFromList(CDDPalette *pPalette);
  303. HRESULT HandleAttachList(LPDDSURFACEDESC pSurfaceDesc, IUnknown *pUnkOuter,IDirectDrawSurface **ppNewSurface, IDirectDrawSurface * pOrigSurf, DWORD dwFlags);
  304. HRESULT CreateSimpleSurface(LPDDSURFACEDESC pSurfaceDesc, IUnknown *pUnkOuter, IDirectDrawSurface * pSurface, IDirectDrawSurface **ppNewSurface, DWORD dwFlags);
  305. public:
  306. INTSTRUC_IDirectDraw m_DDInt;
  307. INTSTRUC_IDirectDraw2 m_DD2Int;
  308. INTSTRUC_IDirectDraw4 m_DD4Int;
  309. LONG m_cRef;
  310. IUnknown *m_pUnkOuter;
  311. CDDSurface *m_pFirstSurface; // list of surfaces (NOT ADDREF'd!)
  312. CDDSurface *m_pPrimaryPaletteList;
  313. CDDPalette *m_pFirstPalette;
  314. BOOL m_bExclusive;
  315. DWORD m_dwDDVer;
  316. };
  317. /*
  318. * DirectDraw simple surface class definition
  319. */
  320. class CDDSurface : public INonDelegatingUnknown
  321. {
  322. friend CDirectDrawEx;
  323. public:
  324. CDDSurface *m_pPrev; // Used by DirectDrawEx to insert in list
  325. CDDSurface *m_pNext;
  326. CDDSurface *m_pPrevPalette;
  327. CDDSurface *m_pNextPalette;
  328. CDDSurface *m_pDestroyList;
  329. CDDPalette *m_pCurrentPalette;
  330. IUnknown *m_pUnkOuter;
  331. //this member will be a linked list of explicitly attached surfaces
  332. //that were not created with the same ddrawex object that this surface
  333. //was created with
  334. DDAttachSurface *m_pAttach;
  335. LONG m_cRef;
  336. CDirectDrawEx *m_pDirectDrawEx;
  337. INTSTRUC_IDirectDrawSurface m_DDSInt;
  338. INTSTRUC_IDirectDrawSurface2 m_DDS2Int;
  339. INTSTRUC_IDirectDrawSurface3 m_DDS3Int;
  340. INTSTRUC_IDirectDrawSurface4 m_DDS4Int;
  341. IDirect3DDevice * m_D3DDeviceRAMPInt;
  342. IDirect3DDevice * m_D3DDeviceHALInt;
  343. IDirect3DDevice * m_D3DDeviceRGBInt;
  344. IDirect3DDevice * m_D3DDeviceChrmInt;
  345. IDirect3DDevice * m_D3DDeviceMMXInt;
  346. IDirect3DTexture * m_D3DTextureInt;
  347. HDC m_HDC;
  348. DWORD m_dwCaps;
  349. HDC m_hDCDib;
  350. HBITMAP m_hBMDib;
  351. HBITMAP m_hBMOld;
  352. LPVOID m_pBitsDib;
  353. IDirectDrawPalette *m_pDDPal;
  354. IDirectDrawPalette *m_pDDPalOurs;
  355. WORD m_dwPalSize;
  356. WORD m_dwPalEntries;
  357. BOOL m_bOwnDC; //boolean set if we are spoofing ddraw to support owndc
  358. BOOL m_bSaveDC;//boolean to store if DX5 and OWNDC set
  359. BOOL m_bPrimaryPalette;
  360. BOOL m_bIsPrimary;
  361. ULONG_PTR m_pSaveBits;
  362. DWORD m_pSaveHDC;
  363. #ifdef DEBUG
  364. DWORD m_DebugCheckDC;
  365. #endif
  366. DWORD m_pSaveHBM;
  367. public:
  368. CDDSurface( DDSURFACEDESC *pSurfaceDesc,
  369. IDirectDrawSurface *pDDSurface,
  370. IDirectDrawSurface2 *pDDSurface2,
  371. IDirectDrawSurface3 *pDDSurface3,
  372. IDirectDrawSurface4 *pDDSurface4,
  373. IUnknown *pUnkOuter, CDirectDrawEx *pDirectDrawEx);
  374. ~CDDSurface();
  375. HRESULT Init();
  376. HRESULT MakeDIBSection();
  377. HRESULT MakeDibInfo( LPDDSURFACEDESC pddsd, LPBITMAPINFO pbmi );
  378. HRESULT SupportOwnDC();
  379. static HRESULT CreateSimpleSurface(
  380. LPDDSURFACEDESC pSurfaceDesc,
  381. IDirectDrawSurface *pSurface,
  382. IDirectDrawSurface2 *pSurface2,
  383. IDirectDrawSurface3 *pSurface3,
  384. IDirectDrawSurface4 *pSurface4,
  385. IUnknown *pUnkOuter,
  386. CDirectDrawEx *pDirectDrawEx,
  387. IDirectDrawSurface **ppNewDDSurf,
  388. DWORD dwFlags);
  389. HRESULT InternalGetDC(HDC *);
  390. HRESULT InternalReleaseDC(HDC);
  391. HRESULT InternalLock(LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent);
  392. HRESULT InternalUnlock(LPVOID lpSurfaceData);
  393. HRESULT InternalSetSurfaceDesc(LPDDSURFACEDESC pddsd, DWORD dwFlags);
  394. HRESULT InternalGetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE FAR * lpDDS, DWORD dwSurfaceType);
  395. HRESULT InternalGetAttachedSurface4(LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE FAR * lpDDS);
  396. HRESULT InternalAddAttachedSurface(LPDIRECTDRAWSURFACE lpDDS, DWORD dwSurfaceType);
  397. HRESULT InternalDeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDS, DWORD dwSurfaceType);
  398. HRESULT InternalFlip(LPDIRECTDRAWSURFACE lpDDS, DWORD dw, DWORD dwSurfaceType);
  399. HRESULT InternalBlt(LPRECT lpRect1,LPDIRECTDRAWSURFACE lpDDS, LPRECT lpRect2,DWORD dw, LPDDBLTFX lpfx, DWORD dwSurfaceType);
  400. HRESULT InternalGetPalette(LPDIRECTDRAWPALETTE FAR * ppPal, DWORD dwSurfaceType);
  401. HRESULT InternalSetPalette(LPDIRECTDRAWPALETTE pPal, DWORD dwSurfaceType);
  402. HRESULT InternalGetDDInterface(LPVOID FAR * ppInt);
  403. HRESULT InternalGetSurfaceDesc(LPDDSURFACEDESC pDesc, DWORD dwSurfaceType);
  404. HRESULT InternalGetSurfaceDesc4(LPDDSURFACEDESC2 pDesc);
  405. HRESULT CheckDDPalette();
  406. void DeleteAttachment(IDirectDrawSurface * pOrigSurf, CDDSurface * pFirst);
  407. void CleanUpSurface();
  408. void ReleaseRealInterfaces();
  409. void AddSurfaceToDestroyList(CDDSurface *pSurface);
  410. void DeleteAttachNode(CDDSurface * Surface);
  411. // Non-Delegating versions of IUnknown
  412. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
  413. STDMETHODIMP_(ULONG) NonDelegatingAddRef(void);
  414. STDMETHODIMP_(ULONG) NonDelegatingRelease(void);
  415. // IUnknown
  416. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  417. STDMETHODIMP_(ULONG) AddRef(void);
  418. STDMETHODIMP_(ULONG) Release(void);
  419. };
  420. class CDDPalette : public INonDelegatingUnknown
  421. {
  422. friend CDirectDrawEx;
  423. friend CDDSurface;
  424. public:
  425. CDDPalette *m_pPrev; // Used by DirectDrawEx to insert in list
  426. CDDPalette *m_pNext;
  427. CDDSurface *m_pFirstSurface;
  428. IUnknown *m_pUnkOuter;
  429. INTSTRUC_IDirectDrawPalette m_DDPInt;
  430. LONG m_cRef;
  431. CDirectDrawEx *m_pDirectDrawEx;
  432. BOOL m_bIsPrimary;
  433. CDDPalette( IDirectDrawPalette * pDDPalette,IUnknown *pUnkOuter,CDirectDrawEx *pDirectDrawEx);
  434. ~CDDPalette();
  435. static HRESULT CreateSimplePalette(LPPALETTEENTRY pEntries,
  436. IDirectDrawPalette *pDDPalette,
  437. LPDIRECTDRAWPALETTE FAR * ppPal,
  438. IUnknown FAR * pUnkOuter,
  439. CDirectDrawEx *pDirectDrawEx);
  440. HRESULT SetColorTable (CDDSurface * pSurface, LPPALETTEENTRY pEntries, DWORD dwNumEntries, DWORD dwBase);
  441. void AddSurfaceToList(CDDSurface *pSurface);
  442. void RemoveSurfaceFromList(CDDSurface *pSurface);
  443. STDMETHODIMP InternalSetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpe);
  444. // Non-Delegating versions of IUnknown
  445. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
  446. STDMETHODIMP_(ULONG) NonDelegatingAddRef(void);
  447. STDMETHODIMP_(ULONG) NonDelegatingRelease(void);
  448. // IUnknown
  449. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  450. STDMETHODIMP_(ULONG) AddRef(void);
  451. STDMETHODIMP_(ULONG) Release(void);
  452. };
  453. /*
  454. * File name of the Direct3D DLL.
  455. */
  456. #define D3D_DLLNAME "D3DIM.DLL"
  457. /*
  458. * Entry points exported by the Direct3D DLL.
  459. */
  460. #define D3DCREATE_PROCNAME "Direct3DCreate"
  461. #define D3DCREATEDEVICE_PROCNAME "Direct3DCreateDevice"
  462. #define D3DCREATETEXTURE_PROCNAME "Direct3DCreateTexture"
  463. #ifdef USE_D3D_CSECT
  464. typedef HRESULT (WINAPI * D3DCreateProc)(LPUNKNOWN* lplpD3D,
  465. IUnknown* pUnkOuter);
  466. #else /* USE_D3D_CSECT */
  467. typedef HRESULT (WINAPI * D3DCreateProc)(LPCRITICAL_SECTION lpDDCSect,
  468. LPUNKNOWN* lplpD3D,
  469. IUnknown* pUnkOuter);
  470. #endif /* USE_D3D_CSECT */
  471. typedef HRESULT (WINAPI * D3DCreateTextProc)(REFIID riid,
  472. LPDIRECTDRAWSURFACE lpDDS,
  473. LPUNKNOWN* lplpD3DText,
  474. IUnknown* pUnkOuter);
  475. typedef HRESULT (WINAPI * D3DCreateDeviceProc)(REFIID riid,
  476. LPUNKNOWN lpDirect3D,
  477. LPDIRECTDRAWSURFACE lpDDS,
  478. LPUNKNOWN* lplpD3DDevice,
  479. IUnknown* pUnkOuter);
  480. /*
  481. * some helper functions...
  482. */
  483. void __stdcall InitDirectDrawInterfaces(IDirectDraw *pDD, INTSTRUC_IDirectDraw *pDDInt,
  484. IDirectDraw2 *pDD2, INTSTRUC_IDirectDraw2 *pDD2Int,
  485. IDirectDraw4 *pDD4, INTSTRUC_IDirectDraw4 *pDD4Int);
  486. void __stdcall InitSurfaceInterfaces(IDirectDrawSurface *pDDSurface,
  487. INTSTRUC_IDirectDrawSurface *pDDSInt,
  488. IDirectDrawSurface2 *pDDSurface2,
  489. INTSTRUC_IDirectDrawSurface2 *pDDS2Int,
  490. IDirectDrawSurface3 *pDDSurface3,
  491. INTSTRUC_IDirectDrawSurface3 *pDDS3Int,
  492. IDirectDrawSurface4 *pDDSurface4,
  493. INTSTRUC_IDirectDrawSurface4 *pDDS4Int );
  494. void __stdcall InitDirectDrawPaletteInterfaces(IDirectDrawPalette *pDDPalette,
  495. INTSTRUC_IDirectDrawPalette *pDDInt);