Bug 648484, part 5: Create our D3D10 device so as to allow cross-process resource sharing. r=Bas

This commit is contained in:
Chris Jones 2011-07-06 13:29:26 -04:00
parent 61d03418ec
commit dc8f49c9a6

View File

@ -79,6 +79,7 @@ using namespace mozilla::gfx;
#include "gfxD2DSurface.h"
#include <d3d10_1.h>
#include <dxgi.h>
#include "mozilla/gfx/2D.h"
@ -152,6 +153,11 @@ typedef HRESULT (WINAPI*D3D10CreateDevice1Func)(
UINT SDKVersion,
ID3D10Device1 **ppDevice
);
typedef HRESULT(WINAPI*CreateDXGIFactory1Func)(
REFIID riid,
void **ppFactory
);
#endif
static __inline void
@ -318,10 +324,34 @@ gfxWindowsPlatform::VerifyD2DDevice(PRBool aAttemptForce)
nsRefPtr<ID3D10Device1> device;
if (createD3DDevice) {
HMODULE dxgiModule = LoadLibraryA("dxgi.dll");
CreateDXGIFactory1Func createDXGIFactory1 = (CreateDXGIFactory1Func)
GetProcAddress(dxgiModule, "CreateDXGIFactory1");
// Try to use a DXGI 1.1 adapter in order to share resources
// across processes.
nsRefPtr<IDXGIAdapter1> adapter1;
if (createDXGIFactory1) {
nsRefPtr<IDXGIFactory1> factory1;
HRESULT hr = createDXGIFactory1(__uuidof(IDXGIFactory1),
getter_AddRefs(factory1));
nsRefPtr<IDXGIAdapter1> adapter1;
hr = factory1->EnumAdapters1(0, getter_AddRefs(adapter1));
if (SUCCEEDED(hr) && adapter1) {
hr = adapter1->CheckInterfaceSupport(__uuidof(ID3D10Device1),
nsnull);
if (FAILED(hr)) {
adapter1 = nsnull;
}
}
}
// We try 10.0 first even though we prefer 10.1, since we want to
// fail as fast as possible if 10.x isn't supported.
HRESULT hr = createD3DDevice(
NULL,
adapter1,
D3D10_DRIVER_TYPE_HARDWARE,
NULL,
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
@ -337,7 +367,7 @@ gfxWindowsPlatform::VerifyD2DDevice(PRBool aAttemptForce)
// clever.
nsRefPtr<ID3D10Device1> device1;
hr = createD3DDevice(
NULL,
adapter1,
D3D10_DRIVER_TYPE_HARDWARE,
NULL,
D3D10_CREATE_DEVICE_BGRA_SUPPORT |