From f894adf887cdbb4c2d9140f1fc9f9e17b9477c9a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 28 Apr 2016 21:52:55 -0700 Subject: [PATCH] Move DeviceInitData from gfxWindowsPlatform to gfxPlatforn. (bug 1254899 part 5, r=milan) --- gfx/ipc/GraphicsMessages.ipdlh | 2 +- gfx/thebes/gfxPlatform.cpp | 15 +++++++++++++-- gfx/thebes/gfxPlatform.h | 8 ++------ gfx/thebes/gfxWindowsPlatform.cpp | 23 +++-------------------- gfx/thebes/gfxWindowsPlatform.h | 2 +- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/gfx/ipc/GraphicsMessages.ipdlh b/gfx/ipc/GraphicsMessages.ipdlh index 09fb18416c65..6b176d3ef902 100644 --- a/gfx/ipc/GraphicsMessages.ipdlh +++ b/gfx/ipc/GraphicsMessages.ipdlh @@ -12,7 +12,7 @@ namespace gfx { struct DeviceInitData { - bool useAcceleration; + bool useHwCompositing; // Windows only. bool useD3D11; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index a1bed76b9631..330977fcc00d 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -170,6 +170,10 @@ static qcms_transform *gCMSRGBATransform = nullptr; static bool gCMSInitialized = false; static eCMSMode gCMSMode = eCMSMode_Off; +// Device init data should only be used on child processes, so we protect it +// behind a getter here. +static DeviceInitData sDeviceInitDataDoNotUseDirectly; + static void ShutdownCMS(); #include "mozilla/gfx/2D.h" @@ -2236,6 +2240,13 @@ gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFo return nullptr; } +/* static */ DeviceInitData& +gfxPlatform::GetParentDevicePrefs() +{ + MOZ_ASSERT(XRE_IsContentProcess()); + return sDeviceInitDataDoNotUseDirectly; +} + /* static */ bool gfxPlatform::UsesOffMainThreadCompositing() { @@ -2442,7 +2453,7 @@ void gfxPlatform::GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut) { MOZ_ASSERT(XRE_IsParentProcess()); - aOut->useAcceleration() = gfxConfig::IsEnabled(Feature::HW_COMPOSITING); + aOut->useHwCompositing() = gfxConfig::IsEnabled(Feature::HW_COMPOSITING); } void @@ -2456,7 +2467,7 @@ gfxPlatform::UpdateDeviceInitData() mozilla::gfx::DeviceInitData data; mozilla::dom::ContentChild::GetSingleton()->SendGetGraphicsDeviceInitData(&data); - SetDeviceInitData(data); + sDeviceInitDataDoNotUseDirectly = data; } bool diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 4eb7f7c12358..7eb490ef99fa 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -693,12 +693,6 @@ protected: */ void BumpDeviceCounter(); - /** - * Called when new device preferences are available. - */ - virtual void SetDeviceInitData(mozilla::gfx::DeviceInitData& aData) - {} - /** * returns the first backend named in the pref gfx.canvas.azure.backends * which is a component of aBackendBitmask, a bitmask of backend types @@ -727,6 +721,8 @@ protected: static already_AddRefed GetScaledFontForFontWithCairoSkia(mozilla::gfx::DrawTarget* aTarget, gfxFont* aFont); + static mozilla::gfx::DeviceInitData& GetParentDevicePrefs(); + int8_t mAllowDownloadableFonts; int8_t mGraphiteShapingEnabled; int8_t mOpenTypeSVGEnabled; diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index b3bdf43b62cd..61a04dd90344 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -358,16 +358,6 @@ public: NS_IMPL_ISUPPORTS(D3D9SharedTextureReporter, nsIMemoryReporter) -// Device init data should only be used on child processes, so we protect it -// behind a getter here. -static DeviceInitData sDeviceInitDataDoNotUseDirectly; -static inline DeviceInitData& -GetParentDevicePrefs() -{ - MOZ_ASSERT(XRE_IsContentProcess()); - return sDeviceInitDataDoNotUseDirectly; -} - gfxWindowsPlatform::gfxWindowsPlatform() : mRenderMode(RENDER_GDI) , mDeviceLock("gfxWindowsPlatform.mDeviceLock") @@ -1927,8 +1917,8 @@ bool DoesD3D11AlphaTextureSharingWork(ID3D11Device *device) return DoesD3D11TextureSharingWorkInternal(device, DXGI_FORMAT_R8_UNORM, D3D11_BIND_SHADER_RESOURCE); } -static inline bool -CanUseWARP() +bool +gfxWindowsPlatform::CanUseWARP() { if (gfxPrefs::LayersD3D11ForceWARP()) { return true; @@ -2265,13 +2255,6 @@ gfxWindowsPlatform::AttemptD3D11ImageBridgeDeviceCreation() return FeatureStatus::Available; } -void -gfxWindowsPlatform::SetDeviceInitData(mozilla::gfx::DeviceInitData& aData) -{ - MOZ_ASSERT(XRE_IsContentProcess()); - sDeviceInitDataDoNotUseDirectly = aData; -} - void gfxWindowsPlatform::InitializeDevices() { @@ -2325,7 +2308,7 @@ gfxWindowsPlatform::CheckAccelerationSupport() return mAcceleration; } if (XRE_IsContentProcess()) { - return GetParentDevicePrefs().useAcceleration() + return GetParentDevicePrefs().useHwCompositing() ? FeatureStatus::Available : FeatureStatus::Blocked; } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 6f8d4c0a9743..ae88a0a297d7 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -270,7 +270,6 @@ protected: } void GetAcceleratedCompositorBackends(nsTArray& aBackends) override; virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size) override; - void SetDeviceInitData(mozilla::gfx::DeviceInitData& aData) override; protected: RenderMode mRenderMode; @@ -313,6 +312,7 @@ private: bool AttemptD3D11ContentDeviceCreationHelper( IDXGIAdapter1* aAdapter, HRESULT& aResOut); + bool CanUseWARP(); bool CanUseD3D11ImageBridge(); bool ContentAdapterIsParentAdapter(ID3D11Device* device);