Bug 1539892 - replace FeatureChange and GPUDeviceStatus IPDL unions with native Maybe syntax; r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D25259

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Gaynor 2019-03-28 21:13:53 +00:00
parent 3aa3bb6bc9
commit e845354e42
5 changed files with 21 additions and 29 deletions

View File

@ -240,12 +240,13 @@ void gfxConfig::ForEachFallbackImpl(const FallbackIterCallback& aCallback) {
}
/* static */
void gfxConfig::ImportChange(Feature aFeature, const FeatureChange& aChange) {
if (aChange.type() == FeatureChange::Tnull_t) {
void gfxConfig::ImportChange(Feature aFeature,
const Maybe<FeatureFailure>& aChange) {
if (aChange.isNothing()) {
return;
}
const FeatureFailure& failure = aChange.get_FeatureFailure();
const FeatureFailure& failure = aChange.ref();
gfxConfig::SetFailed(aFeature, failure.status(), failure.message().get(),
failure.failureId());
}

View File

@ -10,12 +10,13 @@
#include "gfxFeature.h"
#include "gfxFallback.h"
#include "mozilla/Assertions.h"
#include "mozilla/Maybe.h"
namespace mozilla {
namespace gfx {
// Defined in GraphicsMessages.ipdlh.
class FeatureChange;
class FeatureFailure;
// Manages the history and state of a graphics feature. The flow of a feature
// is:
@ -171,7 +172,8 @@ class gfxConfig {
// Get the most descriptive failure id message for this feature.
static const nsCString& GetFailureId(Feature aFeature);
static void ImportChange(Feature aFeature, const FeatureChange& aChange);
static void ImportChange(Feature aFeature,
const Maybe<FeatureFailure>& aChange);
static void Init();
static void Shutdown();

View File

@ -321,7 +321,7 @@ mozilla::ipc::IPCResult GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) {
return IPC_OK();
}
static void CopyFeatureChange(Feature aFeature, FeatureChange* aOut) {
static void CopyFeatureChange(Feature aFeature, Maybe<FeatureFailure>* aOut) {
FeatureState& feature = gfxConfig::GetFeature(aFeature);
if (feature.DisabledByDefault() || feature.IsEnabled()) {
// No change:
@ -330,7 +330,7 @@ static void CopyFeatureChange(Feature aFeature, FeatureChange* aOut) {
// - Enabled means we were told to use this feature, and we didn't
// discover anything
// that would prevent us from doing so.
*aOut = null_t();
*aOut = Nothing();
return;
}
@ -339,7 +339,8 @@ static void CopyFeatureChange(Feature aFeature, FeatureChange* aOut) {
nsCString message;
message.AssignASCII(feature.GetFailureMessage());
*aOut = FeatureFailure(feature.GetValue(), message, feature.GetFailureId());
*aOut =
Some(FeatureFailure(feature.GetValue(), message, feature.GetFailureId()));
}
mozilla::ipc::IPCResult GPUParent::RecvGetDeviceStatus(GPUDeviceData* aOut) {
@ -351,10 +352,10 @@ mozilla::ipc::IPCResult GPUParent::RecvGetDeviceStatus(GPUDeviceData* aOut) {
if (DeviceManagerDx* dm = DeviceManagerDx::Get()) {
D3D11DeviceStatus deviceStatus;
dm->ExportDeviceInfo(&deviceStatus);
aOut->gpuDevice() = deviceStatus;
aOut->gpuDevice() = Some(deviceStatus);
}
#else
aOut->gpuDevice() = null_t();
aOut->gpuDevice() = Nothing();
#endif
return IPC_OK();

View File

@ -63,26 +63,14 @@ struct FeatureFailure
nsCString failureId;
};
// If a feature state has changed from Enabled -> Failure, this will be non-
// null.
union FeatureChange
{
null_t;
FeatureFailure;
};
union GPUDeviceStatus
{
null_t;
D3D11DeviceStatus;
};
struct GPUDeviceData
{
FeatureChange d3d11Compositing;
FeatureChange oglCompositing;
FeatureChange advancedLayers;
GPUDeviceStatus gpuDevice;
// If a feature state has changed from Enabled -> Failure, these will be non-
// null.
FeatureFailure? d3d11Compositing;
FeatureFailure? oglCompositing;
FeatureFailure? advancedLayers;
D3D11DeviceStatus? gpuDevice;
};
union GfxVarValue

View File

@ -1963,7 +1963,7 @@ void gfxWindowsPlatform::ImportGPUDeviceData(
DeviceManagerDx* dm = DeviceManagerDx::Get();
if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
dm->ImportDeviceInfo(aData.gpuDevice().get_D3D11DeviceStatus());
dm->ImportDeviceInfo(aData.gpuDevice().ref());
} else {
// There should be no devices, so this just takes away the device status.
dm->ResetDevices();