1 | /* $Id: VBoxDispInternal.h 99828 2023-05-17 13:48:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox XPDM Display driver, internal header
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_xpdm_VBoxDispInternal_h
|
---|
29 | #define GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_xpdm_VBoxDispInternal_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <iprt/cdefs.h>
|
---|
35 | #define LOG_GROUP LOG_GROUP_DRV_DISPLAY
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <iprt/err.h>
|
---|
38 | #include <iprt/assert.h>
|
---|
39 | #include <iprt/win/windef.h>
|
---|
40 | #include <wingdi.h>
|
---|
41 | #include <winddi.h>
|
---|
42 | #include <ntddvdeo.h>
|
---|
43 | #undef CO_E_NOTINITIALIZED
|
---|
44 | #include <winerror.h>
|
---|
45 | #include <devioctl.h>
|
---|
46 | #define VBOX_VIDEO_LOG_NAME "VBoxDisp"
|
---|
47 | #include "common/VBoxVideoLog.h"
|
---|
48 | #include "common/xpdm/VBoxVideoPortAPI.h"
|
---|
49 | #include "common/xpdm/VBoxVideoIOCTL.h"
|
---|
50 | #include <HGSMI.h>
|
---|
51 | #include <VBoxVideo.h>
|
---|
52 | #include <VBoxVideoGuest.h>
|
---|
53 | #include <VBoxDisplay.h>
|
---|
54 |
|
---|
55 | typedef struct _VBOXDISPDEV *PVBOXDISPDEV;
|
---|
56 |
|
---|
57 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
58 | # include "VBoxDispVHWA.h"
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | /* 4bytes tag passed to EngAllocMem.
|
---|
62 | * Note: chars are reverse order.
|
---|
63 | */
|
---|
64 | #define MEM_ALLOC_TAG 'bvDD'
|
---|
65 |
|
---|
66 | /* Helper macros */
|
---|
67 | #define VBOX_WARN_WINERR(_winerr) \
|
---|
68 | do { \
|
---|
69 | if ((_winerr) != NO_ERROR) \
|
---|
70 | { \
|
---|
71 | WARN(("winerr(%#x)!=NO_ERROR", _winerr)); \
|
---|
72 | } \
|
---|
73 | } while (0)
|
---|
74 |
|
---|
75 | #define VBOX_CHECK_WINERR_RETRC(_winerr, _rc) \
|
---|
76 | do { \
|
---|
77 | if ((_winerr) != NO_ERROR) \
|
---|
78 | { \
|
---|
79 | WARN(("winerr(%#x)!=NO_ERROR", _winerr)); \
|
---|
80 | return (_rc); \
|
---|
81 | } \
|
---|
82 | } while (0)
|
---|
83 |
|
---|
84 | #define VBOX_WARNRC_RETV(_rc, _ret) \
|
---|
85 | do { \
|
---|
86 | if (RT_FAILURE(_rc)) \
|
---|
87 | { \
|
---|
88 | WARN(("RT_FAILURE rc(%#x)", _rc)); \
|
---|
89 | return (_ret); \
|
---|
90 | } \
|
---|
91 | } while (0)
|
---|
92 |
|
---|
93 | #define VBOX_WARNRC_RETRC(_rc) VBOX_WARNRC_RETV(_rc, _rc)
|
---|
94 |
|
---|
95 | #define VBOX_WARNRC(_rc) \
|
---|
96 | do { \
|
---|
97 | if (RT_FAILURE(_rc)) \
|
---|
98 | { \
|
---|
99 | WARN(("RT_FAILURE rc(%#x)", _rc)); \
|
---|
100 | } \
|
---|
101 | } while (0)
|
---|
102 |
|
---|
103 | #define VBOX_WARNRC_NOBP(_rc) \
|
---|
104 | do { \
|
---|
105 | if (RT_FAILURE(_rc)) \
|
---|
106 | { \
|
---|
107 | WARN_NOBP(("RT_FAILURE rc(%#x)", _rc)); \
|
---|
108 | } \
|
---|
109 | } while (0)
|
---|
110 |
|
---|
111 |
|
---|
112 | #define VBOX_WARN_IOCTLCB_RETRC(_ioctl, _cbreturned, _cbexpected, _rc) \
|
---|
113 | do { \
|
---|
114 | if ((_cbreturned)!=(_cbexpected)) \
|
---|
115 | { \
|
---|
116 | WARN((_ioctl " returned %d, expected %d bytes!", _cbreturned, _cbexpected)); \
|
---|
117 | return (_rc); \
|
---|
118 | } \
|
---|
119 | } while (0)
|
---|
120 |
|
---|
121 | #define abs(_v) ( ((_v)>0) ? (_v) : (-(_v)) )
|
---|
122 |
|
---|
123 | typedef struct _CLIPRECTS {
|
---|
124 | ULONG c;
|
---|
125 | RECTL arcl[64];
|
---|
126 | } CLIPRECTS;
|
---|
127 |
|
---|
128 | typedef struct _VRDPCLIPRECTS
|
---|
129 | {
|
---|
130 | RECTL rclDstOrig; /* Original bounding rectangle. */
|
---|
131 | RECTL rclDst; /* Bounding rectangle of all rects. */
|
---|
132 | CLIPRECTS rects; /* Rectangles to update. */
|
---|
133 | } VRDPCLIPRECTS;
|
---|
134 |
|
---|
135 | /* Mouse pointer related functions */
|
---|
136 | int VBoxDispInitPointerCaps(PVBOXDISPDEV pDev, DEVINFO *pDevInfo);
|
---|
137 | int VBoxDispInitPointerAttrs(PVBOXDISPDEV pDev);
|
---|
138 |
|
---|
139 | /* Palette related functions */
|
---|
140 | int VBoxDispInitPalette(PVBOXDISPDEV pDev, DEVINFO *pDevInfo);
|
---|
141 | void VBoxDispDestroyPalette(PVBOXDISPDEV pDev);
|
---|
142 | int VBoxDispSetPalette8BPP(PVBOXDISPDEV pDev);
|
---|
143 |
|
---|
144 | /* VBVA related */
|
---|
145 | int VBoxDispVBVAInit(PVBOXDISPDEV pDev);
|
---|
146 | void VBoxDispVBVAHostCommandComplete(PVBOXDISPDEV pDev, VBVAHOSTCMD RT_UNTRUSTED_VOLATILE_HOST *pCmd);
|
---|
147 |
|
---|
148 | void vrdpReportDirtyRect(PVBOXDISPDEV pDev, RECTL *prcl);
|
---|
149 | void vbvaReportDirtyRect(PVBOXDISPDEV pDev, RECTL *prcl);
|
---|
150 |
|
---|
151 | #ifdef VBOX_VBVA_ADJUST_RECT
|
---|
152 | void vrdpAdjustRect (SURFOBJ *pso, RECTL *prcl);
|
---|
153 | BOOL vbvaFindChangedRect(SURFOBJ *psoDest, SURFOBJ *psoSrc, RECTL *prclDest, POINTL *pptlSrc);
|
---|
154 | #endif /* VBOX_VBVA_ADJUST_RECT */
|
---|
155 |
|
---|
156 | #define VRDP_TEXT_MAX_GLYPH_SIZE 0x100
|
---|
157 | #define VRDP_TEXT_MAX_GLYPHS 0xfe
|
---|
158 | BOOL vrdpReportText(PVBOXDISPDEV pDev, VRDPCLIPRECTS *pClipRects, STROBJ *pstro, FONTOBJ *pfo,
|
---|
159 | RECTL *prclOpaque, ULONG ulForeRGB, ULONG ulBackRGB);
|
---|
160 |
|
---|
161 | BOOL vrdpReportOrderGeneric(PVBOXDISPDEV pDev, const VRDPCLIPRECTS *pClipRects,
|
---|
162 | const void *pvOrder, unsigned cbOrder, unsigned code);
|
---|
163 |
|
---|
164 | BOOL VBoxDispIsScreenSurface(SURFOBJ *pso);
|
---|
165 | void VBoxDispDumpPSO(SURFOBJ *pso, const char *s);
|
---|
166 |
|
---|
167 | BOOL vrdpDrvRealizeBrush(BRUSHOBJ *pbo, SURFOBJ *psoTarget, SURFOBJ *psoPattern, SURFOBJ *psoMask,
|
---|
168 | XLATEOBJ *pxlo, ULONG iHatch);
|
---|
169 | void vrdpReset(PVBOXDISPDEV pDev);
|
---|
170 |
|
---|
171 | DECLINLINE(int) format2BytesPerPixel(const SURFOBJ *pso)
|
---|
172 | {
|
---|
173 | switch (pso->iBitmapFormat)
|
---|
174 | {
|
---|
175 | case BMF_16BPP: return 2;
|
---|
176 | case BMF_24BPP: return 3;
|
---|
177 | case BMF_32BPP: return 4;
|
---|
178 | }
|
---|
179 |
|
---|
180 | return 0;
|
---|
181 | }
|
---|
182 |
|
---|
183 | #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_xpdm_VBoxDispInternal_h */
|
---|