Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/native/sun/java2d/d3d/D3DPipelineManager.h
32288 views
/*1* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24#pragma once2526#include "D3DPipeline.h"27#include "D3DContext.h"28#include "awt_Toolkit.h"2930typedef class D3DPipelineManager *LPD3DPIPELINEMANAGER;3132typedef struct D3DAdapter33{34D3DContext *pd3dContext;35DWORD state;36HWND fsFocusWindow;37} D3DAdapter;3839class D3DPIPELINE_API D3DPipelineManager40{41friend class D3DInitializer;42private:43// creates and initializes instance of D3DPipelineManager, may return NULL44static D3DPipelineManager* CreateInstance(void);4546// deletes the single instance of the manager47static void DeleteInstance();4849public:50// returns the single instance of the manager, may return NULL51static D3DPipelineManager* GetInstance(void);5253HRESULT GetD3DContext(UINT adapterOrdinal, D3DContext **ppd3dContext);5455HRESULT HandleLostDevices();56// Checks if adapters were added or removed, or if the order had changed57// (which may happen with primary display is changed). If that's the case58// releases current adapters and d3d9 instance, reinitializes the pipeline.59// @param *monHds list of monitor handles retrieved from GDI60// @param monNum number of gdi monitors61static62HRESULT HandleAdaptersChange(HMONITOR *monHds, UINT monNum);63// returns depth stencil buffer format matching adapterFormat and render target64// format for the device specified by adapterOrdinal/devType65D3DFORMAT GetMatchingDepthStencilFormat(UINT adapterOrdinal,66D3DFORMAT adapterFormat,67D3DFORMAT renderTargetFormat);6869HWND GetCurrentFocusWindow();70// returns previous fs window71HWND SetFSFocusWindow(UINT, HWND);7273LPDIRECT3D9 GetD3DObject() { return pd3d9; }74D3DDEVTYPE GetDeviceType() { return devType; }7576// returns the d3d adapter ordinal given GDI screen number:77// these may differ depending on which display is primary78UINT GetAdapterOrdinalForScreen(jint gdiScreen);7980// notifies adapter event listeners by calling81// AccelDeviceEventNotifier.eventOccured()82static83void NotifyAdapterEventListeners(UINT adapter, jint eventType);8485private:86D3DPipelineManager(void);87~D3DPipelineManager(void);8889// Creates a Direct3D9 object and initializes adapters.90HRESULT InitD3D(void);91// Releases adapters, Direct3D9 object and the d3d9 library.92HRESULT ReleaseD3D();9394// selects the device type based on user input and available95// device types96D3DDEVTYPE SelectDeviceType();9798// creates array of adapters (releases the old one first)99HRESULT InitAdapters();100// releases each adapter's context, and then releases the array101HRESULT ReleaseAdapters();102103HWND CreateDefaultFocusWindow();104// returns S_OK if the adapter is capable of running the Direct3D105// pipeline106HRESULT D3DEnabledOnAdapter(UINT Adapter);107// returns adapterOrdinal given a HMONITOR handle108UINT GetAdapterOrdinalByHmon(HMONITOR hMon);109HRESULT CheckAdaptersInfo();110HRESULT CheckDeviceCaps(UINT Adapter);111// Check the OS, succeeds if the OS is XP or newer client-class OS112static HRESULT CheckOSVersion();113// used to check attached adapters using GDI against known bad hw database114// prior to the instantiation of the pipeline manager115static HRESULT GDICheckForBadHardware();116// given VendorId, DeviceId and driver version, checks against a database117// of known bad hardware/driver combinations.118// If the driver version is not known MAX_VERSION can be used119// which is guaranteed to satisfy the check120static HRESULT CheckForBadHardware(DWORD vId, DWORD dId, LONGLONG version);121122private:123124// current adapter count125UINT adapterCount;126// Pointer to Direct3D9 Object mainained by the pipeline manager127LPDIRECT3D9 pd3d9;128// d3d9.dll lib129HINSTANCE hLibD3D9;130131int currentFSFocusAdapter;132HWND defaultFocusWindow;133134D3DDEVTYPE devType;135136D3DAdapter *pAdapters;137// instance of this object138static LPD3DPIPELINEMANAGER pMgr;139};140141#define OS_UNDEFINED (0 << 0)142#define OS_VISTA (1 << 0)143#define OS_WINSERV_2008 (1 << 1)144#define OS_WINXP (1 << 2)145#define OS_WINXP_64 (1 << 3)146#define OS_WINSERV_2003 (1 << 4)147#define OS_WINDOWS7 (1 << 5)148#define OS_WINSERV_2008R2 (1 << 6)149#define OS_ALL (OS_VISTA|OS_WINSERV_2008|OS_WINXP|OS_WINXP_64|OS_WINSERV_2003|\150OS_WINDOWS7|OS_WINSERV_2008R2)151#define OS_UNKNOWN (~OS_ALL)152BOOL D3DPPLM_OsVersionMatches(USHORT osInfo);153154155class D3DInitializer : public AwtToolkit::PreloadAction {156private:157D3DInitializer();158~D3DInitializer();159160protected:161// PreloadAction overrides162virtual void InitImpl();163virtual void CleanImpl(bool reInit);164165public:166static D3DInitializer& GetInstance() { return theInstance; }167168private:169// single instance170static D3DInitializer theInstance;171172// adapter initializer class173class D3DAdapterInitializer : public AwtToolkit::PreloadAction {174public:175void setAdapter(UINT adapter) { this->adapter = adapter; }176protected:177// PreloadAction overrides178virtual void InitImpl();179virtual void CleanImpl(bool reInit);180private:181UINT adapter;182};183184// the flag indicates success of COM initialization185bool bComInitialized;186D3DAdapterInitializer *pAdapterIniters;187188};189190191192