CommonTypes.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (c) Microsoft Corporation. All rights reserved
  7. #ifndef _COMMONTYPES_H_
  8. #define _COMMONTYPES_H_
  9. #include <windows.h>
  10. #include <d3d11.h>
  11. #include <dxgi1_2.h>
  12. #include <sal.h>
  13. #include <new>
  14. #include <warning.h>
  15. #include <DirectXMath.h>
  16. #include <initguid.h>
  17. #include "PixelShader.h"
  18. #include "VertexShader.h"
  19. #define NUMVERTICES 6
  20. #define BPP 4
  21. #define OCCLUSION_STATUS_MSG WM_USER
  22. extern HRESULT SystemTransitionsExpectedErrors[];
  23. extern HRESULT CreateDuplicationExpectedErrors[];
  24. extern HRESULT FrameInfoExpectedErrors[];
  25. extern HRESULT AcquireFrameExpectedError[];
  26. extern HRESULT EnumOutputsExpectedErrors[];
  27. typedef _Return_type_success_(return == DUPL_RETURN_SUCCESS) enum {
  28. DUPL_RETURN_SUCCESS = 0,
  29. DUPL_RETURN_ERROR_EXPECTED = 1,
  30. DUPL_RETURN_ERROR_UNEXPECTED = 2
  31. } DUPL_RETURN;
  32. _Post_satisfies_(return != DUPL_RETURN_SUCCESS)
  33. DUPL_RETURN ProcessFailure(_In_opt_ ID3D11Device* Device, _In_ LPCWSTR Str, _In_ LPCWSTR Title, HRESULT hr, _In_opt_z_ HRESULT* ExpectedErrors = nullptr);
  34. void DisplayMsg(_In_ LPCWSTR Str, _In_ LPCWSTR Title, HRESULT hr);
  35. //
  36. // Holds info about the pointer/cursor
  37. //
  38. typedef struct _PTR_INFO {
  39. _Field_size_bytes_(BufferSize) BYTE* PtrShapeBuffer;
  40. DXGI_OUTDUPL_POINTER_SHAPE_INFO ShapeInfo;
  41. POINT Position;
  42. bool Visible;
  43. UINT BufferSize;
  44. UINT WhoUpdatedPositionLast;
  45. LARGE_INTEGER LastTimeStamp;
  46. } PTR_INFO;
  47. //
  48. // Structure that holds D3D resources not directly tied to any one thread
  49. //
  50. typedef struct _DX_RESOURCES {
  51. ID3D11Device* Device;
  52. ID3D11DeviceContext* Context;
  53. ID3D11VertexShader* VertexShader;
  54. ID3D11PixelShader* PixelShader;
  55. ID3D11InputLayout* InputLayout;
  56. ID3D11SamplerState* SamplerLinear;
  57. } DX_RESOURCES;
  58. //
  59. // Structure to pass to a new thread
  60. //
  61. typedef struct _THREAD_DATA {
  62. // Used to indicate abnormal error condition
  63. HANDLE UnexpectedErrorEvent;
  64. // Used to indicate a transition event occurred e.g. PnpStop, PnpStart, mode change, TDR, desktop switch and the application needs to recreate the duplication interface
  65. HANDLE ExpectedErrorEvent;
  66. // Used by WinProc to signal to threads to exit
  67. HANDLE TerminateThreadsEvent;
  68. HANDLE TexSharedHandle;
  69. UINT Output;
  70. INT OffsetX;
  71. INT OffsetY;
  72. PTR_INFO* PtrInfo;
  73. DX_RESOURCES DxRes;
  74. const struct tmedia_producer_s* Producer;
  75. } THREAD_DATA;
  76. //
  77. // FRAME_DATA holds information about an acquired frame
  78. //
  79. typedef struct _FRAME_DATA {
  80. ID3D11Texture2D* Frame;
  81. DXGI_OUTDUPL_FRAME_INFO FrameInfo;
  82. _Field_size_bytes_((MoveCount * sizeof(DXGI_OUTDUPL_MOVE_RECT)) + (DirtyCount * sizeof(RECT))) BYTE* MetaData;
  83. UINT DirtyCount;
  84. UINT MoveCount;
  85. } FRAME_DATA;
  86. //
  87. // A vertex with a position and texture coordinate
  88. //
  89. typedef struct _VERTEX {
  90. DirectX::XMFLOAT3 Pos;
  91. DirectX::XMFLOAT2 TexCoord;
  92. } VERTEX;
  93. #endif