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 |
|
---|
21 | static RTTHREAD g_VBoxDispMpTstThread;
|
---|
22 |
|
---|
23 | static void vboxDispMpTstLogRect(const char * pPrefix, RECT *pRect, const char * pSuffix)
|
---|
24 | {
|
---|
25 | vboxVDbgDoPrint("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix);
|
---|
26 | }
|
---|
27 |
|
---|
28 | static DECLCALLBACK(int) vboxDispMpTstThreadProc(RTTHREAD ThreadSelf, void *pvUser)
|
---|
29 | {
|
---|
30 | VBOXDISPMP_REGIONS Regions;
|
---|
31 |
|
---|
32 | HRESULT hr;
|
---|
33 | do
|
---|
34 | {
|
---|
35 | hr = vboxDispMpGetRegions(&Regions, INFINITE);
|
---|
36 | Assert(hr == S_OK);
|
---|
37 | if (hr == S_OK)
|
---|
38 | {
|
---|
39 | vboxVDbgDoPrint("\n>>>\n");
|
---|
40 | HWND hWnd = Regions.hWnd;
|
---|
41 | if (Regions.pRegions->fFlags.bAddVisibleRects)
|
---|
42 | {
|
---|
43 | uint32_t iVisibleRects = 0;
|
---|
44 | uint32_t cVidibleRects = Regions.pRegions->RectsInfo.cRects;
|
---|
45 | if (Regions.pRegions->fFlags.bPositionRect)
|
---|
46 | {
|
---|
47 | iVisibleRects = 1;
|
---|
48 | --cVidibleRects;
|
---|
49 |
|
---|
50 | vboxVDbgDoPrint("hWnd (0x%p), position and/or size changed: ", hWnd);
|
---|
51 | vboxDispMpTstLogRect("", Regions.pRegions->RectsInfo.aRects, "\n");
|
---|
52 | }
|
---|
53 |
|
---|
54 | vboxVDbgDoPrint("hWnd (0x%p), visibleRects: \n", hWnd);
|
---|
55 | for (uint32_t i = iVisibleRects; i < cVidibleRects; ++i)
|
---|
56 | {
|
---|
57 | vboxDispMpTstLogRect("", &Regions.pRegions->RectsInfo.aRects[i], "");
|
---|
58 | }
|
---|
59 | }
|
---|
60 | else if (Regions.pRegions->fFlags.bAddHiddenRects)
|
---|
61 | {
|
---|
62 | vboxVDbgDoPrint("hWnd (0x%p), hiddenRects: \n", hWnd);
|
---|
63 | for (uint32_t i = 0; i < Regions.pRegions->RectsInfo.cRects; ++i)
|
---|
64 | {
|
---|
65 | vboxDispMpTstLogRect("", &Regions.pRegions->RectsInfo.aRects[i], "");
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | vboxVDbgDoPrint("\n<<<\n");
|
---|
70 | }
|
---|
71 | } while (1);
|
---|
72 | return VINF_SUCCESS;
|
---|
73 | }
|
---|
74 |
|
---|
75 | HRESULT vboxDispMpTstStart()
|
---|
76 | {
|
---|
77 | HRESULT hr = vboxDispMpEnable();
|
---|
78 | Assert(hr == S_OK);
|
---|
79 | if (hr == S_OK)
|
---|
80 | {
|
---|
81 | int rc = RTThreadCreate(&g_VBoxDispMpTstThread, vboxDispMpTstThreadProc, NULL, 0,
|
---|
82 | RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "VBoxDispMpTst");
|
---|
83 | AssertRC(rc);
|
---|
84 | if (RT_SUCCESS(rc))
|
---|
85 | return S_OK;
|
---|
86 |
|
---|
87 | hr = vboxDispMpDisable();
|
---|
88 | Assert(hr == S_OK);
|
---|
89 | hr = E_FAIL;
|
---|
90 | }
|
---|
91 | return hr;
|
---|
92 | }
|
---|
93 |
|
---|
94 | HRESULT vboxDispMpTstStop()
|
---|
95 | {
|
---|
96 | HRESULT hr = vboxDispMpDisable();
|
---|
97 | Assert(hr == S_OK);
|
---|
98 | if (hr == S_OK)
|
---|
99 | {
|
---|
100 | int rc = RTThreadWaitNoResume(g_VBoxDispMpTstThread, RT_INDEFINITE_WAIT, NULL);
|
---|
101 | AssertRC(rc);
|
---|
102 | }
|
---|
103 | return hr;
|
---|
104 | }
|
---|
105 |
|
---|