mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 573229: Part 2 - Enable D2D by default on DX 10 hardware. r=jrmuizel
This commit is contained in:
parent
37823092aa
commit
bd638f486d
@ -76,6 +76,8 @@
|
||||
#ifdef CAIRO_HAS_D2D_SURFACE
|
||||
#include "gfxD2DSurface.h"
|
||||
|
||||
#include <d3d10_1.h>
|
||||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
@ -135,6 +137,18 @@ typedef HRESULT (WINAPI*DWriteCreateFactoryFunc)(
|
||||
__out IUnknown **factory
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef CAIRO_HAS_D2D_SURFACE
|
||||
typedef HRESULT (WINAPI*D3D10CreateDevice1Func)(
|
||||
IDXGIAdapter *pAdapter,
|
||||
D3D10_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
D3D10_FEATURE_LEVEL1 HardwareLevel,
|
||||
UINT SDKVersion,
|
||||
ID3D10Device1 **ppDevice
|
||||
);
|
||||
#endif
|
||||
|
||||
static __inline void
|
||||
BuildKeyNameFromFontName(nsAString &aName)
|
||||
@ -167,11 +181,65 @@ gfxWindowsPlatform::gfxWindowsPlatform()
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPrefBranch2> pref = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
|
||||
OSVERSIONINFOA versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
||||
::GetVersionExA(&versionInfo);
|
||||
bool isVistaOrHigher = versionInfo.dwMajorVersion >= 6;
|
||||
|
||||
#ifdef CAIRO_HAS_D2D_SURFACE
|
||||
NS_RegisterMemoryReporter(new D2DCacheReporter());
|
||||
mD2DDevice = NULL;
|
||||
|
||||
if (isVistaOrHigher) {
|
||||
// We need a DWriteFactory to work.
|
||||
HMODULE d3d10module = LoadLibraryA("d3d10_1.dll");
|
||||
D3D10CreateDevice1Func createD3DDevice = (D3D10CreateDevice1Func)
|
||||
GetProcAddress(d3d10module, "D3D10CreateDevice1");
|
||||
nsRefPtr<ID3D10Device1> device;
|
||||
|
||||
if (createD3DDevice) {
|
||||
// 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,
|
||||
D3D10_DRIVER_TYPE_HARDWARE,
|
||||
NULL,
|
||||
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
|
||||
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
|
||||
D3D10_FEATURE_LEVEL_10_0,
|
||||
D3D10_1_SDK_VERSION,
|
||||
getter_AddRefs(device));
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
// We have 10.0, let's try 10.1.
|
||||
// XXX - This adds an additional 10-20ms for people who are
|
||||
// getting direct2d. We'd really like to do something more
|
||||
// clever.
|
||||
nsRefPtr<ID3D10Device1> device1;
|
||||
hr = createD3DDevice(
|
||||
NULL,
|
||||
D3D10_DRIVER_TYPE_HARDWARE,
|
||||
NULL,
|
||||
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
|
||||
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
|
||||
D3D10_FEATURE_LEVEL_10_1,
|
||||
D3D10_1_SDK_VERSION,
|
||||
getter_AddRefs(device1));
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
device = device1;
|
||||
}
|
||||
|
||||
mD2DDevice = cairo_d2d_create_device_from_d3d10device(device);
|
||||
if (mD2DDevice) {
|
||||
mRenderMode = RENDER_DIRECT2D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
nsresult rv;
|
||||
PRBool useDirectWrite = PR_FALSE;
|
||||
@ -181,8 +249,10 @@ gfxWindowsPlatform::gfxWindowsPlatform()
|
||||
if (NS_FAILED(rv)) {
|
||||
useDirectWrite = PR_FALSE;
|
||||
}
|
||||
|
||||
if (useDirectWrite) {
|
||||
|
||||
// Enable when it's preffed on -and- we're using Vista or higher. Or when
|
||||
// we're going to use D2D.
|
||||
if ((useDirectWrite && isVistaOrHigher) || mRenderMode == RENDER_DIRECT2D) {
|
||||
DWriteCreateFactoryFunc createDWriteFactory = (DWriteCreateFactoryFunc)
|
||||
GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory");
|
||||
|
||||
@ -214,9 +284,11 @@ gfxWindowsPlatform::gfxWindowsPlatform()
|
||||
#ifndef CAIRO_HAS_D2D_SURFACE
|
||||
return;
|
||||
#else
|
||||
mD2DDevice = cairo_d2d_create_device();
|
||||
if (!mD2DDevice) {
|
||||
return;
|
||||
mD2DDevice = cairo_d2d_create_device();
|
||||
if (!mD2DDevice) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
if (!GetDWriteFactory()) {
|
||||
|
Loading…
Reference in New Issue
Block a user