Don't use Direct2D if CompositorD3D11::Initialize fails. (bug 1208638, r=jrmuizel)

--HG--
extra : rebase_source : 2c0b1febd9bcc3a52f48a98243ab853f5b58848d
This commit is contained in:
David Anderson 2015-09-30 16:16:16 -07:00
Родитель 3985b32cf2
Коммит b0e2473678
8 изменённых файлов: 38 добавлений и 14 удалений

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

@ -81,7 +81,7 @@ nsSVGPathGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
{
// We only cache the path if it matches the backend used for screen painting:
bool cacheable = aDrawTarget.GetBackendType() ==
gfxPlatform::GetPlatform()->GetContentBackend();
gfxPlatform::GetPlatform()->GetDefaultContentBackend();
// Checking for and returning mCachedPath before checking the pref means
// that the pref is only live on page reload (or app restart for SVG in

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

@ -74,7 +74,7 @@ BasicCompositor::BasicCompositor(nsIWidget *aWidget)
SetBackend(LayersBackend::LAYERS_BASIC);
mMaxTextureSize =
Factory::GetMaxSurfaceSize(gfxPlatform::GetPlatform()->GetContentBackend());
Factory::GetMaxSurfaceSize(gfxPlatform::GetPlatform()->GetContentBackendFor(LayersBackend::LAYERS_BASIC));
}
BasicCompositor::~BasicCompositor()

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

@ -343,13 +343,13 @@ CreateBufferTextureClient(ISurfaceAllocator* aAllocator,
}
static inline gfx::BackendType
BackendTypeForBackendSelector(BackendSelector aSelector)
BackendTypeForBackendSelector(LayersBackend aLayersBackend, BackendSelector aSelector)
{
switch (aSelector) {
case BackendSelector::Canvas:
return gfxPlatform::GetPlatform()->GetPreferredCanvasBackend();
case BackendSelector::Content:
return gfxPlatform::GetPlatform()->GetContentBackend();
return gfxPlatform::GetPlatform()->GetContentBackendFor(aLayersBackend);
default:
MOZ_ASSERT_UNREACHABLE("Unknown backend selector");
return gfx::BackendType::NONE;
@ -365,7 +365,8 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(aSelector);
LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(parentBackend, aSelector);
RefPtr<TextureClient> texture;
@ -374,7 +375,6 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
#endif
#ifdef XP_WIN
LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
if (parentBackend == LayersBackend::LAYERS_D3D11 &&
(moz2DBackend == gfx::BackendType::DIRECT2D ||
moz2DBackend == gfx::BackendType::DIRECT2D1_1) &&
@ -407,7 +407,6 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
#endif
#ifdef MOZ_X11
LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
gfxSurfaceType type =
gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType();

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

@ -579,7 +579,8 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag
// When we're not on the main thread we're not going to be using Direct2D
// to access the contents of this texture client so we will always use D3D11.
bool haveD3d11Backend = windowsPlatform->GetContentBackend() == BackendType::DIRECT2D1_1 || !NS_IsMainThread();
BackendType backend = windowsPlatform->GetContentBackendFor(LayersBackend::LAYERS_D3D11);
bool haveD3d11Backend = (backend == BackendType::DIRECT2D1_1) || !NS_IsMainThread();
if (haveD3d11Backend) {
if (!AllocateD3D11Surface(d3d11device, aSize)) {

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

@ -271,7 +271,16 @@ public:
}
void GetApzSupportInfo(mozilla::widget::InfoObject& aObj);
mozilla::gfx::BackendType GetContentBackend() {
// Get the default content backend that will be used with the default
// compositor. If the compositor is known when calling this function,
// GetContentBackendFor() should be called instead.
mozilla::gfx::BackendType GetDefaultContentBackend() {
return mContentBackend;
}
// Return the best content backend available that is compatible with the
// given layers backend.
virtual mozilla::gfx::BackendType GetContentBackendFor(mozilla::layers::LayersBackend aLayers) {
return mContentBackend;
}

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

@ -99,8 +99,8 @@ public:
bool UseXRender() {
#if defined(MOZ_X11)
if (GetContentBackend() != mozilla::gfx::BackendType::NONE &&
GetContentBackend() != mozilla::gfx::BackendType::CAIRO)
if (GetDefaultContentBackend() != mozilla::gfx::BackendType::NONE &&
GetDefaultContentBackend() != mozilla::gfx::BackendType::CAIRO)
return false;
return sUseXRender;

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

@ -512,12 +512,14 @@ gfxWindowsPlatform::HandleDeviceReset()
return true;
}
static const BackendType SOFTWARE_BACKEND = BackendType::CAIRO;
void
gfxWindowsPlatform::UpdateBackendPrefs()
{
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
BackendType defaultBackend = BackendType::CAIRO;
uint32_t canvasMask = BackendTypeBit(SOFTWARE_BACKEND);
uint32_t contentMask = BackendTypeBit(SOFTWARE_BACKEND);
BackendType defaultBackend = SOFTWARE_BACKEND;
if (GetD2DStatus() == FeatureStatus::Available) {
mRenderMode = RENDER_DIRECT2D;
canvasMask |= BackendTypeBit(BackendType::DIRECT2D);
@ -550,6 +552,17 @@ gfxWindowsPlatform::UpdateRenderMode()
}
}
mozilla::gfx::BackendType
gfxWindowsPlatform::GetContentBackendFor(mozilla::layers::LayersBackend aLayers)
{
if (aLayers == LayersBackend::LAYERS_D3D11) {
return gfxPlatform::GetDefaultContentBackend();
}
// If we're not accelerated with D3D11, never use D2D.
return SOFTWARE_BACKEND;
}
#ifdef CAIRO_HAS_D2D_SURFACE
HRESULT
gfxWindowsPlatform::CreateDevice(nsRefPtr<IDXGIAdapter1> &adapter1,

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

@ -345,6 +345,8 @@ private:
IDXGIAdapter1 *GetDXGIAdapter();
bool IsDeviceReset(HRESULT hr, DeviceResetReason* aReason);
mozilla::gfx::BackendType GetContentBackendFor(mozilla::layers::LayersBackend aLayers) override;
#ifdef CAIRO_HAS_DWRITE_FONT
nsRefPtr<IDWriteFactory> mDWriteFactory;
nsRefPtr<IDWriteRenderingParams> mRenderingParams[TEXT_RENDERING_COUNT];