VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispMpTst.cpp@ 31828

Last change on this file since 31828 was 30515, checked in by vboxsync, 14 years ago

wddm/3d: visible regions tracking optimizations & fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/** @file
2 *
3 * VBoxVideo Display D3D User mode dll
4 *
5 * Copyright (C) 2010 Oracle Corporation
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License (GPL) as published by the Free Software
11 * Foundation, in version 2 as it comes in the "COPYING" file of the
12 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14 */
15#include "VBoxDispMp.h"
16
17#include <iprt/thread.h>
18
19#include "VBoxDispD3DCmn.h"
20
21static RTTHREAD g_VBoxDispMpTstThread;
22static VBOXDISPMP_CALLBACKS g_VBoxDispMpTstCallbacks;
23static HMODULE g_hVBoxDispMpModule;
24static PFNVBOXDISPMP_GETCALLBACKS g_pfnVBoxDispMpGetCallbacks;
25
26
27static void vboxDispMpTstLogRect(const char * pPrefix, RECT *pRect, const char * pSuffix)
28{
29 vboxVDbgPrint(("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix));
30}
31
32static DECLCALLBACK(int) vboxDispMpTstThreadProc(RTTHREAD ThreadSelf, void *pvUser)
33{
34 VBOXDISPMP_REGIONS Regions;
35
36 HRESULT hr = g_VBoxDispMpTstCallbacks.pfnEnableEvents();
37 Assert(hr == S_OK);
38 if (hr != S_OK)
39 return VERR_GENERAL_FAILURE;
40
41 do
42 {
43 hr = g_VBoxDispMpTstCallbacks.pfnGetRegions(&Regions, INFINITE);
44 Assert(hr == S_OK);
45 if (hr == S_OK)
46 {
47 vboxVDbgPrint(("\n>>>\n"));
48 HWND hWnd = Regions.hWnd;
49 if (Regions.pRegions->fFlags.bSetVisibleRects)
50 {
51 uint32_t iVisibleRects = 0;
52 uint32_t cVisibleRects = Regions.pRegions->RectsInfo.cRects;
53 if (Regions.pRegions->fFlags.bSetViewRect)
54 {
55 iVisibleRects = 1;
56
57 vboxVDbgPrint(("hWnd (0x%p), position and/or size changed: ", hWnd));
58 vboxDispMpTstLogRect("", Regions.pRegions->RectsInfo.aRects, "\n");
59 }
60
61 vboxVDbgPrint(("hWnd (0x%p), visibleRects: \n", hWnd));
62 for (uint32_t i = iVisibleRects; i < cVisibleRects; ++i)
63 {
64 vboxDispMpTstLogRect("", &Regions.pRegions->RectsInfo.aRects[i], "");
65 }
66 }
67 else if (Regions.pRegions->fFlags.bAddHiddenRects)
68 {
69 vboxVDbgPrint(("hWnd (0x%p), hiddenRects: \n", hWnd));
70 for (uint32_t i = 0; i < Regions.pRegions->RectsInfo.cRects; ++i)
71 {
72 vboxDispMpTstLogRect("", &Regions.pRegions->RectsInfo.aRects[i], "");
73 }
74 }
75
76 vboxVDbgPrint(("\n<<<\n"));
77 }
78 } while (1);
79
80 hr = g_VBoxDispMpTstCallbacks.pfnDisableEvents();
81 Assert(hr == S_OK);
82
83 return VINF_SUCCESS;
84}
85
86HRESULT vboxDispMpTstStart()
87{
88 HRESULT hr = E_FAIL;
89 g_hVBoxDispMpModule = GetModuleHandleW(L"VBoxDispD3D.dll");
90 Assert(g_hVBoxDispMpModule);
91
92 if (g_hVBoxDispMpModule)
93 {
94 g_pfnVBoxDispMpGetCallbacks = (PFNVBOXDISPMP_GETCALLBACKS)GetProcAddress(g_hVBoxDispMpModule, "VBoxDispMpGetCallbacks");
95 Assert(g_pfnVBoxDispMpGetCallbacks);
96 if (g_pfnVBoxDispMpGetCallbacks)
97 {
98 hr = g_pfnVBoxDispMpGetCallbacks(VBOXDISPMP_VERSION, &g_VBoxDispMpTstCallbacks);
99 Assert(hr == S_OK);
100 if (hr == S_OK)
101 {
102 int rc = RTThreadCreate(&g_VBoxDispMpTstThread, vboxDispMpTstThreadProc, NULL, 0,
103 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "VBoxDispMpTst");
104 AssertRC(rc);
105 if (RT_SUCCESS(rc))
106 return S_OK;
107
108 hr = E_FAIL;
109 }
110 }
111 FreeLibrary(g_hVBoxDispMpModule);
112 }
113
114 return hr;
115}
116
117HRESULT vboxDispMpTstStop()
118{
119 HRESULT hr = g_VBoxDispMpTstCallbacks.pfnDisableEvents();
120 Assert(hr == S_OK);
121#if 0
122 if (hr == S_OK)
123 {
124 int rc = RTThreadWaitNoResume(g_VBoxDispMpTstThread, RT_INDEFINITE_WAIT, NULL);
125 AssertRC(rc);
126 if (RT_SUCCESS(rc))
127 {
128 BOOL bResult = FreeLibrary(g_hVBoxDispMpModule);
129 Assert(bResult);
130#ifdef DEBUG
131 if (!bResult)
132 {
133 DWORD winEr = GetLastError();
134 hr = HRESULT_FROM_WIN32(winEr);
135 }
136#endif
137 }
138 else
139 hr = E_FAIL;
140 }
141#endif
142 return hr;
143}
144
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette