Bug 859007 - Annotate crash reports with hresult failure codes when layer manager fails to initialize. r=bbondy

This commit is contained in:
Jim Mathies 2013-04-10 09:02:44 -05:00
Родитель 82373c89f8
Коммит c909004dca
3 изменённых файлов: 37 добавлений и 9 удалений

Просмотреть файл

@ -98,12 +98,20 @@ LayerManagerD3D10::~LayerManagerD3D10()
Destroy();
}
_inline void
SetHRESULT(HRESULT* aHresultPtr, HRESULT aHresult)
{
if (aHresultPtr) {
*aHresultPtr = aHresult;
}
}
bool
LayerManagerD3D10::Initialize(bool force)
LayerManagerD3D10::Initialize(bool force, HRESULT* aHresultPtr)
{
ScopedGfxFeatureReporter reporter("D3D10 Layers", force);
HRESULT hr;
HRESULT hr = E_UNEXPECTED;
/* Create an Nv3DVUtils instance */
if (!mNv3DVUtils) {
@ -120,6 +128,7 @@ LayerManagerD3D10::Initialize(bool force)
mDevice = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!mDevice) {
SetHRESULT(aHresultPtr, hr);
return false;
}
@ -147,10 +156,11 @@ LayerManagerD3D10::Initialize(bool force)
attachments = new DeviceAttachments;
mDevice->SetPrivateData(sDeviceAttachments, sizeof(attachments), &attachments);
SetLastError(0);
D3D10CreateEffectFromMemoryFunc createEffect = (D3D10CreateEffectFromMemoryFunc)
GetProcAddress(LoadLibraryA("d3d10_1.dll"), "D3D10CreateEffectFromMemory");
GetProcAddress(LoadLibraryA("d3d10_1.dll"), "D3D10CreateEffectFromMemory");
if (!createEffect) {
SetHRESULT(aHresultPtr, HRESULT_FROM_WIN32(GetLastError()));
return false;
}
@ -162,6 +172,7 @@ LayerManagerD3D10::Initialize(bool force)
getter_AddRefs(mEffect));
if (FAILED(hr)) {
SetHRESULT(aHresultPtr, hr);
return false;
}
@ -182,6 +193,7 @@ LayerManagerD3D10::Initialize(bool force)
getter_AddRefs(mInputLayout));
if (FAILED(hr)) {
SetHRESULT(aHresultPtr, hr);
return false;
}
@ -195,6 +207,7 @@ LayerManagerD3D10::Initialize(bool force)
hr = mDevice->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mVertexBuffer));
if (FAILED(hr)) {
SetHRESULT(aHresultPtr, hr);
return false;
}
@ -247,7 +260,8 @@ LayerManagerD3D10::Initialize(bool force)
dxgiDevice, (IUnknown *)mWidget->GetNativeData(NS_NATIVE_ICOREWINDOW),
&swapDesc, nullptr, getter_AddRefs(swapChain1));
if (FAILED(hr)) {
return false;
SetHRESULT(aHresultPtr, hr);
return false;
}
mSwapChain = swapChain1;
} else

Просмотреть файл

@ -60,9 +60,9 @@ public:
* to draw to the window. If this method fails the device cannot be used.
* This function is not threadsafe.
*
* \return True is initialization was succesful, false when it was not.
* return True is initialization was succesful, false when it was not.
*/
bool Initialize(bool force = false);
bool Initialize(bool force = false, HRESULT* aHresultPtr = nullptr);
/*
* LayerManager implementation.

Просмотреть файл

@ -23,6 +23,9 @@
#include "Layers.h"
#include "BasicLayers.h"
#include "Windows.Graphics.Display.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#endif
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
@ -822,6 +825,8 @@ MetroWidget::GetLayerManager(PLayersChild* aShadowManager,
}
}
HRESULT hr = S_OK;
// Create a layer manager: try to use an async compositor first, if enabled.
// Otherwise fall back on the main thread d3d manager.
if (!mLayerManager) {
@ -831,13 +836,12 @@ MetroWidget::GetLayerManager(PLayersChild* aShadowManager,
} else if (ShouldUseMainThreadD3D10Manager()) {
nsRefPtr<mozilla::layers::LayerManagerD3D10> layerManager =
new mozilla::layers::LayerManagerD3D10(this);
if (layerManager->Initialize(true)) {
if (layerManager->Initialize(true, &hr)) {
mLayerManager = layerManager;
}
} else if (ShouldUseBasicManager()) {
mLayerManager = CreateBasicLayerManager();
}
// Either we're not ready to initialize yet due to a missing view pointer,
// or something has gone wrong.
if (!mLayerManager) {
@ -846,6 +850,16 @@ MetroWidget::GetLayerManager(PLayersChild* aShadowManager,
mLayerManager = new BasicShadowLayerManager(this);
mTempBasicLayerInUse = true;
} else {
#ifdef MOZ_CRASHREPORTER
if (FAILED(hr)) {
char errorBuf[10];
errorBuf[0] = '\0';
_snprintf_s(errorBuf, sizeof(errorBuf), _TRUNCATE, "%X", hr);
CrashReporter::
AnnotateCrashReport(NS_LITERAL_CSTRING("HRESULT"),
nsDependentCString(errorBuf));
}
#endif
NS_RUNTIMEABORT("Couldn't create layer manager");
}
}