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.

1363 lines
54 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: ddraw.hxx
  3. *
  4. * DirectDraw extended objects.
  5. *
  6. * Created: 3-Dec-1995
  7. * Author: J. Andrew Goossen [andrewgo]
  8. *
  9. * Copyright (c) 1995-1999 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. #ifndef GDIFLAGS_ONLY // used for gdikdx
  13. // Handy forward declarations:
  14. class EDD_SURFACE;
  15. class EDD_VIDEOPORT;
  16. class EDD_DIRECTDRAW_LOCAL;
  17. class EDD_DIRECTDRAW_GLOBAL;
  18. class EDD_DXDIRECTDRAW;
  19. class EDD_DXVIDEOPORT;
  20. class EDD_DXSURFACE;
  21. class EDD_DXCAPTURE;
  22. class EDD_MOTIONCOMP;
  23. class EDD_VMEMMAPPING;
  24. class DXOBJ;
  25. #endif // GDIFLAGS_ONLY
  26. #ifdef DXKERNEL_BUILD
  27. extern PVOID gpDummyPage;
  28. extern LONG gcDummyPageRefCnt;
  29. extern HSEMAPHORE ghsemDummyPage;
  30. // Ease the pain of probes:
  31. inline
  32. VOID
  33. ProbeAndWriteRVal(
  34. HRESULT* pRVal,
  35. HRESULT RVal
  36. )
  37. {
  38. ProbeAndWriteStructure(pRVal, RVal, HRESULT);
  39. }
  40. // Reasonable bounds for any drawing calls, to ensure that drivers won't
  41. // overflow their math if given bad data:
  42. #define DD_MAXIMUM_COORDINATE (0x8000)
  43. #define DD_MINIMUM_COORDINATE -(0x8000)
  44. // Function exports to handle enabling and disabling DirectDraw when
  45. // the driver is loaded or unloaded.
  46. BOOL bDdEnableDirectDraw(
  47. HDEV hdev
  48. );
  49. VOID vDdDisableDirectDraw(
  50. HDEV hdev
  51. );
  52. // Generic QueryInterface IO request function:
  53. BOOL
  54. bDdIoQueryInterface(
  55. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal,
  56. const GUID* pguid,
  57. DWORD cjInterface,
  58. DWORD dwDesiredVersion,
  59. INTERFACE* pInterface
  60. );
  61. // Function exports to be called from the handle manager cleanup code:
  62. BOOL
  63. bDdDeleteDirectDrawObject(
  64. HANDLE hDirectDrawLocal,
  65. BOOL bProcessTermination
  66. );
  67. BOOL
  68. bDdDeleteSurfaceObject(
  69. HANDLE hSurface,
  70. DWORD* pdwRet
  71. );
  72. BOOL
  73. bDdDeleteVideoPortObject(
  74. HANDLE hVideoPort,
  75. DWORD* pdwRet
  76. );
  77. BOOL
  78. bDdReleaseDC(
  79. EDD_SURFACE* peSurface,
  80. BOOL bForce
  81. );
  82. BOOL
  83. bDdDeleteMotionCompObject(
  84. HANDLE hMotionComp,
  85. DWORD* pdwRet
  86. );
  87. // Private support functions exported from WIN32K.SYS for DXAPI.SYS.
  88. #define DXAPI_PRIVATE_VERSION_NUMBER 0x1001
  89. extern "C"
  90. VOID
  91. APIENTRY
  92. DdDxApiOpenDirectDraw(
  93. DDOPENDIRECTDRAWIN* pOpenDirectDrawIn,
  94. DDOPENDIRECTDRAWOUT* pOpenDirectDrawOut,
  95. PKDEFERRED_ROUTINE pfnEventDpc,
  96. ULONG VersionNumber
  97. );
  98. extern "C"
  99. VOID
  100. APIENTRY
  101. DdDxApiOpenVideoPort(
  102. DDOPENVIDEOPORTIN* pOpenVideoPortIn,
  103. DDOPENVIDEOPORTOUT* pOpenVideoPortOut
  104. );
  105. extern "C"
  106. VOID
  107. APIENTRY
  108. DdDxApiOpenSurface(
  109. DDOPENSURFACEIN* pOpenSurfaceIn,
  110. DDOPENSURFACEOUT* pOpenSurfaceOut
  111. );
  112. extern "C"
  113. VOID
  114. APIENTRY
  115. DdDxApiCloseHandle(
  116. DDCLOSEHANDLE* pCloseHandle,
  117. DWORD* pdwRet
  118. );
  119. extern "C"
  120. VOID
  121. APIENTRY
  122. DdDxApiOpenCaptureDevice(
  123. DDOPENVPCAPTUREDEVICEIN* pOpenCaptureDeviceIn,
  124. DDOPENVPCAPTUREDEVICEOUT* pOpenCaptureDeviceOut
  125. );
  126. extern "C"
  127. VOID
  128. APIENTRY
  129. DdDxApiGetKernelCaps(
  130. HANDLE hDirectDraw,
  131. DDGETKERNELCAPSOUT* pGetKernelCaps
  132. );
  133. extern "C"
  134. VOID
  135. APIENTRY
  136. DdDxApiLockDevice(
  137. HDEV hdev
  138. );
  139. extern "C"
  140. VOID
  141. APIENTRY
  142. DdDxApiUnlockDevice(
  143. HDEV hdev
  144. );
  145. // Function exports for handling DXAPI non-paged allocations:
  146. VOID
  147. vDdSynchronizeVideoPort(
  148. EDD_VIDEOPORT* peVideoPort
  149. );
  150. VOID
  151. vDdSynchronizeSurface(
  152. EDD_SURFACE* peSurface
  153. );
  154. VOID
  155. vDdStopVideoPort(
  156. EDD_VIDEOPORT* peVideoPort
  157. );
  158. VOID
  159. vDdQueryMiniportDxApiSupport(
  160. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal
  161. );
  162. HANDLE
  163. hDdOpenDxApiSurface(
  164. EDD_SURFACE* peSurface
  165. );
  166. VOID
  167. vDdCloseDxApiSurface(
  168. EDD_SURFACE* peSurface
  169. );
  170. BOOL
  171. bDdLoadDxApi(
  172. EDD_DIRECTDRAW_LOCAL* peDirectDrawLocal
  173. );
  174. VOID
  175. vDdUnloadDxApi(
  176. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal
  177. );
  178. VOID
  179. vDdUnloadDxApiImage(
  180. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal
  181. );
  182. VOID
  183. vDdLoseDxObjects(
  184. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal,
  185. DXOBJ* pDxObj,
  186. PVOID pDxThing,
  187. DWORD dwType
  188. );
  189. VOID
  190. vDdDxApiFreeSurface(
  191. DXOBJ* pDxObj,
  192. BOOL bDoCallBack
  193. );
  194. // Handle dynamic mode changes for DirectDraw:
  195. VOID
  196. vDdDynamicModeChange(
  197. HDEV hdevOld,
  198. HDEV hdevNew
  199. );
  200. VOID
  201. vDdNotifyEvent(
  202. EDD_DIRECTDRAW_GLOBAL* peDirectDraw,
  203. DWORD dwEvent
  204. );
  205. #endif // DXKERNEL_BUILD
  206. #ifndef GDIFLAGS_ONLY // used for gdikdx
  207. typedef
  208. VOID
  209. (APIENTRY *PFNAUTOFLIPUPDATE)(
  210. EDD_DXVIDEOPORT* peDxVideoPort,
  211. EDD_DXSURFACE** apeDxSurfaceVideo,
  212. ULONG cSurfacesVideo,
  213. EDD_DXSURFACE** apeDxSurfaceVbi,
  214. ULONG cSurfacesVbi
  215. );
  216. typedef enum {
  217. LO_DIRECTDRAW,
  218. LO_VIDEOPORT,
  219. LO_SURFACE,
  220. LO_CAPTURE
  221. } LOTYPE;
  222. typedef
  223. void
  224. (APIENTRY *PFNLOSEOBJECT)(
  225. VOID* pvObject,
  226. LOTYPE loType
  227. );
  228. typedef
  229. void
  230. (APIENTRY *PFNENABLEIRQ)(
  231. EDD_DXVIDEOPORT* peDxVideoPort,
  232. BOOL bEnable
  233. );
  234. typedef
  235. void
  236. (APIENTRY *PFNUPDATECAPTURE)(
  237. EDD_DXVIDEOPORT* peDxVideoPort,
  238. EDD_DXCAPTURE* peDxCapture,
  239. BOOL bDelete
  240. );
  241. typedef
  242. VOID
  243. (APIENTRY *PFNDXAPIOPENDIRECTDRAW)(
  244. DDOPENDIRECTDRAWIN* pOpenDirectDrawIn,
  245. DDOPENDIRECTDRAWOUT* pOpenDirectDrawOut,
  246. PKDEFERRED_ROUTINE pfnEventDpc,
  247. ULONG DxApiPrivateVersionNumber
  248. );
  249. typedef
  250. VOID
  251. (APIENTRY *PFNDXAPIOPENVIDEOPORT)(
  252. DDOPENVIDEOPORTIN* pOpenVideoPortIn,
  253. DDOPENVIDEOPORTOUT* pOpenVideoPortOut
  254. );
  255. typedef
  256. VOID
  257. (APIENTRY *PFNDXAPIOPENSURFACE)(
  258. DDOPENSURFACEIN* pOpenSurfaceIn,
  259. DDOPENSURFACEOUT* pOpenSurfaceOut
  260. );
  261. typedef
  262. VOID
  263. (APIENTRY *PFNDXAPICLOSEHANDLE)(
  264. DDCLOSEHANDLE* pCloseHandle,
  265. DWORD* pdwRet
  266. );
  267. typedef
  268. VOID
  269. (APIENTRY *PFNDXAPIGETKERNELCAPS)(
  270. HANDLE hDirectDraw,
  271. DDGETKERNELCAPSOUT* pdwRet
  272. );
  273. typedef
  274. VOID
  275. (APIENTRY *PFNDXAPIOPENCAPTUREDEVICE)(
  276. DDOPENVPCAPTUREDEVICEIN* pOpenCaptureDeviceIn,
  277. DDOPENVPCAPTUREDEVICEOUT* pOpenCaptureDeviceOut
  278. );
  279. typedef
  280. VOID
  281. (APIENTRY *PFNDXAPILOCKDEVICE)(
  282. HDEV hdev
  283. );
  284. typedef
  285. VOID
  286. (APIENTRY *PFNDXAPIUNLOCKDEVICE)(
  287. HDEV hdev
  288. );
  289. typedef
  290. VOID
  291. (APIENTRY *PFNDXAPIINITIALIZE)(
  292. PFNDXAPIOPENDIRECTDRAW pfnOpenDirectDraw,
  293. PFNDXAPIOPENVIDEOPORT pfnOpenVideoPort,
  294. PFNDXAPIOPENSURFACE pfnOpenSurface,
  295. PFNDXAPICLOSEHANDLE pfnCloseHandle,
  296. PFNDXAPIGETKERNELCAPS pfnGetKernelCaps,
  297. PFNDXAPIOPENCAPTUREDEVICE pfnOpenCaptureDevice,
  298. PFNDXAPILOCKDEVICE pfnLockDevice,
  299. PFNDXAPIUNLOCKDEVICE pfnUnlockDevice
  300. );
  301. #endif
  302. ////////////////////////////////////////////////////////////////////////////
  303. // The following 'extended' (hence the 'E') classes contain all the private
  304. // GDI information associated with the public objects that we don't want
  305. // the DirectDraw drivers to see.
  306. /*********************************Class************************************\
  307. * class DD_DIRECTDRAW_GLOBAL_DRIVER_DATA
  308. *
  309. * Contains all the DirectDraw mode-specific driver data. This entire
  310. * structure is preserved, along with the driver instance, on a mode
  311. * change (until such time as all D3D, WNDOBJ, and DRIVEROBJ objects
  312. * referencing that mode are deleted).
  313. *
  314. \**************************************************************************/
  315. #define DD_DRIVER_FLAG_EMULATE_SYSTEM_TO_VIDEO 0x0001
  316. // Set if kernel-mode is emulating system-memory to
  317. // video-memory calls
  318. #define DD_DRIVERINFO_MISCELLANEOUS 0x0001
  319. #define DD_DRIVERINFO_VIDEOPORT 0x0002
  320. #define DD_DRIVERINFO_COLORCONTROL 0x0004
  321. #define DD_DRIVERINFO_D3DCALLBACKS2 0x0008
  322. #define DD_DRIVERINFO_MOTIONCOMP 0x0040
  323. #define DD_DRIVERINFO_MISCELLANEOUS2 0x0080
  324. #define DD_DRIVERINFO_MORECAPS 0x0100
  325. #define DD_DRIVERINFO_D3DCALLBACKS3 0x0200
  326. #define DD_DRIVERINFO_NT 0x0400
  327. #define DD_DRIVERINFO_PRIVATECAPS 0x0800
  328. #define DD_DRIVERINFO_MORESURFACECAPS 0x1000
  329. #ifndef GDIFLAGS_ONLY // used for gdikdx
  330. class DD_DIRECTDRAW_GLOBAL_DRIVER_DATA
  331. {
  332. public:
  333. LONG cDriverReferences; // References to driver instance
  334. FLONG flDriver; // DD_DRIVER_FLAGs
  335. FLONG flDriverInfo; // DD_DRIVERINFO flags to indicate
  336. // what DriverInfo calls the driver
  337. // succeeded
  338. LONGLONG llAssertModeTimeout;// Duration for which we'll wait
  339. // for an application to give up
  340. // a lock before changing modes
  341. // (in 100 nanosecond units)
  342. DWORD dwNumHeaps; // Number of heaps
  343. VIDEOMEMORY* pvmList; // Pointer to list of heaps
  344. DWORD dwNumFourCC; // Number of FourCC codes
  345. DWORD* pdwFourCC; // Pointer to list of FourCC codes
  346. DD_HALINFO HalInfo; // Driver information
  347. // VPE capabilities:
  348. DXAPI_INTERFACE DxApiInterface; // Call-tables into miniport
  349. VOID* HwDeviceExtension; // Miniport's context
  350. AGP_INTERFACE AgpInterface; // AGP provider interface.
  351. DDKERNELCAPS DDKernelCaps;
  352. DD_MORECAPS MoreCaps;
  353. DD_NTPRIVATEDRIVERCAPS PrivateCaps;
  354. // DirectDraw entry points:
  355. DD_CALLBACKS CallBacks;
  356. DD_SURFACECALLBACKS SurfaceCallBacks;
  357. DD_PALETTECALLBACKS PaletteCallBacks;
  358. // DX3-style Direct3D driver information and entry points:
  359. D3DNTHAL_GLOBALDRIVERDATA D3dDriverData;
  360. D3DNTHAL_CALLBACKS D3dCallBacks;
  361. DD_D3DBUFCALLBACKS D3dBufCallbacks;
  362. // New DX5 entry points:
  363. D3DNTHAL_CALLBACKS2 D3dCallBacks2;
  364. // Other entry points:
  365. DD_VIDEOPORTCALLBACKS VideoPortCallBacks;
  366. DD_MISCELLANEOUSCALLBACKS MiscellaneousCallBacks;
  367. DD_MISCELLANEOUS2CALLBACKS Miscellaneous2CallBacks;
  368. DD_NTCALLBACKS NTCallBacks;
  369. DD_COLORCONTROLCALLBACKS ColorControlCallBacks;
  370. DD_KERNELCALLBACKS DxApiCallBacks;
  371. // New DX6 entry points:
  372. D3DNTHAL_CALLBACKS3 D3dCallBacks3;
  373. DD_MOTIONCOMPCALLBACKS MotionCompCallbacks;
  374. DD_MORESURFACECAPS MoreSurfaceCaps;
  375. };
  376. #endif // GDIFLAGS_ONLY used for gdikdx
  377. /*********************************Class************************************\
  378. * class DD_DIRECTDRAW_GLOBAL_PDEV_DATA
  379. *
  380. * Contains all the DirectDraw data that stays with PDEV after a mode
  381. * change.
  382. *
  383. \**************************************************************************/
  384. #define DD_GLOBAL_FLAG_DRIVER_ENABLED 0x0001
  385. // Driver's DirectDraw component is enabled
  386. #define DD_GLOBAL_FLAG_MODE_CHANGED 0x0002
  387. // Set if DirectDraw was disabled because the display
  388. // mode has changed
  389. #define DD_GLOBAL_FLAG_BOUNDS_SET 0x0004
  390. // Set after a blt to the primary surface
  391. #ifndef GDIFLAGS_ONLY // used for gdikdx
  392. // Structure used to defer the freeing of usermem until the surface using it
  393. // has been unlocked.
  394. typedef struct _DD_USERMEM_DEFER
  395. {
  396. PVOID pUserMem;
  397. EDD_SURFACE* peSurface;
  398. struct _DD_USERMEM_DEFER* pNext;
  399. } DD_USERMEM_DEFER;
  400. class DD_DIRECTDRAW_GLOBAL_PDEV_DATA
  401. {
  402. public:
  403. // Any fields in this section may be accessed only if the DEVLOCK is held:
  404. EDD_DIRECTDRAW_LOCAL* peDirectDrawLocalList;
  405. // Pointer to list of associated
  406. // DirectDraw local objects
  407. EDD_SURFACE* peSurface_PrimaryLockList;
  408. // List of primary surfaces that
  409. // have an active lock
  410. FLONG fl; // DD_GLOBAL_FLAGs
  411. ULONG cSurfaceLocks; // Number of surface locks currently
  412. // held
  413. PKEVENT pAssertModeEvent; // Wait event for a time-out on
  414. // waiting for everyone to give
  415. // up their surface locks
  416. EDD_SURFACE* peSurfaceCurrent; // Surface that's currently visible
  417. // as a result of a 'flip'
  418. EDD_SURFACE* peSurfacePrimary; // Primary surface that was flipped
  419. // away from
  420. BOOL bSuspended; // All DirectDraw HAL calls are
  421. // suspended (can be checked only
  422. // under the devlock). Note that
  423. // this does NOT necessarily mean
  424. // that the PDEV is disabled. It
  425. // also does not mean that system-
  426. // memory surfaces can't be used
  427. LONG cMaps; // Count of mappings of the frame
  428. // buffer
  429. ULONG cSurfaceAliasedLocks;// Number of aliased surface locks
  430. // currently held
  431. EDD_DXDIRECTDRAW* peDxDirectDraw; // Non-pageable part of the object,
  432. // allocated on demand for DXAPI
  433. // clients
  434. HANDLE hDirectDraw; // DXAPI instance handle, used for
  435. // VPE software autoflipping
  436. PFNAUTOFLIPUPDATE pfnAutoflipUpdate; // DXAPI.SYS routine for updating
  437. // the software autoflipping list
  438. PFNLOSEOBJECT pfnLoseObject; // DXAPI.SYS routine for marking
  439. // DXAPI objects as lost
  440. PFNENABLEIRQ pfnEnableIRQ; // DXAPI.SYS routine to enable/disable
  441. // video port VSYNC IRQs
  442. PFNUPDATECAPTURE pfnUpdateCapture; // DXAPI.SYS routine to add
  443. // capture objects to vports
  444. LPDXAPI pfnDxApi; // DXAPI.SYS entry point for all
  445. // its public APIs
  446. HANDLE hDxApi; // Module handle for dyna-loaded
  447. // DXAPI.SYS
  448. DWORD dwDxApiRefCnt; // Ref count for objects using DxApi
  449. DWORD dwDxApiExplicitLoads;// Prevents ring 3 from unloading
  450. // DXAPI.SYS if it didn't load it
  451. RECTL rclBounds; // Accumulation rectangle of blts
  452. // to primary surface
  453. DD_USERMEM_DEFER* pUserMemDefer;
  454. // Any fields below this point may be read if an associated Local
  455. // DirectDraw or Surface lock is held:
  456. HDEV hdev; // Handle to device
  457. // Any fields below must use Interlocked intrinsics to access:
  458. VOID* hdcCache; // Cached GetDC DC
  459. };
  460. /*********************************Class************************************\
  461. * class EDD_DIRECTDRAW_GLOBAL
  462. *
  463. * This object is global to the PDEV.
  464. *
  465. * Locking convention:
  466. *
  467. * This data is static once created (except for cLocal), so the only
  468. * worry is that the data may get deleted while someone is reading it.
  469. * However, this cannot happen while a lock is held on an associated
  470. * DirectDraw or Surface object. So the rule is:
  471. *
  472. * o Always have a lock held on an associated DirectDraw or Surface
  473. * object when reading this structure.
  474. *
  475. \**************************************************************************/
  476. class EDD_DIRECTDRAW_GLOBAL : public _DD_DIRECTDRAW_GLOBAL,
  477. public _DD_DIRECTDRAW_LOCAL,
  478. public DD_DIRECTDRAW_GLOBAL_DRIVER_DATA,
  479. public DD_DIRECTDRAW_GLOBAL_PDEV_DATA
  480. {
  481. // See above structures for contents.
  482. //
  483. // NOTE: Don't add any fields here! Add them to _DRIVER_DATA or _PDEV_DATA!
  484. };
  485. // Add or remove references to the DirectDraw driver instance:
  486. VOID vDdIncrementReferenceCount(
  487. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal
  488. );
  489. VOID vDdDecrementReferenceCount(
  490. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal
  491. );
  492. // Debug macro to ensure that we own the devlock in the appropriate places:
  493. #if DBG
  494. VOID vDdAssertShareDevLock();
  495. VOID vDdAssertDevlock(EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal);
  496. VOID vDdAssertNoDevlock(EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal);
  497. #define DD_ASSERTSHAREDEVLOCK() vDdAssertShareDevlock()
  498. #define DD_ASSERTDEVLOCK(p) vDdAssertDevlock(p)
  499. #define DD_ASSERTNODEVLOCK(p) vDdAssertNoDevlock(p)
  500. #else
  501. #define DD_ASSERTSHAREDEVLOCK()
  502. #define DD_ASSERTDEVLOCK(p)
  503. #define DD_ASSERTNODEVLOCK(p)
  504. #endif
  505. #endif // GDIFLAGS_ONLY used for gdikdx
  506. /*********************************Class************************************\
  507. * class EDD_SURFACE
  508. *
  509. \**************************************************************************/
  510. #define DD_SURFACE_FLAG_PRIMARY 0x0001 // Surface is primary display
  511. #define DD_SURFACE_FLAG_CLIP 0x0002 // There is an HWND associated
  512. // with this surface, so pay
  513. // attention to clipping
  514. #define DD_SURFACE_FLAG_DRIVER_CREATED 0x0004 // Surface was created by the
  515. // driver, so call the driver
  516. // at surface deletion
  517. #define DD_SURFACE_FLAG_CREATE_COMPLETE 0x0008 // Surface has been completely
  518. // created; ignore any further
  519. // NtGdiDdCreateSurfaceObject
  520. // calls with this surface
  521. #define DD_SURFACE_FLAG_UMEM_ALLOCATED 0x0010 // User-mode memory was allocated
  522. // for the surface on behalf
  523. // of the driver
  524. #define DD_SURFACE_FLAG_VMEM_ALLOCATED 0x0020 // Video memory was allocated
  525. // for the surface
  526. #define DD_SURFACE_FLAG_UPDATE_OVERLAY_CALLED 0x0040 // Flag that prevents us from calling
  527. // UpdateOverlay if the driver failed
  528. // to create the surface
  529. #define DD_SURFACE_FLAG_BITMAP_NEEDS_LOCKING 0x0080 // True if the 'hbmGdi' GDI
  530. // representation used by GDI needs
  531. // to have driver's DdLock function
  532. // called before use
  533. #define DD_SURFACE_FLAG_FLIP_PENDING 0x0100 // Set when surface is flipped by
  534. // driver; this is not a reliable
  535. // mechanism to determine flip status
  536. // but will be used when emulating
  537. // system to video blts in kernel
  538. // mode to tell us if we need to
  539. // wait for the flip to finish.
  540. #define DD_SURFACE_FLAG_WRONG_DRIVER 0x0200 // Set when surface is transferred to
  541. // different video driver other than
  542. // it created when the surface is
  543. // "driver managed".
  544. #define DD_SURFACE_FLAG_FAKE_ALIAS_LOCK 0x0400 // Set when we want a NONSYSLOCK lock on
  545. // an AGP surface to behave like
  546. // NONSYSLOCK, even though the driver doesn't
  547. // expose an AGP heap.
  548. #define DD_SURFACE_FLAG_ALIAS_LOCK 0x0800 // Indicates that user mode is holding an
  549. // aliased lock and that we cannot free
  550. // any user mem that the surface may use.
  551. #define DD_SURFACE_FLAG_DEFER_USERMEM 0x1000 // Indicates the surface has allocated
  552. // usermem that needs to be freed via
  553. // the defered list.
  554. #define DD_SURFACE_FLAG_SYSMEM_CREATESURFACEEX 0x2000 // CreateSurfaceEx has been called on
  555. // this system memory surface (which
  556. // means driver has been associated
  557. // to this surface)
  558. #ifndef GDIFLAGS_ONLY // used for gdikdx
  559. class EDD_SURFACE : public DD_OBJECT,
  560. public _DD_SURFACE_LOCAL,
  561. public _DD_SURFACE_MORE,
  562. public _DD_SURFACE_GLOBAL,
  563. public _DD_SURFACE_INT
  564. {
  565. public:
  566. LIST_ENTRY List_eSurface; // List chain of surfaces
  567. // associated with the
  568. // Local DirectDraw object
  569. EDD_SURFACE* peSurface_PrimaryLockNext;
  570. // Next in chain of primary
  571. // surfaces that have an
  572. // active lock
  573. EDD_DXSURFACE* peDxSurface; // Non-pageable part of the
  574. // object, allocated on demand
  575. // for DXAPI clients
  576. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal; // Global DirectDraw object.
  577. EDD_DIRECTDRAW_LOCAL* peDirectDrawLocal; // Local DirectDraw object
  578. FLONG fl; // DD_SURFACE_FLAGs (zeroed when
  579. // surface lost)
  580. ULONG cLocks; // Count of simultaneous Locks
  581. // of this surface
  582. ULONG iVisRgnUniqueness; // Identifies the VisRgn state
  583. // from when the application
  584. // last down-loaded the
  585. // VisRgn
  586. BOOL bLost; // TRUE if surface can't be
  587. // used. NOTE: This field
  588. // is accessible only while
  589. // the devlock is held. This
  590. // is also why it's a BOOL
  591. // and not an 'fl' flag
  592. HANDLE hSecure; // Handle to secured memory
  593. // for DDSCAPS_SYSTEMMEMORY
  594. // surfaces
  595. HDC hdc; // DC handle if a GetDC is
  596. // active; zero if not
  597. HBITMAP hbmGdi; // GDI handle for the surface;
  598. // zero if GetDC hasn't yet
  599. // been called. NOTE: Don't
  600. // convert to SURFOBJ*, as
  601. // 'pConvertDfbSurfaceToDib' may
  602. // get called on it during a
  603. // mode change.
  604. HPALETTE hpalGdi; // GDI handle for the palette
  605. // used in hbmGdi.
  606. HANDLE hSurface; // DXAPI instance handle, used
  607. // for VPE software
  608. // autoflipping
  609. union {
  610. // 'rclLock' is used only for primary surfaces, and the overlay
  611. // dimensions are used only for overlay surfaces. Since the two
  612. // will never overlap, we can use a union to save some space:
  613. RECTL rclLock; // Union of all Lock rectangles
  614. // for this surface
  615. struct {
  616. DWORD dwOverlaySrcWidth; // Used by DXAPI
  617. DWORD dwOverlaySrcHeight; // Used by DXAPI
  618. DWORD dwOverlayDestWidth; // Used by DXAPI
  619. DWORD dwOverlayDestHeight;// Used by DXAPI
  620. };
  621. };
  622. // User-mode surface pointer for Direct3D TextureGetSurf support:
  623. ULONG_PTR upUserModePtr; // LPDIRECTDRAWSURFACE
  624. // If this surface has an NOSYSLOCK lock outstanding, then this point
  625. // to the view of the video memory in which the lock is.
  626. // Currently this is property of the surface. To be similar to the Win9x
  627. // sematics, there should be a pointer per access rect in a surface.
  628. // But we still don't keep track of access rects in the kernel so this
  629. // is a compromise.
  630. EDD_VMEMMAPPING* peMap;
  631. // We need to track the correct peDirectDrawGlobal to be used when freeing this
  632. // mapping. When a mode switch changes the driver we need to make sure the
  633. // original driver is called to free the mapping.
  634. EDD_DIRECTDRAW_GLOBAL* peVirtualMapDdGlobal;
  635. // basically same purpose as above for driver managed surface to keep track
  636. // which video driver create this surface.
  637. ULONG_PTR pldevCreator;
  638. EDD_DIRECTDRAW_GLOBAL* peDdGlobalCreator;
  639. // tracking which graphics device owns this paticualar system memory
  640. // surface, filled when CreateSurfaceEx called for system memory surface.
  641. // only valid with DD_SURFACE_FLAG_CREATESURFACEEX flag.
  642. ULONG_PTR pGraphicsDeviceCreator;
  643. // keep original width and height of DXT textures
  644. DWORD wWidthOriginal;
  645. DWORD wHeightOriginal;
  646. };
  647. #endif
  648. /*********************************Class************************************\
  649. * class EDD_DIRECTDRAW_LOCAL
  650. *
  651. * Essentially, this is a DirectDraw object that is handed out to
  652. * user-mode processes. It should be exclusively locked.
  653. *
  654. \**************************************************************************/
  655. #define DD_LOCAL_FLAG_MEMORY_MAPPED 0x0001 // Frame buffer is mapped into
  656. // the application's space
  657. #define DD_LOCAL_DISABLED 0x0002 // This object has been disabled
  658. // Amount of AGP memory to map at a time when doing user-mode mappings.
  659. // This is dependent on the define AGP_BLOCK_SIZE in nt\drivers\video\ms\port\agp.c
  660. // These two defines must be the same!!
  661. #define DDLOCAL_AGP_MAPPING_PAGES 16
  662. // Since we now allow outstanding locks to video memory even after a mode
  663. // switch there can be multiple views of video memory in any process's
  664. // address space. Only one of these maps to real video memory. The rest are
  665. // just mapped to a dummy page. These user-mode visible "views" of video
  666. // memory correspond to "aliased heaps" on DDraw Win9x. The following
  667. // structure is used to track the lifetime of such mappings.
  668. //
  669. // This structure now tracks AGP heap mappings as well.
  670. #define DD_VMEMMAPPING_FLAG_ALIASED 0x0001
  671. #define DD_VMEMMAPPING_FLAG_AGP 0x0002
  672. // fpProcess is an AGP heap
  673. #ifndef GDIFLAGS_ONLY // used for gdikdx
  674. class EDD_VMEMMAPPING
  675. {
  676. public:
  677. LONG cReferences; // References
  678. FLONG fl; // DD_VMEMMAPPING_FLAGs
  679. union
  680. {
  681. FLATPTR fpProcess; // Video memory base virtual address
  682. VOID* pvVirtAddr; // AGP: Base virtual address
  683. };
  684. VOID* pvReservation; // AGP: User address reservation handle
  685. ULONG ulMapped; // AGP: Highest mapped offset for heap
  686. DWORD iHeapIndex; // AGP: Global heap index into pvmList
  687. BYTE* pAgpVirtualCommitMask;
  688. DWORD dwAgpVirtualCommitMaskSize;
  689. };
  690. class EDD_DIRECTDRAW_LOCAL : public DD_OBJECT,
  691. public _DD_DIRECTDRAW_LOCAL
  692. {
  693. public:
  694. ULONG cSurface; // Number of surfaces associated
  695. // with this DirectDraw object
  696. ULONG cActiveSurface; // Number of surfaces which is
  697. // *not* lost.
  698. LIST_ENTRY ListHead_eSurface; // List of surfaces associated
  699. // with this DirectDraw object
  700. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal; // Pointer to global object
  701. EDD_VIDEOPORT* peVideoPort_DdList; // Pointer to list of
  702. // videoports associated with
  703. // this DirectDraw object
  704. EDD_MOTIONCOMP* peMotionComp_DdList;// Pointer to list of
  705. // motion comp objects
  706. // associated with
  707. // this DirectDraw object
  708. EDD_DIRECTDRAW_LOCAL* peDirectDrawLocalNext;
  709. // Next in chain of DirectDraw
  710. // local objects associated
  711. // with the Global DirectDraw
  712. // object
  713. FLATPTR fpProcess; // Address of frame buffer in
  714. // owning process' address
  715. // space
  716. FLONG fl; // DD_LOCAL_FLAGs
  717. HANDLE UniqueProcess; // Process identifier
  718. PEPROCESS Process; // Process structure pointer
  719. EDD_VMEMMAPPING** ppeMapAgp; // Pointers to current AGP
  720. // heap mappings, if any
  721. int iAgpHeapsMapped; // Count of mapped heaps.
  722. EDD_VMEMMAPPING* peMapCurrent; // Pointer to the current mapping, if any
  723. LPWORD pGammaRamp; // Pointer to gamma ramp set by ddraw
  724. public:
  725. EDD_SURFACE *peSurface_Enum(EDD_SURFACE *peSurface)
  726. {
  727. EDD_SURFACE *peSurface_Next = NULL;
  728. if (!IsListEmpty(&ListHead_eSurface))
  729. {
  730. PLIST_ENTRY p = NULL;
  731. if (peSurface == NULL)
  732. {
  733. // Enum 1st one. get from list head.
  734. p = ListHead_eSurface.Flink;
  735. }
  736. else
  737. {
  738. // Enum next one, check if this is last one or not.
  739. if (peSurface->List_eSurface.Flink != &ListHead_eSurface)
  740. {
  741. p = peSurface->List_eSurface.Flink;
  742. }
  743. }
  744. if (p)
  745. {
  746. peSurface_Next = CONTAINING_RECORD(p,EDD_SURFACE,List_eSurface);
  747. }
  748. }
  749. return (peSurface_Next);
  750. }
  751. };
  752. #endif
  753. #ifdef DXKERNEL_BUILD
  754. /********************************Function**********************************\
  755. * inline EDD_SURFACE* pedFromLp
  756. *
  757. \**************************************************************************/
  758. inline
  759. EDD_SURFACE*
  760. pedFromLp(
  761. DD_SURFACE_LOCAL* pSurfaceLocal
  762. )
  763. {
  764. return((EDD_SURFACE*) ((BYTE*) pSurfaceLocal
  765. - offsetof(EDD_SURFACE, DD_SURFACE_LOCAL::lpGbl)));
  766. }
  767. /*********************************Class************************************\
  768. * class EDD_VIDEOPORT
  769. *
  770. \**************************************************************************/
  771. #define DD_VIDEOPORT_FLAG_DRIVER_CREATED 0x0001
  772. // Videoport was created by the
  773. // driver, so call the driver
  774. // at surface deletion
  775. class EDD_VIDEOPORT : public DD_OBJECT,
  776. public _DD_VIDEOPORT_LOCAL
  777. {
  778. public:
  779. EDD_VIDEOPORT* peVideoPort_DdNext; // Next in chain of videoports
  780. // associated with the Local
  781. // DirectDraw object
  782. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal; // Global DirectDraw object
  783. EDD_DIRECTDRAW_LOCAL* peDirectDrawLocal; // Local DirectDraw object
  784. FLONG fl; // DD_VIDEOPORT_FLAGs
  785. DDPIXELFORMAT ddpfInputFormat; // Holds ddvpInfo.lpddpfInputFormat
  786. EDD_DXVIDEOPORT* peDxVideoPort; // Non-pageable part of the
  787. // object, allocated on demand
  788. // for DXAPI clients
  789. HANDLE hVideoPort; // DXAPI instance handle, used
  790. // for VPE software
  791. // autoflipping
  792. DWORD cAutoflipVideo; // Number of autoflip surfaces
  793. // for video
  794. DWORD cAutoflipVbi; // Number of autoflip surfaces
  795. // for VBI data
  796. EDD_SURFACE* apeSurfaceVideo[MAX_AUTOFLIP_BUFFERS];
  797. // Array of video autoflip
  798. // surfaces
  799. EDD_SURFACE* apeSurfaceVbi[MAX_AUTOFLIP_BUFFERS];
  800. // Array of VBI autoflip
  801. // surfaces
  802. };
  803. /********************************Function**********************************\
  804. * EDD_VIDEOPORT* pedFromLp
  805. *
  806. \**************************************************************************/
  807. inline
  808. EDD_VIDEOPORT*
  809. pedFromLp(
  810. DD_VIDEOPORT_LOCAL* pVideoPortLocal
  811. )
  812. {
  813. return((EDD_VIDEOPORT*) ((BYTE*) pVideoPortLocal
  814. - offsetof(EDD_VIDEOPORT, lpDD)));
  815. }
  816. /*********************************Class************************************\
  817. * class EDD_PALETTE
  818. *
  819. \**************************************************************************/
  820. class EDD_PALETTE : public DD_OBJECT,
  821. public _DD_PALETTE_LOCAL,
  822. public _DD_PALETTE_GLOBAL
  823. {
  824. public:
  825. };
  826. /*********************************Class************************************\
  827. * class EDD_CLIPPER
  828. *
  829. \**************************************************************************/
  830. class EDD_CLIPPER : public DD_OBJECT,
  831. public _DD_CLIPPER_LOCAL,
  832. public _DD_CLIPPER_GLOBAL
  833. {
  834. public:
  835. };
  836. /*********************************Class************************************\
  837. * class EDD_MOTIONCOMP
  838. *
  839. \**************************************************************************/
  840. #define DD_MOTIONCOMP_FLAG_DRIVER_CREATED 0x0001
  841. // Videoport was created by the
  842. // driver, so call the driver
  843. // at surface deletion
  844. class EDD_MOTIONCOMP : public DD_OBJECT,
  845. public _DD_MOTIONCOMP_LOCAL
  846. {
  847. public:
  848. EDD_MOTIONCOMP* peMotionComp_DdNext;// Next in chain of video objects
  849. // associated with the Local
  850. // DirectDraw object
  851. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal; // Global DirectDraw object
  852. EDD_DIRECTDRAW_LOCAL* peDirectDrawLocal; // Local DirectDraw object
  853. FLONG fl; // DD_MOTIONCOMP_FLAGs
  854. };
  855. ////////////////////////////////////////////////////////////////////////////
  856. // DXAPI structures
  857. typedef struct _DXAPI_EVENT DXAPI_EVENT;
  858. typedef struct _DXAPI_EVENT {
  859. EDD_DXDIRECTDRAW* peDxDirectDraw; // Associated DirectDraw object
  860. EDD_DXVIDEOPORT* peDxVideoPort; // NULL if event is not tied
  861. // to a videoport
  862. DWORD dwEvent;
  863. DWORD dwIrqFlag; // 0 if not an interrupt event
  864. LPDD_NOTIFYCALLBACK pfnCallBack;
  865. PVOID pContext;
  866. DXAPI_EVENT* pDxEvent_Next;
  867. } DXAPI_EVENT;
  868. /*********************************Class************************************\
  869. * class EDD_DXDIRECTDRAW
  870. *
  871. * The non-pageable part of the EDD_DIRECTDRAW_GLOBAL structure, allocated
  872. * on demand for DXAPI clients.
  873. *
  874. \**************************************************************************/
  875. /*
  876. * We keep two disptach lists - one for the callbacks registered by the clients
  877. * and another for our own callbacks. We do this so we can gaurentee that we
  878. * call the clients first so they can call the skip fucntions before we execute
  879. * our skip logic within our own callbacks.
  880. */
  881. #define NUM_DISPATCH_LISTS 2
  882. #define CLIENT_DISPATCH_LIST 0
  883. #define INTERNAL_DISPATCH_LIST 1
  884. class EDD_DXDIRECTDRAW
  885. {
  886. public:
  887. BOOL bLost; // DirectDraw object is lost
  888. EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal; // Owning DirectDraw object;
  889. // NULL if lost
  890. DXOBJ* pDxObj_List; // List of open DXAPI objects
  891. // for this DirectDraw object
  892. HDEV hdev; // Identifies owning PDEV
  893. DXAPI_INTERFACE DxApiInterface; // Call-tables into miniport
  894. VOID* HwDeviceExtension; // Miniport's context
  895. DWORD dwIRQCaps; // Miniport's interrupt
  896. // capabilities
  897. KDPC EventDpc; // DPC for handling interrupt
  898. // call-backs
  899. KSPIN_LOCK SpinLock; // SpinLock for protecting
  900. // DXAPI event list and
  901. // serializing raised
  902. // IRQL calls to miniport
  903. DWORD dwSynchedIrqFlags; // Used temporarily for
  904. // atomically reading
  905. // the miniport's dwIrqFlags
  906. // interrupt status
  907. DX_IRQDATA IrqData; // Context miniport passes
  908. // back to us on its
  909. // IRQCallBack call during an
  910. // interrupt
  911. DXAPI_EVENT* pDxEvent_PassiveList; // List of passive-level
  912. // events, protected by
  913. // devlock
  914. DXAPI_EVENT* pDxEvent_DispatchList[2];// Lists of dispatch-level
  915. // events, protected by
  916. // spinlock
  917. DXAPI_EVENT* pDxEvent_CaptureList; // List of video ports
  918. // capturing
  919. };
  920. #endif // DXKERNEL_BUILD
  921. /*********************************Class************************************\
  922. * class EDD_DXVIDEOPORT
  923. *
  924. * The non-pageable part of the EDD_VIDEOPORT structure, allocated
  925. * on demand for DXAPI clients.
  926. *
  927. \**************************************************************************/
  928. #define DD_DXVIDEOPORT_FLAG_ON 0x0001
  929. // The video port is on
  930. #define DD_DXVIDEOPORT_FLAG_AUTOFLIP 0x0002
  931. // Video data is autoflipped using IRQ
  932. #define DD_DXVIDEOPORT_FLAG_AUTOFLIP_VBI 0x0004
  933. // VBI data is autoflipped using IRQ
  934. #define DD_DXVIDEOPORT_FLAG_BOB 0x0008
  935. // Video data using bob via the IRQ
  936. #define DD_DXVIDEOPORT_FLAG_CAPTURING 0x0010
  937. // VP has capture buffers in queue
  938. #define DD_DXVIDEOPORT_FLAG_NEW_STATE 0x0020
  939. // A new state change has been posted
  940. #define DD_DXVIDEOPORT_FLAG_SKIPPED_LAST 0x0040
  941. // The previous field was skipped
  942. // - VP needs restoring
  943. #define DD_DXVIDEOPORT_FLAG_SKIP_SET 0x0080
  944. // dwStartSkip contains valid data
  945. #define DD_DXVIDEOPORT_FLAG_NEXT_SKIP_SET 0x0100
  946. // dwNextSkip contains valid data
  947. #define DD_DXVIDEOPORT_FLAG_FLIP_NEXT 0x0200
  948. // This video field was not
  949. // flipped due to interleaving
  950. #define DD_DXVIDEOPORT_FLAG_FLIP_NEXT_VBI 0x0400
  951. // This VBI field was not
  952. // flipped due to interleaving
  953. #define DD_DXVIDEOPORT_FLAG_VBI_INTERLEAVED 0x0800
  954. // Is the VBI data interleaved?
  955. #define DD_DXVIDEOPORT_FLAG_HALFLINES 0x1000
  956. // Due to half lines, even field
  957. // data is shifted down one line
  958. #define DD_DXVIDEOPORT_FLAG_DISABLEAUTOFLIP 0x2000
  959. // Overlay autoflipping is
  960. // temporarily disabled
  961. #define DD_DXVIDEOPORT_FLAG_SOFTWAREBOB 0x4000
  962. // Don't use hardware bob
  963. #define DD_DXVIDEOPORT_FLAG_REGISTERED_IRQ 0x8000
  964. // Have added the video port VSYNC to the list of registered callbacks
  965. #ifdef DXKERNEL_BUILD
  966. class EDD_DXVIDEOPORT : public DDVIDEOPORTDATA
  967. {
  968. public:
  969. BOOL bLost; // Videoport is lost
  970. EDD_VIDEOPORT* peVideoPort; // Owning videoport; NULL if
  971. // lost
  972. DXOBJ* pDxObj_List; // List of open DXAPI objects
  973. // for this VideoPort
  974. EDD_DXDIRECTDRAW* peDxDirectDraw; // Owning DXAPI DirectDraw
  975. // object
  976. EDD_DXCAPTURE* peDxCapture; // List of capture objects
  977. // capturing from vport
  978. DWORD dwVideoPortID; // ddvpDesc.dwVideoPortID
  979. FLONG flFlags; // DD_DXVIDEOPORT_FLAGs
  980. BOOL bSoftwareAutoflip;
  981. BOOL bSkip;
  982. // The following fields are updated asynchronously from the VideoPort
  983. // DPC, so be very careful when modifying them. In general, the
  984. // device's spinlock must acquired to use the fields.
  985. DWORD dwCurrentField; // Current field number
  986. DWORD iCurrentVideo; // Surface index of current
  987. // autoflip videoport video
  988. // output
  989. DWORD iCurrentVbi; // Surface index of current
  990. // autoflip videoport VBI
  991. // output
  992. DWORD dwFieldToSkip; // Field to be skipped
  993. // (relative to current field)
  994. DWORD dwNextFieldToSkip; // So client can specify two
  995. // fields w/o waiting for
  996. // the first one to skip
  997. DWORD dwSetStateField; // Field number at which new
  998. // SetState is to take effect
  999. DWORD dwSetStateState; // New SetState state
  1000. DWORD cAutoflipVideo; // Number of autoflip surfaces
  1001. // for video
  1002. DWORD cAutoflipVbi; // Number of autoflip surfaces
  1003. // for VBI data
  1004. EDD_DXSURFACE* apeDxSurfaceVideo[MAX_AUTOFLIP_BUFFERS];
  1005. // Array of video autoflip
  1006. // surfaces
  1007. EDD_DXSURFACE* apeDxSurfaceVbi[MAX_AUTOFLIP_BUFFERS];
  1008. // Array of VBI autoflip
  1009. // surfaces
  1010. PKEVENT pNotifyEvent;
  1011. HANDLE pNotifyEventHandle;
  1012. LPDDVIDEOPORTNOTIFY pNotifyBuffer;
  1013. PMDL pNotifyMdl;
  1014. };
  1015. #endif // DXKERNEL_BUILD
  1016. /*********************************Class************************************\
  1017. * class EDD_DXSURFACE
  1018. *
  1019. * The non-pageable part of the EDD_SURFACE structure, allocated
  1020. * on demand for DXAPI clients.
  1021. *
  1022. \**************************************************************************/
  1023. #define DD_DXSURFACE_FLAG_STATE_SET 0x0001
  1024. // State was explicitly set
  1025. // via DxApi
  1026. #define DD_DXSURFACE_FLAG_STATE_BOB 0x0002
  1027. // State is bob
  1028. #define DD_DXSURFACE_FLAG_STATE_WEAVE 0x0004
  1029. // State is weave
  1030. #define DD_DXSURFACE_FLAG_CAN_BOB_INTERLEAVED 0x0008
  1031. // Surface can be bobbed when
  1032. // interleaved
  1033. #define DD_DXSURFACE_FLAG_CAN_BOB_NONINTERLEAVED 0x0010
  1034. // Surface can be bobbed when
  1035. // not interleaved
  1036. #define DD_DXSURFACE_FLAG_TRANSFER 0x0020
  1037. // A busmaster was made from
  1038. // this surface
  1039. #ifdef DXKERNEL_BUILD
  1040. class EDD_DXSURFACE : public DDSURFACEDATA
  1041. {
  1042. public:
  1043. BOOL bLost; // Surface is lost
  1044. EDD_SURFACE* peSurface; // Owning surface; NULL if lost
  1045. DXOBJ* pDxObj_List; // List of open DXAPI objects
  1046. // for this surface
  1047. EDD_DXDIRECTDRAW* peDxDirectDraw; // Owning DXAPI DirectDraw
  1048. // object
  1049. EDD_DXVIDEOPORT* peDxVideoPort; // Video port associated with
  1050. // surface
  1051. FLONG flFlags;
  1052. };
  1053. #endif // DXKERNEL_BUILD
  1054. /*********************************Class************************************\
  1055. * class EDD_DXCAPTURE
  1056. *
  1057. * The non-pageable capture structure used to capture from the video port,
  1058. * allocated on demand for DXAPI clients.
  1059. *
  1060. \**************************************************************************/
  1061. #define DD_DXCAPTUREBUFF_FLAG_IN_USE 0x0001
  1062. // The buffer is currently begin used
  1063. #define DD_DXCAPTUREBUFF_FLAG_WAITING 0x0002
  1064. // The buffer is waiting to be filled
  1065. #define DD_DXCAPTUREBUFF_FLAG_FLUSH 0x0004
  1066. // The buffer has been flushed - set the event
  1067. #ifdef DXKERNEL_BUILD
  1068. typedef struct _DXCAPTUREBUFF
  1069. {
  1070. FLONG flFlags;
  1071. PMDL pBuffMDL;
  1072. PKEVENT pBuffKEvent;
  1073. PVOID lpBuffInfo;
  1074. DWORD dwClientFlags;
  1075. EDD_DXSURFACE* peDxSurface;
  1076. } DXCAPTUREBUFF;
  1077. #endif // DXKERNEL_BUILD
  1078. #define DD_DXCAPTURE_FLAG_VBI 0x0001
  1079. // Object is capturing VBI
  1080. #define DD_DXCAPTURE_FLAG_VIDEO 0x0002
  1081. // Object is capturing video
  1082. #define DXCAPTURE_MAX_CAPTURE_BUFFS 10
  1083. #ifdef DXKERNEL_BUILD
  1084. class EDD_DXCAPTURE
  1085. {
  1086. public:
  1087. BOOL bLost; // Capture object is lost
  1088. DXOBJ* pDxObj_List; // List of open DXAPI objects
  1089. // for this Capture object
  1090. FLONG flFlags; // DD_DXCAPTURE_FLAGs
  1091. DWORD dwStartLine; // Line in buffer to start
  1092. // capturing
  1093. DWORD dwEndLine; // Line in buffer to end
  1094. // capturing (inclusive)
  1095. DWORD dwCaptureEveryNFields;// 1 = capture every field,
  1096. // 2 = capture every 2nd field,
  1097. // etc.
  1098. DWORD dwCaptureCountDown; // Used internally to handle
  1099. // dwCaptureEveryNFields
  1100. DWORD dwTransferId; // ????
  1101. // The following fields are updated asynchronously from the DPC,
  1102. // so be very careful when modifying them. In general, the
  1103. // device's spinlock must acquired to use the fields.
  1104. EDD_DXVIDEOPORT* peDxVideoPort; // Owning videoport; NULL if
  1105. // lost
  1106. EDD_DXCAPTURE* peDxCaptureNext; // Next object in list of objects
  1107. // associated with vport
  1108. DWORD dwTop; // ????
  1109. DWORD dwBottom; // ????
  1110. DXCAPTUREBUFF CaptureQueue[DXCAPTURE_MAX_CAPTURE_BUFFS];
  1111. };
  1112. /*********************************Class************************************\
  1113. * class DXOBJ
  1114. *
  1115. * Non-pageable structure used to represent all objects passed out to DXAPI
  1116. * clients. There may be more than one DXOBJ instance per actual DXAPI
  1117. * object, so they're kept in a linked list.
  1118. *
  1119. * Whenever we give out an object handle via DXAPI, it's actually a pointer
  1120. * to one of these objects.
  1121. *
  1122. \**************************************************************************/
  1123. typedef enum {
  1124. DXT_INVALID,
  1125. DXT_DIRECTDRAW,
  1126. DXT_SURFACE,
  1127. DXT_VIDEOPORT,
  1128. DXT_CAPTURE,
  1129. } DXTYPE;
  1130. class DXOBJ
  1131. {
  1132. public:
  1133. DXTYPE iDxType; // DXAPI object type
  1134. LPDD_NOTIFYCALLBACK pfnClose; // Call-back context data
  1135. PVOID pContext; // for informing DXAPI
  1136. DWORD dwEvent; // client when object
  1137. // is no longer valid
  1138. DXOBJ* pDxObj_Next; // There may be more than one
  1139. // DXAPI instance per actual
  1140. // DXAPI object, so this
  1141. // points to the next instance
  1142. // for this DXAPI object
  1143. DWORD dwFlags; // DXT_ flags
  1144. PEPROCESS pepSession; // Pointer to CsrSS process of
  1145. // the session who own this
  1146. // object. (need for TS)
  1147. union {
  1148. EDD_DXDIRECTDRAW* peDxDirectDraw; // Points to owning DXAPI object
  1149. EDD_DXSURFACE* peDxSurface; // of the respective type
  1150. EDD_DXVIDEOPORT* peDxVideoPort;
  1151. EDD_DXCAPTURE* peDxCapture;
  1152. };
  1153. };
  1154. #endif // DXKERNEL_BUILD