diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 17f2a3144e4b..4e3199e188ce 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -520,7 +520,7 @@ ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit, { mLookAndFeelCache = aLookAndFeelIntCache; InitXPCOM(aXPCOMInit, aInitialData); - InitGraphicsDeviceData(); + InitGraphicsDeviceData(aXPCOMInit.contentDeviceData()); return IPC_OK(); } @@ -952,11 +952,11 @@ ContentChild::AppendProcessId(nsACString& aName) } void -ContentChild::InitGraphicsDeviceData() +ContentChild::InitGraphicsDeviceData(const ContentDeviceData& aData) { // Initialize the graphics platform. This may contact the parent process // to read device preferences. - gfxPlatform::GetPlatform(); + gfxPlatform::InitChild(aData); } void diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 05253771d379..ef69b06d7670 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -104,7 +104,7 @@ public: void InitXPCOM(const XPCOMInitData& aXPCOMInit, const mozilla::dom::ipc::StructuredCloneData& aInitialData); - void InitGraphicsDeviceData(); + void InitGraphicsDeviceData(const ContentDeviceData& aData); static ContentChild* GetSingleton() { diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index ec7b97df72bd..4d35e0970ace 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2222,6 +2222,8 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, SerializeURI(nullptr, xpcomInit.userContentSheetURL()); } + gfxPlatform::GetPlatform()->BuildContentDeviceData(&xpcomInit.contentDeviceData()); + nsCOMPtr gfxInfo = services::GetGfxInfo(); if (gfxInfo) { for (int32_t i = 1; i <= nsIGfxInfo::FEATURE_MAX_VALUE; ++i) { diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 26b6f9cf533e..12d82becfdc2 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -265,6 +265,7 @@ struct XPCOMInitData FontFamilyListEntry[] fontFamilies; OptionalURIParams userContentSheetURL; PrefSetting[] prefs; + ContentDeviceData contentDeviceData; GfxInfoFeatureStatus[] gfxFeatureStatus; DataStorageEntry[] dataStorage; }; diff --git a/gfx/ipc/D3DMessageUtils.cpp b/gfx/ipc/D3DMessageUtils.cpp index f3895fdae95c..30a2b88734b3 100644 --- a/gfx/ipc/D3DMessageUtils.cpp +++ b/gfx/ipc/D3DMessageUtils.cpp @@ -47,8 +47,6 @@ ParamTraits::Write(Message* aMsg, const paramType& aParam) WriteParam(aMsg, aParam.SharedSystemMemory); WriteParam(aMsg, aParam.AdapterLuid.LowPart); WriteParam(aMsg, aParam.AdapterLuid.HighPart); -#else - MOZ_ASSERT_UNREACHABLE("DxgiAdapterDesc is Windows-only"); #endif } @@ -72,10 +70,10 @@ ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, p { return true; } -#else - MOZ_ASSERT_UNREACHABLE("DxgiAdapterDesc is Windows-only"); -#endif return false; +#else + return true; +#endif } } // namespace IPC diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 82167c1b264e..e754ab6c24f6 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -152,6 +152,8 @@ using namespace mozilla::gfx; gfxPlatform *gPlatform = nullptr; static bool gEverInitialized = false; +const ContentDeviceData* gContentDeviceInitData = nullptr; + static Mutex* gGfxPlatformPrefsLock = nullptr; // These two may point to the same profile @@ -528,6 +530,8 @@ gfxPlatform* gfxPlatform::GetPlatform() { if (!gPlatform) { + MOZ_RELEASE_ASSERT(!XRE_IsContentProcess(), + "Content Process should have called InitChild() before first GetPlatform()"); Init(); } return gPlatform; @@ -539,6 +543,19 @@ gfxPlatform::Initialized() return !!gPlatform; } +/* static */ void +gfxPlatform::InitChild(const ContentDeviceData& aData) +{ + MOZ_ASSERT(XRE_IsContentProcess()); + MOZ_RELEASE_ASSERT(!gPlatform, + "InitChild() should be called before first GetPlatform()"); + // Make the provided initial ContentDeviceData available to the init + // routines, so they don't have to do a sync request from the parent. + gContentDeviceInitData = &aData; + Init(); + gContentDeviceInitData = nullptr; +} + void RecordingPrefChanged(const char *aPrefName, void *aClosure) { if (Preferences::GetBool("gfx.2d.recording", false)) { @@ -2651,6 +2668,11 @@ gfxPlatform::FetchAndImportContentDeviceData() { MOZ_ASSERT(XRE_IsContentProcess()); + if (gContentDeviceInitData) { + ImportContentDeviceData(*gContentDeviceInitData); + return; + } + mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); mozilla::gfx::ContentDeviceData data; diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 698d248dc708..ee6b299d75b7 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -175,6 +175,12 @@ public: */ static void Shutdown(); + /** + * Initialize gfxPlatform (if not already done) in a child process, with + * the provided ContentDeviceData. + */ + static void InitChild(const mozilla::gfx::ContentDeviceData& aData); + static void InitLayersIPC(); static void ShutdownLayersIPC();