Bug 1698732 - Change reftest-content to get Azure info without Win32k APIs r=bas,emilio

Currently, reftest-content uses GfxInfo::GetInfo() to obtain information about
the Azure backend. GetInfo() uses Win32k APIs, and therefore will mostly
return garbage in content processes.

This adds a new way to obtain the same information directly from GfxInfo
without using Win32k APIs.

Differential Revision: https://phabricator.services.mozilla.com/D111890
This commit is contained in:
Chris Martin 2021-04-27 15:17:12 +00:00
parent 533273efcd
commit e8085e7ecb
8 changed files with 75 additions and 20 deletions

View File

@ -103,6 +103,14 @@ class MockGfxInfo final : public nsIGfxInfo {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD GetAzureCanvasBackend(nsAString& aBackend) override {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD GetAzureContentBackend(nsAString& aBackend) override {
return NS_ERROR_NOT_IMPLEMENTED;
}
// The following methods we don't need for testing gfxConfigManager.
NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature,
nsAString& _retval) override {

View File

@ -3046,6 +3046,40 @@ void gfxPlatform::ReInitFrameRate() {
}
}
const char* gfxPlatform::GetAzureCanvasBackend() const {
BackendType backend{};
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
// Assume content process' backend prefs.
BackendPrefsData data = GetBackendPrefs();
backend = GetCanvasBackendPref(data.mCanvasBitmask);
if (backend == BackendType::NONE) {
backend = data.mCanvasDefault;
}
} else {
backend = mPreferredCanvasBackend;
}
return GetBackendName(backend);
}
const char* gfxPlatform::GetAzureContentBackend() const {
BackendType backend{};
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
// Assume content process' backend prefs.
BackendPrefsData data = GetBackendPrefs();
backend = GetContentBackendPref(data.mContentBitmask);
if (backend == BackendType::NONE) {
backend = data.mContentDefault;
}
} else {
backend = mContentBackend;
}
return GetBackendName(backend);
}
void gfxPlatform::GetAzureBackendInfo(mozilla::widget::InfoObject& aObj) {
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
aObj.DefineProperty("AzureCanvasBackend (UI Process)",
@ -3054,26 +3088,13 @@ void gfxPlatform::GetAzureBackendInfo(mozilla::widget::InfoObject& aObj) {
GetBackendName(mFallbackCanvasBackend));
aObj.DefineProperty("AzureContentBackend (UI Process)",
GetBackendName(mContentBackend));
// Assume content process' backend prefs.
BackendPrefsData data = GetBackendPrefs();
BackendType canvasBackend = GetCanvasBackendPref(data.mCanvasBitmask);
if (canvasBackend == BackendType::NONE) {
canvasBackend = data.mCanvasDefault;
}
BackendType contentBackend = GetContentBackendPref(data.mContentBitmask);
if (contentBackend == BackendType::NONE) {
contentBackend = data.mContentDefault;
}
aObj.DefineProperty("AzureCanvasBackend", GetBackendName(canvasBackend));
aObj.DefineProperty("AzureContentBackend", GetBackendName(contentBackend));
} else {
aObj.DefineProperty("AzureCanvasBackend",
GetBackendName(mPreferredCanvasBackend));
aObj.DefineProperty("AzureFallbackCanvasBackend",
GetBackendName(mFallbackCanvasBackend));
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
}
aObj.DefineProperty("AzureCanvasBackend", GetAzureCanvasBackend());
aObj.DefineProperty("AzureContentBackend", GetAzureContentBackend());
}
void gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj) {

View File

@ -310,6 +310,9 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
static bool AsyncPanZoomEnabled();
const char* GetAzureCanvasBackend() const;
const char* GetAzureContentBackend() const;
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject& aObj);
void GetApzSupportInfo(mozilla::widget::InfoObject& aObj);
void GetTilesSupportInfo(mozilla::widget::InfoObject& aObj);

View File

@ -473,9 +473,8 @@ function BuildConditionSandbox(aURL) {
sandbox.embeddedInFirefoxReality = false;
}
var info = gfxInfo.getInfo();
var canvasBackend = readGfxInfo(info, "AzureCanvasBackend");
var contentBackend = readGfxInfo(info, "AzureContentBackend");
var canvasBackend = readGfxInfo(gfxInfo, "AzureCanvasBackend");
var contentBackend = readGfxInfo(gfxInfo, "AzureContentBackend");
sandbox.gpuProcess = gfxInfo.usingGPUProcess;
sandbox.azureCairo = canvasBackend == "cairo";

View File

@ -1454,7 +1454,8 @@ function SendAssertionCount(numAssertions)
function SendContentReady()
{
let gfxInfo = (NS_GFXINFO_CONTRACTID in Cc) && Cc[NS_GFXINFO_CONTRACTID].getService(Ci.nsIGfxInfo);
let info = gfxInfo.getInfo();
let info = {};
// The webrender check has to be separate from the d2d checks
// since the d2d checks will throw an exception on non-windows platforms.
@ -1474,6 +1475,9 @@ function SendContentReady()
info.EmbeddedInFirefoxReality = false;
}
info.AzureCanvasBackend = gfxInfo.AzureCanvasBackend;
info.AzureContentBackend = gfxInfo.AzureContentBackend;
return sendSyncMessage("reftest:ContentReady", { 'gfx': info })[0];
}

View File

@ -1802,6 +1802,22 @@ GfxInfoBase::GetContentBackend(nsAString& aContentBackend) {
return NS_OK;
}
NS_IMETHODIMP
GfxInfoBase::GetAzureCanvasBackend(nsAString& aBackend) {
CopyASCIItoUTF16(mozilla::MakeStringSpan(
gfxPlatform::GetPlatform()->GetAzureCanvasBackend()),
aBackend);
return NS_OK;
}
NS_IMETHODIMP
GfxInfoBase::GetAzureContentBackend(nsAString& aBackend) {
CopyASCIItoUTF16(mozilla::MakeStringSpan(
gfxPlatform::GetPlatform()->GetAzureContentBackend()),
aBackend);
return NS_OK;
}
NS_IMETHODIMP
GfxInfoBase::GetUsingGPUProcess(bool* aOutValue) {
GPUProcessManager* gpu = GPUProcessManager::Get();

View File

@ -66,6 +66,8 @@ class GfxInfoBase : public nsIGfxInfo,
NS_IMETHOD GetActiveCrashGuards(JSContext*,
JS::MutableHandle<JS::Value>) override;
NS_IMETHOD GetContentBackend(nsAString& aContentBackend) override;
NS_IMETHOD GetAzureCanvasBackend(nsAString& aBackend) override;
NS_IMETHOD GetAzureContentBackend(nsAString& aBackend) override;
NS_IMETHOD GetUsingGPUProcess(bool* aOutValue) override;
NS_IMETHOD GetWebRenderEnabled(bool* aWebRenderEnabled) override;
NS_IMETHOD GetIsHeadless(bool* aIsHeadless) override;

View File

@ -16,6 +16,8 @@ interface nsIGfxInfo : nsISupports
readonly attribute boolean D2DEnabled;
readonly attribute boolean DWriteEnabled;
readonly attribute boolean EmbeddedInFirefoxReality;
readonly attribute AString AzureCanvasBackend;
readonly attribute AString AzureContentBackend;
readonly attribute boolean usingGPUProcess;
readonly attribute boolean hasBattery;
readonly attribute AString DWriteVersion;