2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
23 #ifndef _D3DADAPTER_PRESENT_H_
24 #define _D3DADAPTER_PRESENT_H_
28 #ifndef D3DOK_WINDOW_OCCLUDED
29 #define D3DOK_WINDOW_OCCLUDED MAKE_D3DSTATUS(2531)
30 #endif /* D3DOK_WINDOW_OCCLUDED */
33 typedef struct ID3DPresent ID3DPresent
;
34 typedef struct ID3DPresentGroup ID3DPresentGroup
;
35 typedef struct ID3DAdapter9 ID3DAdapter9
;
36 typedef struct D3DWindowBuffer D3DWindowBuffer
;
38 /* Presentation backend for drivers to display their brilliant work */
39 typedef struct ID3DPresentVtbl
42 HRESULT (WINAPI
*QueryInterface
)(ID3DPresent
*This
, REFIID riid
, void **ppvObject
);
43 ULONG (WINAPI
*AddRef
)(ID3DPresent
*This
);
44 ULONG (WINAPI
*Release
)(ID3DPresent
*This
);
47 /* This function initializes the screen and window provided at creation.
48 * Hence why this should always be called as the one of first things a new
50 HRESULT (WINAPI
*SetPresentParameters
)(ID3DPresent
*This
, D3DPRESENT_PARAMETERS
*pPresentationParameters
, D3DDISPLAYMODEEX
*pFullscreenDisplayMode
);
51 /* Make a buffer visible to the window system via dma-buf fd.
52 * For better compatibility, it must be 32bpp and format ARGB/XRGB */
53 HRESULT (WINAPI
*NewD3DWindowBufferFromDmaBuf
)(ID3DPresent
*This
, int dmaBufFd
, int width
, int height
, int stride
, int depth
, int bpp
, D3DWindowBuffer
**out
);
54 HRESULT (WINAPI
*DestroyD3DWindowBuffer
)(ID3DPresent
*This
, D3DWindowBuffer
*buffer
);
55 /* After presenting a buffer to the window system, the buffer
56 * may be used as is (no copy of the content) by the window system.
57 * You must not use a non-released buffer, else the user may see undefined content. */
58 HRESULT (WINAPI
*WaitBufferReleased
)(ID3DPresent
*This
, D3DWindowBuffer
*buffer
);
59 HRESULT (WINAPI
*FrontBufferCopy
)(ID3DPresent
*This
, D3DWindowBuffer
*buffer
);
60 /* It is possible to do partial copy, but impossible to do resizing, which must
61 * be done by the client after checking the front buffer size */
62 HRESULT (WINAPI
*PresentBuffer
)(ID3DPresent
*This
, D3DWindowBuffer
*buffer
, HWND hWndOverride
, const RECT
*pSourceRect
, const RECT
*pDestRect
, const RGNDATA
*pDirtyRegion
, DWORD Flags
);
63 HRESULT (WINAPI
*GetRasterStatus
)(ID3DPresent
*This
, D3DRASTER_STATUS
*pRasterStatus
);
64 HRESULT (WINAPI
*GetDisplayMode
)(ID3DPresent
*This
, D3DDISPLAYMODEEX
*pMode
, D3DDISPLAYROTATION
*pRotation
);
65 HRESULT (WINAPI
*GetPresentStats
)(ID3DPresent
*This
, D3DPRESENTSTATS
*pStats
);
66 HRESULT (WINAPI
*GetCursorPos
)(ID3DPresent
*This
, POINT
*pPoint
);
67 HRESULT (WINAPI
*SetCursorPos
)(ID3DPresent
*This
, POINT
*pPoint
);
68 /* Cursor size is always 32x32. pBitmap and pHotspot can be NULL. */
69 HRESULT (WINAPI
*SetCursor
)(ID3DPresent
*This
, void *pBitmap
, POINT
*pHotspot
, BOOL bShow
);
70 HRESULT (WINAPI
*SetGammaRamp
)(ID3DPresent
*This
, const D3DGAMMARAMP
*pRamp
, HWND hWndOverride
);
71 HRESULT (WINAPI
*GetWindowInfo
)(ID3DPresent
*This
, HWND hWnd
, int *width
, int *height
, int *depth
);
72 /* Available since version 1.1 */
73 BOOL (WINAPI
*GetWindowOccluded
)(ID3DPresent
*This
);
78 ID3DPresentVtbl
*lpVtbl
;
82 #define ID3DPresent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
83 #define ID3DPresent_AddRef(p) (p)->lpVtbl->AddRef(p)
84 #define ID3DPresent_Release(p) (p)->lpVtbl->Release(p)
85 /* ID3DPresent macros */
86 #define ID3DPresent_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
87 #define ID3DPresent_SetPresentParameters(p,a,b) (p)->lpVtbl->SetPresentParameters(p,a,b)
88 #define ID3DPresent_NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g) (p)->lpVtbl->NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g)
89 #define ID3DPresent_DestroyD3DWindowBuffer(p,a) (p)->lpVtbl->DestroyD3DWindowBuffer(p,a)
90 #define ID3DPresent_WaitBufferReleased(p,a) (p)->lpVtbl->WaitBufferReleased(p,a)
91 #define ID3DPresent_FrontBufferCopy(p,a) (p)->lpVtbl->FrontBufferCopy(p,a)
92 #define ID3DPresent_PresentBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->PresentBuffer(p,a,b,c,d,e,f)
93 #define ID3DPresent_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
94 #define ID3DPresent_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b)
95 #define ID3DPresent_GetPresentStats(p,a) (p)->lpVtbl->GetPresentStats(p,a)
96 #define ID3DPresent_GetCursorPos(p,a) (p)->lpVtbl->GetCursorPos(p,a)
97 #define ID3DPresent_SetCursorPos(p,a) (p)->lpVtbl->SetCursorPos(p,a)
98 #define ID3DPresent_SetCursor(p,a,b,c) (p)->lpVtbl->SetCursor(p,a,b,c)
99 #define ID3DPresent_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b)
100 #define ID3DPresent_GetWindowInfo(p,a,b,c,d) (p)->lpVtbl->GetWindowSize(p,a,b,c,d)
101 #define ID3DPresent_GetWindowOccluded(p) (p)->lpVtbl->GetWindowOccluded(p)
103 typedef struct ID3DPresentGroupVtbl
106 HRESULT (WINAPI
*QueryInterface
)(ID3DPresentGroup
*This
, REFIID riid
, void **ppvObject
);
107 ULONG (WINAPI
*AddRef
)(ID3DPresentGroup
*This
);
108 ULONG (WINAPI
*Release
)(ID3DPresentGroup
*This
);
110 /* ID3DPresentGroup */
111 /* When creating a device, it's relevant for the driver to know how many
112 * implicit swap chains to create. It has to create one per monitor in a
113 * multi-monitor setup */
114 UINT (WINAPI
*GetMultiheadCount
)(ID3DPresentGroup
*This
);
115 /* returns only the implicit present interfaces */
116 HRESULT (WINAPI
*GetPresent
)(ID3DPresentGroup
*This
, UINT Index
, ID3DPresent
**ppPresent
);
117 /* used to create additional presentation interfaces along the way */
118 HRESULT (WINAPI
*CreateAdditionalPresent
)(ID3DPresentGroup
*This
, D3DPRESENT_PARAMETERS
*pPresentationParameters
, ID3DPresent
**ppPresent
);
119 void (WINAPI
*GetVersion
) (ID3DPresentGroup
*This
, int *major
, int *minor
);
120 } ID3DPresentGroupVtbl
;
122 struct ID3DPresentGroup
124 ID3DPresentGroupVtbl
*lpVtbl
;
127 /* IUnknown macros */
128 #define ID3DPresentGroup_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
129 #define ID3DPresentGroup_AddRef(p) (p)->lpVtbl->AddRef(p)
130 #define ID3DPresentGroup_Release(p) (p)->lpVtbl->Release(p)
131 /* ID3DPresentGroup */
132 #define ID3DPresentGroup_GetMultiheadCount(p) (p)->lpVtbl->GetMultiheadCount(p)
133 #define ID3DPresentGroup_GetPresent(p,a,b) (p)->lpVtbl->GetPresent(p,a,b)
134 #define ID3DPresentGroup_CreateAdditionalPresent(p,a,b) (p)->lpVtbl->CreateAdditionalPresent(p,a,b)
135 #define ID3DPresentGroup_GetVersion(p,a,b) (p)->lpVtbl->GetVersion(p,a,b)
137 #endif /* __cplusplus */
139 #endif /* _D3DADAPTER_PRESENT_H_ */