2006-02-01 02:35:38 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-02-01 02:35:38 +00:00
|
|
|
|
|
|
|
#ifndef GFX_WINDOWS_PLATFORM_H
|
|
|
|
#define GFX_WINDOWS_PLATFORM_H
|
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-21 13:47:32 +00:00
|
|
|
* XXX to get CAIRO_HAS_D2D_SURFACE, CAIRO_HAS_DWRITE_FONT
|
|
|
|
* and cairo_win32_scaled_font_select_font
|
2010-02-26 06:36:07 +00:00
|
|
|
*/
|
2011-02-21 13:47:32 +00:00
|
|
|
#include "cairo-win32.h"
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2008-04-04 02:01:22 +00:00
|
|
|
#include "gfxFontUtils.h"
|
2006-02-15 02:48:08 +00:00
|
|
|
#include "gfxWindowsSurface.h"
|
2010-03-17 11:40:29 +00:00
|
|
|
#include "gfxFont.h"
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
|
|
|
#include "gfxDWriteFonts.h"
|
|
|
|
#endif
|
2006-02-01 02:35:38 +00:00
|
|
|
#include "gfxPlatform.h"
|
2015-07-19 21:50:35 +00:00
|
|
|
#include "gfxTelemetry.h"
|
2014-11-10 21:41:40 +00:00
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
2015-01-28 01:09:34 +00:00
|
|
|
#include "mozilla/Atomics.h"
|
2009-01-18 20:14:14 +00:00
|
|
|
#include "nsTArray.h"
|
2006-06-10 00:21:05 +00:00
|
|
|
#include "nsDataHashtable.h"
|
2006-02-15 02:48:08 +00:00
|
|
|
|
2013-05-01 14:27:09 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
|
2006-02-24 05:15:21 +00:00
|
|
|
#include <windows.h>
|
2010-08-26 22:26:47 +00:00
|
|
|
#include <objbase.h>
|
2006-02-24 05:15:21 +00:00
|
|
|
|
2013-03-22 19:32:56 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
#include <dxgi.h>
|
|
|
|
#endif
|
|
|
|
|
2013-05-10 13:26:10 +00:00
|
|
|
// This header is available in the June 2010 SDK and in the Win8 SDK
|
|
|
|
#include <d3dcommon.h>
|
2013-05-09 15:32:50 +00:00
|
|
|
// Win 8.0 SDK types we'll need when building using older sdks.
|
2013-05-10 13:26:10 +00:00
|
|
|
#if !defined(D3D_FEATURE_LEVEL_11_1) // defined in the 8.0 SDK only
|
2013-05-09 15:32:50 +00:00
|
|
|
#define D3D_FEATURE_LEVEL_11_1 static_cast<D3D_FEATURE_LEVEL>(0xb100)
|
|
|
|
#define D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION 2048
|
|
|
|
#define D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION 4096
|
|
|
|
#endif
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
namespace mozilla {
|
2014-11-10 21:41:40 +00:00
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
namespace layers {
|
|
|
|
class DeviceManagerD3D9;
|
2014-07-30 13:38:46 +00:00
|
|
|
class ReadbackManagerD3D11;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-19 00:57:51 +00:00
|
|
|
struct IDirect3DDevice9;
|
|
|
|
struct ID3D11Device;
|
|
|
|
struct IDXGIAdapter1;
|
2013-05-01 14:27:09 +00:00
|
|
|
|
2014-11-10 21:41:40 +00:00
|
|
|
/**
|
|
|
|
* Utility to get a Windows HDC from a Moz2D DrawTarget. If the DrawTarget is
|
|
|
|
* not backed by a HDC this will get the HDC for the screen device context
|
|
|
|
* instead.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class MOZ_STACK_CLASS DCFromDrawTarget final
|
2014-11-10 21:41:40 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DCFromDrawTarget(mozilla::gfx::DrawTarget& aDrawTarget);
|
2010-03-15 09:34:25 +00:00
|
|
|
|
2014-11-10 21:41:40 +00:00
|
|
|
~DCFromDrawTarget() {
|
|
|
|
if (mNeedsRelease) {
|
|
|
|
ReleaseDC(nullptr, mDC);
|
2011-02-19 20:48:33 +00:00
|
|
|
} else {
|
2014-11-10 21:41:40 +00:00
|
|
|
RestoreDC(mDC, -1);
|
2011-02-19 20:48:33 +00:00
|
|
|
}
|
2010-03-15 09:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
operator HDC () {
|
2014-11-10 21:41:40 +00:00
|
|
|
return mDC;
|
2010-03-15 09:34:25 +00:00
|
|
|
}
|
|
|
|
|
2014-11-10 21:41:40 +00:00
|
|
|
private:
|
|
|
|
HDC mDC;
|
|
|
|
bool mNeedsRelease;
|
2010-03-15 09:34:25 +00:00
|
|
|
};
|
|
|
|
|
2011-05-11 00:30:20 +00:00
|
|
|
// ClearType parameters set by running ClearType tuner
|
|
|
|
struct ClearTypeParameterInfo {
|
|
|
|
ClearTypeParameterInfo() :
|
|
|
|
gamma(-1), pixelStructure(-1), clearTypeLevel(-1), enhancedContrast(-1)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
nsString displayName; // typically just 'DISPLAY1'
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t gamma;
|
|
|
|
int32_t pixelStructure;
|
|
|
|
int32_t clearTypeLevel;
|
|
|
|
int32_t enhancedContrast;
|
2011-05-11 00:30:20 +00:00
|
|
|
};
|
|
|
|
|
2013-05-29 21:59:24 +00:00
|
|
|
class gfxWindowsPlatform : public gfxPlatform {
|
2006-02-01 02:35:38 +00:00
|
|
|
public:
|
2012-03-19 19:20:18 +00:00
|
|
|
enum TextRenderingMode {
|
|
|
|
TEXT_RENDERING_NO_CLEARTYPE,
|
|
|
|
TEXT_RENDERING_NORMAL,
|
|
|
|
TEXT_RENDERING_GDI_CLASSIC,
|
|
|
|
TEXT_RENDERING_COUNT
|
|
|
|
};
|
|
|
|
|
2006-02-01 02:35:38 +00:00
|
|
|
gfxWindowsPlatform();
|
2006-02-24 05:15:21 +00:00
|
|
|
virtual ~gfxWindowsPlatform();
|
2006-02-01 02:35:38 +00:00
|
|
|
static gfxWindowsPlatform *GetPlatform() {
|
|
|
|
return (gfxWindowsPlatform*) gfxPlatform::GetPlatform();
|
|
|
|
}
|
|
|
|
|
2009-10-07 14:13:40 +00:00
|
|
|
virtual gfxPlatformFontList* CreatePlatformFontList();
|
|
|
|
|
2014-02-09 08:04:38 +00:00
|
|
|
virtual already_AddRefed<gfxASurface>
|
2015-07-07 01:21:47 +00:00
|
|
|
CreateOffscreenSurface(const IntSize& aSize,
|
|
|
|
gfxImageFormat aFormat) override;
|
2012-06-26 02:43:31 +00:00
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
2012-07-24 10:18:37 +00:00
|
|
|
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
|
2006-02-01 02:35:38 +00:00
|
|
|
|
2009-07-08 23:34:02 +00:00
|
|
|
enum RenderMode {
|
|
|
|
/* Use GDI and windows surfaces */
|
|
|
|
RENDER_GDI = 0,
|
|
|
|
|
|
|
|
/* Use 32bpp image surfaces and call StretchDIBits */
|
|
|
|
RENDER_IMAGE_STRETCH32,
|
|
|
|
|
|
|
|
/* Use 32bpp image surfaces, and do 32->24 conversion before calling StretchDIBits */
|
|
|
|
RENDER_IMAGE_STRETCH24,
|
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/* Use Direct2D rendering */
|
|
|
|
RENDER_DIRECT2D,
|
|
|
|
|
2009-07-08 23:34:02 +00:00
|
|
|
/* max */
|
|
|
|
RENDER_MODE_MAX
|
|
|
|
};
|
|
|
|
|
2015-09-11 18:21:56 +00:00
|
|
|
int GetScreenDepth() const;
|
|
|
|
|
2009-07-08 23:34:02 +00:00
|
|
|
RenderMode GetRenderMode() { return mRenderMode; }
|
|
|
|
void SetRenderMode(RenderMode rmode) { mRenderMode = rmode; }
|
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
/**
|
|
|
|
* Updates render mode with relation to the current preferences and
|
|
|
|
* available devices.
|
|
|
|
*/
|
|
|
|
void UpdateRenderMode();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies a D2D device is present and working, will attempt to create one
|
|
|
|
* it is non-functional or non-existant.
|
|
|
|
*
|
|
|
|
* \param aAttemptForce Attempt to force D2D cairo device creation by using
|
|
|
|
* cairo device creation routines.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
void VerifyD2DDevice(bool aAttemptForce);
|
2010-09-15 22:16:09 +00:00
|
|
|
|
2013-03-22 19:32:56 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
HRESULT CreateDevice(nsRefPtr<IDXGIAdapter1> &adapter1, int featureLevelIndex);
|
|
|
|
#endif
|
|
|
|
|
2013-04-01 09:10:28 +00:00
|
|
|
/**
|
|
|
|
* Return the resolution scaling factor to convert between "logical" or
|
|
|
|
* "screen" pixels as used by Windows (dependent on the DPI scaling option
|
|
|
|
* in the Display control panel) and actual device pixels.
|
|
|
|
*/
|
2013-12-14 20:40:55 +00:00
|
|
|
double GetDPIScale();
|
2013-04-01 09:10:28 +00:00
|
|
|
|
2010-02-24 17:57:57 +00:00
|
|
|
nsresult GetFontList(nsIAtom *aLangGroup,
|
2006-02-01 02:35:38 +00:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 20:14:14 +00:00
|
|
|
nsTArray<nsString>& aListOfFonts);
|
2006-02-01 02:35:38 +00:00
|
|
|
|
2006-06-15 04:47:23 +00:00
|
|
|
nsresult UpdateFontList();
|
|
|
|
|
2014-09-30 06:27:55 +00:00
|
|
|
virtual void GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aRunScript,
|
2012-03-09 02:05:24 +00:00
|
|
|
nsTArray<const char*>& aFontList);
|
|
|
|
|
2008-03-13 10:32:50 +00:00
|
|
|
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
|
|
|
|
|
2015-09-11 04:24:33 +00:00
|
|
|
gfxFontGroup*
|
|
|
|
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
|
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxTextPerfMetrics* aTextPerf,
|
|
|
|
gfxUserFontSet *aUserFontSet) override;
|
2008-10-01 03:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Look up a local platform font using the full font face name (needed to support @font-face src local() )
|
|
|
|
*/
|
2014-09-08 07:23:19 +00:00
|
|
|
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
|
|
|
bool aItalic);
|
2008-10-01 03:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Activate a platform font (needed to support @font-face src url() )
|
|
|
|
*/
|
2014-09-08 07:23:19 +00:00
|
|
|
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
|
|
|
bool aItalic,
|
|
|
|
const uint8_t* aFontData,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aLength);
|
2008-10-01 03:01:53 +00:00
|
|
|
|
2015-06-18 04:09:16 +00:00
|
|
|
virtual bool CanUseHardwareVideoDecoding() override;
|
|
|
|
|
2008-10-01 03:01:53 +00:00
|
|
|
/**
|
|
|
|
* Check whether format is supported on a platform or not (if unclear, returns true)
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags);
|
2007-04-02 19:06:16 +00:00
|
|
|
|
2015-02-22 22:53:32 +00:00
|
|
|
virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr);
|
2014-09-24 17:12:10 +00:00
|
|
|
|
2010-05-27 05:05:30 +00:00
|
|
|
// ClearType is not always enabled even when available (e.g. Windows XP)
|
|
|
|
// if either of these prefs are enabled and apply, use ClearType rendering
|
2011-09-29 06:19:26 +00:00
|
|
|
bool UseClearTypeForDownloadableFonts();
|
|
|
|
bool UseClearTypeAlways();
|
2010-05-27 05:05:30 +00:00
|
|
|
|
2013-12-11 09:46:41 +00:00
|
|
|
static void GetDLLVersion(char16ptr_t aDLLPath, nsAString& aVersion);
|
2011-01-14 12:57:17 +00:00
|
|
|
|
2011-05-11 00:30:20 +00:00
|
|
|
// returns ClearType tuning information for each display
|
|
|
|
static void GetCleartypeParams(nsTArray<ClearTypeParameterInfo>& aParams);
|
|
|
|
|
2011-06-12 02:30:16 +00:00
|
|
|
virtual void FontsPrefsChanged(const char *aPref);
|
2010-05-27 05:05:30 +00:00
|
|
|
|
2011-06-12 02:30:16 +00:00
|
|
|
void SetupClearTypeParams();
|
2011-04-21 06:29:50 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
2010-12-02 10:37:17 +00:00
|
|
|
IDWriteFactory *GetDWriteFactory() { return mDWriteFactory; }
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
inline bool DWriteEnabled() { return !!mDWriteFactory; }
|
2011-04-21 06:29:50 +00:00
|
|
|
inline DWRITE_MEASURING_MODE DWriteMeasuringMode() { return mMeasuringMode; }
|
2012-03-19 19:20:18 +00:00
|
|
|
|
|
|
|
IDWriteRenderingParams *GetRenderingParams(TextRenderingMode aRenderMode)
|
|
|
|
{ return mRenderingParams[aRenderMode]; }
|
2010-08-16 07:15:03 +00:00
|
|
|
#else
|
2011-09-29 06:19:26 +00:00
|
|
|
inline bool DWriteEnabled() { return false; }
|
2010-02-26 06:36:07 +00:00
|
|
|
#endif
|
2013-11-21 22:07:56 +00:00
|
|
|
void OnDeviceManagerDestroy(mozilla::layers::DeviceManagerD3D9* aDeviceManager);
|
2013-08-04 07:46:17 +00:00
|
|
|
mozilla::layers::DeviceManagerD3D9* GetD3D9DeviceManager();
|
|
|
|
IDirect3DDevice9* GetD3D9Device();
|
2015-07-02 21:44:53 +00:00
|
|
|
ID3D10Device1 *GetD3D10Device() { return mD3D10Device; }
|
2013-05-01 14:27:09 +00:00
|
|
|
ID3D11Device *GetD3D11Device();
|
2014-09-14 21:51:27 +00:00
|
|
|
ID3D11Device *GetD3D11ContentDevice();
|
2015-07-27 15:47:29 +00:00
|
|
|
ID3D11Device* GetD3D11DeviceForCurrentThread();
|
2015-05-13 11:42:32 +00:00
|
|
|
// Device to be used on the ImageBridge thread
|
|
|
|
ID3D11Device *GetD3D11ImageBridgeDevice();
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2015-03-31 05:21:15 +00:00
|
|
|
// Create a D3D11 device to be used for DXVA decoding.
|
2015-06-17 14:00:52 +00:00
|
|
|
already_AddRefed<ID3D11Device> CreateD3D11DecoderDevice();
|
2015-03-31 05:21:15 +00:00
|
|
|
|
2014-07-30 13:38:46 +00:00
|
|
|
mozilla::layers::ReadbackManagerD3D11* GetReadbackManager();
|
|
|
|
|
2011-03-02 01:00:33 +00:00
|
|
|
static bool IsOptimus();
|
|
|
|
|
2015-01-21 03:36:01 +00:00
|
|
|
bool IsWARP() { return mIsWARP; }
|
2015-08-05 09:45:06 +00:00
|
|
|
|
|
|
|
// Returns whether the compositor's D3D11 device supports texture sharing.
|
|
|
|
bool CompositorD3D11TextureSharingWorks() const {
|
|
|
|
return mCompositorD3D11TextureSharingWorks;
|
|
|
|
}
|
2015-01-21 03:36:01 +00:00
|
|
|
|
2015-04-19 20:12:14 +00:00
|
|
|
bool SupportsApzWheelInput() const override {
|
2015-03-24 22:04:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-04-19 20:12:14 +00:00
|
|
|
bool SupportsApzTouchInput() const override;
|
2015-03-24 22:04:44 +00:00
|
|
|
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
// Recreate devices as needed for a device reset. Returns true if a device
|
|
|
|
// reset occurred.
|
|
|
|
bool HandleDeviceReset();
|
|
|
|
void UpdateBackendPrefs();
|
|
|
|
|
2015-07-19 21:50:35 +00:00
|
|
|
// Return the diagnostic status of DirectX initialization. If
|
|
|
|
// initialization has not been attempted, this returns
|
|
|
|
// FeatureStatus::Unused.
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
mozilla::gfx::FeatureStatus GetD3D11Status() const;
|
|
|
|
mozilla::gfx::FeatureStatus GetD2DStatus() const;
|
|
|
|
mozilla::gfx::FeatureStatus GetD2D1Status() const;
|
2015-07-19 21:50:35 +00:00
|
|
|
unsigned GetD3D11Version();
|
|
|
|
|
2015-07-30 07:23:53 +00:00
|
|
|
void TestDeviceReset(DeviceResetReason aReason) override;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
|
2015-01-28 01:09:34 +00:00
|
|
|
static mozilla::Atomic<size_t> sD3D11MemoryUsed;
|
2015-02-03 08:34:33 +00:00
|
|
|
static mozilla::Atomic<size_t> sD3D9MemoryUsed;
|
2015-02-05 03:20:14 +00:00
|
|
|
static mozilla::Atomic<size_t> sD3D9SharedTextureUsed;
|
2015-01-28 01:09:34 +00:00
|
|
|
|
2015-08-02 20:59:33 +00:00
|
|
|
void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut) override;
|
|
|
|
|
2015-07-16 22:18:05 +00:00
|
|
|
protected:
|
|
|
|
bool AccelerateLayersByDefault() override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void GetAcceleratedCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aBackends);
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size);
|
2015-08-02 20:59:33 +00:00
|
|
|
void SetDeviceInitData(mozilla::gfx::DeviceInitData& aData) override;
|
2015-07-16 22:18:05 +00:00
|
|
|
|
2009-07-08 23:34:02 +00:00
|
|
|
protected:
|
|
|
|
RenderMode mRenderMode;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int8_t mUseClearTypeForDownloadableFonts;
|
|
|
|
int8_t mUseClearTypeAlways;
|
2010-05-27 05:05:30 +00:00
|
|
|
|
2006-02-15 02:48:08 +00:00
|
|
|
private:
|
|
|
|
void Init();
|
2015-07-16 06:59:39 +00:00
|
|
|
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
void InitializeDevices();
|
|
|
|
void InitializeD3D11();
|
|
|
|
void InitializeD2D();
|
2015-07-30 07:25:56 +00:00
|
|
|
void InitializeD2D1();
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
bool InitDWriteSupport();
|
2015-07-16 06:59:39 +00:00
|
|
|
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
void DisableD2D();
|
|
|
|
|
2015-08-02 20:59:33 +00:00
|
|
|
mozilla::gfx::FeatureStatus CheckAccelerationSupport();
|
2015-07-30 07:24:56 +00:00
|
|
|
mozilla::gfx::FeatureStatus CheckD3D11Support(bool* aCanUseHardware);
|
2015-07-30 07:25:56 +00:00
|
|
|
mozilla::gfx::FeatureStatus CheckD2DSupport();
|
|
|
|
mozilla::gfx::FeatureStatus CheckD2D1Support();
|
2015-09-14 06:52:29 +00:00
|
|
|
mozilla::gfx::FeatureStatus AttemptD3D11DeviceCreation();
|
|
|
|
mozilla::gfx::FeatureStatus AttemptWARPDeviceCreation();
|
|
|
|
mozilla::gfx::FeatureStatus AttemptD3D11ImageBridgeDeviceCreation();
|
|
|
|
mozilla::gfx::FeatureStatus AttemptD3D11ContentDeviceCreation();
|
2015-08-02 20:59:33 +00:00
|
|
|
bool CanUseD3D11ImageBridge();
|
2015-08-11 03:27:06 +00:00
|
|
|
bool ContentAdapterIsParentAdapter(ID3D11Device* device);
|
2015-07-16 06:59:39 +00:00
|
|
|
|
2015-09-14 06:52:29 +00:00
|
|
|
void DisableD3D11AfterCrash();
|
|
|
|
void ResetD3D11Devices();
|
|
|
|
|
2013-05-01 14:27:09 +00:00
|
|
|
IDXGIAdapter1 *GetDXGIAdapter();
|
2015-05-08 21:12:32 +00:00
|
|
|
bool IsDeviceReset(HRESULT hr, DeviceResetReason* aReason);
|
2006-02-15 02:48:08 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
|
|
|
nsRefPtr<IDWriteFactory> mDWriteFactory;
|
2012-03-19 19:20:18 +00:00
|
|
|
nsRefPtr<IDWriteRenderingParams> mRenderingParams[TEXT_RENDERING_COUNT];
|
2011-04-21 06:29:50 +00:00
|
|
|
DWRITE_MEASURING_MODE mMeasuringMode;
|
2010-08-10 23:59:51 +00:00
|
|
|
#endif
|
2013-05-01 14:27:09 +00:00
|
|
|
mozilla::RefPtr<IDXGIAdapter1> mAdapter;
|
2013-08-04 07:46:17 +00:00
|
|
|
nsRefPtr<mozilla::layers::DeviceManagerD3D9> mDeviceManager;
|
2015-07-02 21:44:53 +00:00
|
|
|
mozilla::RefPtr<ID3D10Device1> mD3D10Device;
|
2013-05-01 14:27:09 +00:00
|
|
|
mozilla::RefPtr<ID3D11Device> mD3D11Device;
|
2014-09-14 21:51:27 +00:00
|
|
|
mozilla::RefPtr<ID3D11Device> mD3D11ContentDevice;
|
2015-05-13 11:42:32 +00:00
|
|
|
mozilla::RefPtr<ID3D11Device> mD3D11ImageBridgeDevice;
|
2014-07-30 13:38:46 +00:00
|
|
|
mozilla::RefPtr<mozilla::layers::ReadbackManagerD3D11> mD3D11ReadbackManager;
|
2015-01-21 03:36:01 +00:00
|
|
|
bool mIsWARP;
|
2015-05-08 21:12:32 +00:00
|
|
|
bool mHasDeviceReset;
|
2015-07-30 07:23:53 +00:00
|
|
|
bool mHasFakeDeviceReset;
|
2015-08-05 09:45:06 +00:00
|
|
|
bool mCompositorD3D11TextureSharingWorks;
|
2015-05-08 21:12:32 +00:00
|
|
|
DeviceResetReason mDeviceResetReason;
|
2010-02-26 06:36:07 +00:00
|
|
|
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
// These should not be accessed directly. Use the Get[Feature]Status
|
|
|
|
// accessors instead.
|
|
|
|
mozilla::gfx::FeatureStatus mAcceleration;
|
2015-07-19 21:50:35 +00:00
|
|
|
mozilla::gfx::FeatureStatus mD3D11Status;
|
|
|
|
mozilla::gfx::FeatureStatus mD2DStatus;
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
mozilla::gfx::FeatureStatus mD2D1Status;
|
2015-07-19 21:50:35 +00:00
|
|
|
|
Refactor graphics device initialization on Windows. (bug 1183910 part 1, r=mattwoodrow,bas)
This patch addresses a number of inconsistencies in the device initialization process, as well as simplifying it for future use. All device decisions are now explicitly made up-front during startup, rather than implicitly or on-demand. In addition a number of restrictions have been placed on when we can construct devices.
Full change list:
(1) We no longer attempt to use D3D11 if acceleration is disabled or D3D9 is preferred. This is a departure from our previous behavior, where we would construct these devices but then not use them as a compositor backend.
(2) D3D11 startup no longer creates a content device (this is reserved for D2D initialization).
(3) D2D is only attempted if we managed to create a D3D11 compositor device. This is a departure from previous behavior where if D3D11 was not used for compositing, we could still create its machinery to use D2D as a content backend.
(4) D2D 1.1 initialization is now directly responsible for creating a D3D11 content device.
(5) D2D 1.0 and 1.1 logic have been disentangled for clarity.
(6) UpdateRenderMode() has been split up, so we can update backend prefs out of band with device resets.
(7) mUseGDIFonts and mUseDirectWrite have been removed as their state was confusing. Instead, D2D now depends on DWrite initialization succeeding. If later we fail to get a DWrite font list, we revert our decision to use Direct2D.
(8) Device resets now clear a little more state, including the devices set in Moz2D Factory.
(9) We no longer create a DWrite text analyzer as it was unused.
2015-07-28 23:52:54 +00:00
|
|
|
nsTArray<D3D_FEATURE_LEVEL> mFeatureLevels;
|
2006-02-01 02:35:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_WINDOWS_PLATFORM_H */
|