Skip to content

Commit

Permalink
Bug 1539892 - replace FeatureChange and GPUDeviceStatus IPDL unions w…
Browse files Browse the repository at this point in the history
…ith native Maybe syntax; r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D25259
  • Loading branch information
Alex Gaynor committed Mar 28, 2019
1 parent 43b6f7c commit dc299b8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
7 changes: 4 additions & 3 deletions gfx/config/gfxConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
6 changes: 4 additions & 2 deletions gfx/config/gfxConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 6 additions & 5 deletions gfx/ipc/GPUParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
}

Expand All @@ -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) {
Expand All @@ -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();
Expand Down
24 changes: 6 additions & 18 deletions gfx/ipc/GraphicsMessages.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxWindowsPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit dc299b8

Please sign in to comment.