Bug 1725573 - Add color profile remoting for GTK. r=aosmond,perftest-reviewers,AlexandruIonescu

Previously, content processes would try to contact the X server
directly during startup to read color calibration information; with
`dom.ipc.avoid-gtk` this doesn't work because the process is in headless
mode.  This patch extends the color profile IPC facility added in bug
1540776 for Windows sandboxing (win32k lockdown) to GTK under X11.
(Currently there's no support for color management under Wayland, so
there's nothing for this patch to fix in that case.)

Differential Revision: https://phabricator.services.mozilla.com/D124507
This commit is contained in:
Jed Davis 2021-09-14 16:01:08 +00:00
parent fb31a116fe
commit 86d7fa40d2
3 changed files with 37 additions and 0 deletions

View File

@ -240,6 +240,15 @@ add_task(async function navigate_around() {
min: 49,
max: 55,
};
// This was previously being read in the content process, but
// bug 1725573 moved it into the parent process. We also block
// the main thread on requests to the X server, which is likely
// more problematic than the pref read. These issues are covered
// by https://bugzilla.mozilla.org/show_bug.cgi?id=1729080
knownProblematicPrefs["gfx.color_management.display_profile"] = {
min: 49,
max: 50,
};
} else if (AppConstants.platform == "win") {
// The following 2 graphics prefs are covered by
// https://bugzilla.mozilla.org/show_bug.cgi?id=1639497

View File

@ -27,6 +27,7 @@
#include "GLContextProvider.h"
#include "mozilla/Atomics.h"
#include "mozilla/Components.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/FontPropertyTypes.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Logging.h"
@ -493,6 +494,26 @@ nsTArray<uint8_t> gfxPlatformGtk::GetPlatformCMSOutputProfileData() {
return prefProfileData;
}
if (XRE_IsContentProcess()) {
MOZ_ASSERT(NS_IsMainThread());
// This will be passed in during InitChild so we can avoid sending a
// sync message back to the parent during init.
const mozilla::gfx::ContentDeviceData* contentDeviceData =
GetInitContentDeviceData();
if (contentDeviceData) {
// On Windows, we assert that the profile isn't empty, but on
// Linux it can legitimately be empty if the display isn't
// calibrated. Thus, no assertion here.
return contentDeviceData->cmsOutputProfileData().Clone();
}
// Otherwise we need to ask the parent for the updated color profile
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
nsTArray<uint8_t> result;
Unused << cc->SendGetOutputColorProfileData(&result);
return result;
}
if (!mIsX11Display) {
return nsTArray<uint8_t>();
}
@ -849,3 +870,9 @@ already_AddRefed<gfx::VsyncSource> gfxPlatformGtk::CreateHardwareVsyncSource() {
}
#endif
void gfxPlatformGtk::BuildContentDeviceData(ContentDeviceData* aOut) {
gfxPlatform::BuildContentDeviceData(aOut);
aOut->cmsOutputProfileData() = GetPlatformCMSOutputProfileData();
}

View File

@ -76,6 +76,7 @@ class gfxPlatformGtk final : public gfxPlatform {
void InitPlatformGPUProcessPrefs() override;
void InitWebRenderConfig() override;
bool CheckVariationFontSupport() override;
void BuildContentDeviceData(mozilla::gfx::ContentDeviceData* aOut) override;
int8_t mMaxGenericSubstitutions;