Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.h
41159 views
1
/*
2
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
#pragma once
26
27
#include "D3DPipeline.h"
28
#include "D3DContext.h"
29
#include "awt_Toolkit.h"
30
31
typedef class D3DPipelineManager *LPD3DPIPELINEMANAGER;
32
33
typedef struct D3DAdapter
34
{
35
D3DContext *pd3dContext;
36
DWORD state;
37
HWND fsFocusWindow;
38
} D3DAdapter;
39
40
class D3DPIPELINE_API D3DPipelineManager
41
{
42
friend class D3DInitializer;
43
private:
44
// creates and initializes instance of D3DPipelineManager, may return NULL
45
static D3DPipelineManager* CreateInstance(void);
46
47
// deletes the single instance of the manager
48
static void DeleteInstance();
49
50
public:
51
// returns the single instance of the manager, may return NULL
52
static D3DPipelineManager* GetInstance(void);
53
54
HRESULT GetD3DContext(UINT adapterOrdinal, D3DContext **ppd3dContext);
55
56
HRESULT HandleLostDevices();
57
// Checks if adapters were added or removed, or if the order had changed
58
// (which may happen with primary display is changed). If that's the case
59
// releases current adapters and d3d9 instance, reinitializes the pipeline.
60
// @param *monHds list of monitor handles retrieved from GDI
61
// @param monNum number of gdi monitors
62
static
63
HRESULT HandleAdaptersChange(HMONITOR *monHds, UINT monNum);
64
// returns depth stencil buffer format matching adapterFormat and render target
65
// format for the device specified by adapterOrdinal/devType
66
D3DFORMAT GetMatchingDepthStencilFormat(UINT adapterOrdinal,
67
D3DFORMAT adapterFormat,
68
D3DFORMAT renderTargetFormat);
69
70
HWND GetCurrentFocusWindow();
71
// returns previous fs window
72
HWND SetFSFocusWindow(UINT, HWND);
73
74
LPDIRECT3D9 GetD3DObject() { return pd3d9; }
75
D3DDEVTYPE GetDeviceType() { return devType; }
76
77
// returns the d3d adapter ordinal given GDI screen number:
78
// these may differ depending on which display is primary
79
UINT GetAdapterOrdinalForScreen(jint gdiScreen);
80
81
private:
82
D3DPipelineManager(void);
83
~D3DPipelineManager(void);
84
85
// Creates a Direct3D9 object and initializes adapters.
86
HRESULT InitD3D(void);
87
// Releases adapters, Direct3D9 object and the d3d9 library.
88
HRESULT ReleaseD3D();
89
90
// selects the device type based on user input and available
91
// device types
92
D3DDEVTYPE SelectDeviceType();
93
94
// creates array of adapters (releases the old one first)
95
HRESULT InitAdapters();
96
// releases each adapter's context, and then releases the array
97
HRESULT ReleaseAdapters();
98
99
HWND CreateDefaultFocusWindow();
100
// returns S_OK if the adapter is capable of running the Direct3D
101
// pipeline
102
HRESULT D3DEnabledOnAdapter(UINT Adapter);
103
// returns adapterOrdinal given a HMONITOR handle
104
UINT GetAdapterOrdinalByHmon(HMONITOR hMon);
105
HRESULT CheckAdaptersInfo();
106
HRESULT CheckDeviceCaps(UINT Adapter);
107
// Check the OS, succeeds if the OS is XP or newer client-class OS
108
static HRESULT CheckOSVersion();
109
// used to check attached adapters using GDI against known bad hw database
110
// prior to the instantiation of the pipeline manager
111
static HRESULT GDICheckForBadHardware();
112
// given VendorId, DeviceId and driver version, checks against a database
113
// of known bad hardware/driver combinations.
114
// If the driver version is not known MAX_VERSION can be used
115
// which is guaranteed to satisfy the check
116
static HRESULT CheckForBadHardware(DWORD vId, DWORD dId, LONGLONG version);
117
118
private:
119
120
// current adapter count
121
UINT adapterCount;
122
// Pointer to Direct3D9 Object mainained by the pipeline manager
123
LPDIRECT3D9 pd3d9;
124
// d3d9.dll lib
125
HINSTANCE hLibD3D9;
126
127
int currentFSFocusAdapter;
128
HWND defaultFocusWindow;
129
130
D3DDEVTYPE devType;
131
132
D3DAdapter *pAdapters;
133
// instance of this object
134
static LPD3DPIPELINEMANAGER pMgr;
135
};
136
137
#define OS_UNDEFINED (0 << 0)
138
#define OS_VISTA (1 << 0)
139
#define OS_WINSERV_2008 (1 << 1)
140
#define OS_WINXP (1 << 2)
141
#define OS_WINXP_64 (1 << 3)
142
#define OS_WINSERV_2003 (1 << 4)
143
#define OS_WINDOWS7 (1 << 5)
144
#define OS_WINSERV_2008R2 (1 << 6)
145
#define OS_ALL (OS_VISTA|OS_WINSERV_2008|OS_WINXP|OS_WINXP_64|OS_WINSERV_2003|\
146
OS_WINDOWS7|OS_WINSERV_2008R2)
147
#define OS_UNKNOWN (~OS_ALL)
148
BOOL D3DPPLM_OsVersionMatches(USHORT osInfo);
149
150
151
class D3DInitializer : public AwtToolkit::PreloadAction {
152
private:
153
D3DInitializer();
154
~D3DInitializer();
155
156
protected:
157
// PreloadAction overrides
158
virtual void InitImpl();
159
virtual void CleanImpl(bool reInit);
160
161
public:
162
static D3DInitializer& GetInstance() { return theInstance; }
163
164
private:
165
// single instance
166
static D3DInitializer theInstance;
167
168
// adapter initializer class
169
class D3DAdapterInitializer : public AwtToolkit::PreloadAction {
170
public:
171
void setAdapter(UINT adapter) { this->adapter = adapter; }
172
protected:
173
// PreloadAction overrides
174
virtual void InitImpl();
175
virtual void CleanImpl(bool reInit);
176
private:
177
UINT adapter;
178
};
179
180
// the flag indicates success of COM initialization
181
bool bComInitialized;
182
D3DAdapterInitializer *pAdapterIniters;
183
184
};
185
186
187