From 80fa3494e1cb1aa9966f7ffb00247c20ce61ff6f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 8 Mar 2017 00:17:36 -0800 Subject: [PATCH] Remove references to the Direct3D9 compositor. (bug 1318558 part 1, r=mattwoodrow) --- gfx/config/gfxFeature.h | 1 - gfx/ipc/GPUChild.cpp | 1 - gfx/ipc/GPUParent.cpp | 5 - gfx/ipc/GraphicsMessages.ipdlh | 2 - gfx/layers/D3D9SurfaceImage.cpp | 83 ++++++++++++++++- gfx/layers/D3D9SurfaceImage.h | 48 ++++++++++ gfx/layers/IMFYCbCrImage.cpp | 106 ---------------------- gfx/layers/IMFYCbCrImage.h | 4 - gfx/layers/client/CompositableClient.cpp | 1 - gfx/layers/client/TextureClient.cpp | 11 --- gfx/layers/composite/TextureHost.cpp | 14 +-- gfx/layers/d3d11/CompositorD3D11.cpp | 1 - gfx/layers/ipc/CompositorBridgeParent.cpp | 11 --- gfx/src/DriverCrashGuard.cpp | 6 +- gfx/tests/gtest/TextureHelper.h | 54 +---------- gfx/thebes/gfxPrefs.h | 2 - gfx/thebes/gfxWindowsPlatform.cpp | 66 +------------- gfx/thebes/gfxWindowsPlatform.h | 1 - gfx/thebes/moz.build | 2 +- layout/ipc/RenderFrameParent.cpp | 3 - old-configure.in | 3 - 21 files changed, 140 insertions(+), 285 deletions(-) diff --git a/gfx/config/gfxFeature.h b/gfx/config/gfxFeature.h index 542b64f67af4..5db081fa8ef4 100644 --- a/gfx/config/gfxFeature.h +++ b/gfx/config/gfxFeature.h @@ -19,7 +19,6 @@ namespace gfx { /* Name, Type, Description */ \ _(HW_COMPOSITING, Feature, "Compositing") \ _(D3D11_COMPOSITING, Feature, "Direct3D11 Compositing") \ - _(D3D9_COMPOSITING, Feature, "Direct3D9 Compositing") \ _(OPENGL_COMPOSITING, Feature, "OpenGL Compositing") \ _(DIRECT2D, Feature, "Direct2D") \ _(D3D11_HW_ANGLE, Feature, "Direct3D11 hardware ANGLE") \ diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index d8512e460f10..90d2a2fe4e24 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -58,7 +58,6 @@ GPUChild::Init() DevicePrefs devicePrefs; devicePrefs.hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING); devicePrefs.d3d11Compositing() = gfxConfig::GetValue(Feature::D3D11_COMPOSITING); - devicePrefs.d3d9Compositing() = gfxConfig::GetValue(Feature::D3D9_COMPOSITING); devicePrefs.oglCompositing() = gfxConfig::GetValue(Feature::OPENGL_COMPOSITING); devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D); diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index fb6cb2ad62da..de4a87ef9d1e 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -38,7 +38,6 @@ #include "VRManagerParent.h" #include "VsyncBridgeParent.h" #if defined(XP_WIN) -# include "DeviceManagerD3D9.h" # include "mozilla/gfx/DeviceManagerDx.h" # include #endif @@ -103,7 +102,6 @@ GPUParent::Init(base::ProcessId aParentPid, gfxPlatform::InitMoz2DLogging(); #if defined(XP_WIN) DeviceManagerDx::Init(); - DeviceManagerD3D9::Init(); #endif if (NS_FAILED(NS_InitMinimalXPCOM())) { @@ -162,7 +160,6 @@ GPUParent::RecvInit(nsTArray&& prefs, // Inherit device preferences. gfxConfig::Inherit(Feature::HW_COMPOSITING, devicePrefs.hwCompositing()); gfxConfig::Inherit(Feature::D3D11_COMPOSITING, devicePrefs.d3d11Compositing()); - gfxConfig::Inherit(Feature::D3D9_COMPOSITING, devicePrefs.d3d9Compositing()); gfxConfig::Inherit(Feature::OPENGL_COMPOSITING, devicePrefs.oglCompositing()); gfxConfig::Inherit(Feature::DIRECT2D, devicePrefs.useD2D1()); @@ -275,7 +272,6 @@ mozilla::ipc::IPCResult GPUParent::RecvGetDeviceStatus(GPUDeviceData* aOut) { CopyFeatureChange(Feature::D3D11_COMPOSITING, &aOut->d3d11Compositing()); - CopyFeatureChange(Feature::D3D9_COMPOSITING, &aOut->d3d9Compositing()); CopyFeatureChange(Feature::OPENGL_COMPOSITING, &aOut->oglCompositing()); #if defined(XP_WIN) @@ -423,7 +419,6 @@ GPUParent::ActorDestroy(ActorDestroyReason aWhy) Factory::ShutDown(); #if defined(XP_WIN) DeviceManagerDx::Shutdown(); - DeviceManagerD3D9::Shutdown(); #endif LayerTreeOwnerTracker::Shutdown(); gfxVars::Shutdown(); diff --git a/gfx/ipc/GraphicsMessages.ipdlh b/gfx/ipc/GraphicsMessages.ipdlh index cc4115d42578..f806f67bd45c 100644 --- a/gfx/ipc/GraphicsMessages.ipdlh +++ b/gfx/ipc/GraphicsMessages.ipdlh @@ -27,7 +27,6 @@ struct DevicePrefs { FeatureStatus hwCompositing; FeatureStatus d3d11Compositing; - FeatureStatus d3d9Compositing; FeatureStatus oglCompositing; FeatureStatus useD2D1; }; @@ -63,7 +62,6 @@ union GPUDeviceStatus struct GPUDeviceData { FeatureChange d3d11Compositing; - FeatureChange d3d9Compositing; FeatureChange oglCompositing; GPUDeviceStatus gpuDevice; }; diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp index 91dce6291dcd..c5538105dc5c 100644 --- a/gfx/layers/D3D9SurfaceImage.cpp +++ b/gfx/layers/D3D9SurfaceImage.cpp @@ -5,7 +5,7 @@ #include "D3D9SurfaceImage.h" #include "gfx2DGlue.h" -#include "mozilla/layers/TextureD3D9.h" +#include "gfxWindowsPlatform.h" #include "mozilla/layers/CompositableClient.h" #include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/ImageBridgeChild.h" @@ -14,6 +14,87 @@ namespace mozilla { namespace layers { +DXGID3D9TextureData::DXGID3D9TextureData(gfx::SurfaceFormat aFormat, + IDirect3DTexture9* aTexture, HANDLE aHandle, + IDirect3DDevice9* aDevice) +: mDevice(aDevice) +, mTexture(aTexture) +, mFormat(aFormat) +, mHandle(aHandle) +{ + MOZ_COUNT_CTOR(DXGID3D9TextureData); +} + +DXGID3D9TextureData::~DXGID3D9TextureData() +{ + gfxWindowsPlatform::sD3D9SharedTextures -= mDesc.Width * mDesc.Height * 4; + MOZ_COUNT_DTOR(DXGID3D9TextureData); +} + +// static +DXGID3D9TextureData* +DXGID3D9TextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, + TextureFlags aFlags, + IDirect3DDevice9* aDevice) +{ + PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS); + MOZ_ASSERT(aFormat == gfx::SurfaceFormat::B8G8R8A8); + if (aFormat != gfx::SurfaceFormat::B8G8R8A8) { + return nullptr; + } + + RefPtr texture; + HANDLE shareHandle = nullptr; + HRESULT hr = aDevice->CreateTexture(aSize.width, aSize.height, + 1, + D3DUSAGE_RENDERTARGET, + D3DFMT_A8R8G8B8, + D3DPOOL_DEFAULT, + getter_AddRefs(texture), + &shareHandle); + if (FAILED(hr) || !shareHandle) { + return nullptr; + } + + D3DSURFACE_DESC surfaceDesc; + hr = texture->GetLevelDesc(0, &surfaceDesc); + if (FAILED(hr)) { + return nullptr; + } + DXGID3D9TextureData* data = new DXGID3D9TextureData(aFormat, texture, shareHandle, aDevice); + data->mDesc = surfaceDesc; + + gfxWindowsPlatform::sD3D9SharedTextures += aSize.width * aSize.height * 4; + return data; +} + +void +DXGID3D9TextureData::FillInfo(TextureData::Info& aInfo) const +{ + aInfo.size = GetSize(); + aInfo.format = mFormat; + aInfo.supportsMoz2D = false; + aInfo.canExposeMappedData = false; + aInfo.hasIntermediateBuffer = false; + aInfo.hasSynchronization = false; +} + +already_AddRefed +DXGID3D9TextureData::GetD3D9Surface() const +{ + RefPtr textureSurface; + HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(textureSurface)); + NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); + + return textureSurface.forget(); +} + +bool +DXGID3D9TextureData::Serialize(SurfaceDescriptor& aOutDescriptor) +{ + aOutDescriptor = SurfaceDescriptorD3D10((WindowsHandle)(mHandle), mFormat, GetSize()); + return true; +} D3D9SurfaceImage::D3D9SurfaceImage() : Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE) diff --git a/gfx/layers/D3D9SurfaceImage.h b/gfx/layers/D3D9SurfaceImage.h index a5326bb996df..81cfa2caddde 100644 --- a/gfx/layers/D3D9SurfaceImage.h +++ b/gfx/layers/D3D9SurfaceImage.h @@ -40,6 +40,54 @@ protected: RefPtr mDevice; }; +/** + * Wraps a D3D9 texture, shared with the compositor though DXGI. + * At the moment it is only used with D3D11 compositing, and the corresponding + * TextureHost is DXGITextureHostD3D11. + */ +class DXGID3D9TextureData : public TextureData +{ +public: + static DXGID3D9TextureData* + Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureFlags aFlags, IDirect3DDevice9* aDevice); + + ~DXGID3D9TextureData(); + + virtual void FillInfo(TextureData::Info& aInfo) const override; + + virtual bool Lock(OpenMode) override { return true; } + + virtual void Unlock() override {} + + virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override; + + virtual void Deallocate(LayersIPCChannel* aAllocator) override {} + + IDirect3DDevice9* GetD3D9Device() { return mDevice; } + IDirect3DTexture9* GetD3D9Texture() { return mTexture; } + HANDLE GetShareHandle() const { return mHandle; } + already_AddRefed GetD3D9Surface() const; + + const D3DSURFACE_DESC& GetDesc() const + { + return mDesc; + } + + gfx::IntSize GetSize() const { return gfx::IntSize(mDesc.Width, mDesc.Height); } + +protected: + DXGID3D9TextureData(gfx::SurfaceFormat aFormat, + IDirect3DTexture9* aTexture, HANDLE aHandle, + IDirect3DDevice9* aDevice); + + RefPtr mDevice; + RefPtr mTexture; + gfx::SurfaceFormat mFormat; + HANDLE mHandle; + D3DSURFACE_DESC mDesc; +}; + + // Image class that wraps a IDirect3DSurface9. This class copies the image // passed into SetData(), so that it can be accessed from other D3D devices. // This class also manages the synchronization of the copy, to ensure the diff --git a/gfx/layers/IMFYCbCrImage.cpp b/gfx/layers/IMFYCbCrImage.cpp index 2e93e9d34a61..e91aa4daa9a2 100644 --- a/gfx/layers/IMFYCbCrImage.cpp +++ b/gfx/layers/IMFYCbCrImage.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "IMFYCbCrImage.h" -#include "DeviceManagerD3D9.h" #include "mozilla/layers/TextureD3D11.h" #include "mozilla/layers/CompositableClient.h" #include "mozilla/layers/CompositableForwarder.h" @@ -133,91 +132,6 @@ FinishTextures(IDirect3DDevice9* aDevice, return true; } -static bool UploadData(IDirect3DDevice9* aDevice, - RefPtr& aTexture, - HANDLE& aHandle, - uint8_t* aSrc, - const gfx::IntSize& aSrcSize, - int32_t aSrcStride) -{ - RefPtr surf; - D3DLOCKED_RECT rect; - aTexture = InitTextures(aDevice, aSrcSize, D3DFMT_A8, surf, aHandle, rect); - if (!aTexture) { - return false; - } - - if (aSrcStride == rect.Pitch) { - memcpy(rect.pBits, aSrc, rect.Pitch * aSrcSize.height); - } else { - for (int i = 0; i < aSrcSize.height; i++) { - memcpy((uint8_t*)rect.pBits + i * rect.Pitch, - aSrc + i * aSrcStride, - aSrcSize.width); - } - } - - return FinishTextures(aDevice, aTexture, surf); -} - -DXGIYCbCrTextureData* -IMFYCbCrImage::GetD3D9TextureData(Data aData, gfx::IntSize aSize) -{ - RefPtr device = DeviceManagerD3D9::GetDevice(); - if (!device) { - return nullptr; - } - - RefPtr textureY; - HANDLE shareHandleY = 0; - if (!UploadData(device, textureY, shareHandleY, - aData.mYChannel, aData.mYSize, aData.mYStride)) { - return nullptr; - } - - RefPtr textureCb; - HANDLE shareHandleCb = 0; - if (!UploadData(device, textureCb, shareHandleCb, - aData.mCbChannel, aData.mCbCrSize, aData.mCbCrStride)) { - return nullptr; - } - - RefPtr textureCr; - HANDLE shareHandleCr = 0; - if (!UploadData(device, textureCr, shareHandleCr, - aData.mCrChannel, aData.mCbCrSize, aData.mCbCrStride)) { - return nullptr; - } - - RefPtr query; - HRESULT hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query)); - hr = query->Issue(D3DISSUE_END); - - int iterations = 0; - bool valid = false; - while (iterations < 10) { - HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH); - if (hr == S_FALSE) { - Sleep(1); - iterations++; - continue; - } - if (hr == S_OK) { - valid = true; - } - break; - } - - if (!valid) { - return nullptr; - } - - return DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT, textureY, - textureCb, textureCr, shareHandleY, - shareHandleCb, shareHandleCr, aSize, - aData.mYSize, aData.mCbCrSize); -} - DXGIYCbCrTextureData* IMFYCbCrImage::GetD3D11TextureData(Data aData, gfx::IntSize aSize) { @@ -313,22 +227,6 @@ IMFYCbCrImage::GetD3D11TextureData(Data aData, gfx::IntSize aSize) aData.mCbCrSize); } -TextureClient* -IMFYCbCrImage::GetD3D9TextureClient(KnowsCompositor* aForwarder) -{ - DXGIYCbCrTextureData* textureData = GetD3D9TextureData(mData, GetSize()); - if (textureData == nullptr) { - return nullptr; - } - - mTextureClient = TextureClient::CreateWithData( - textureData, TextureFlags::DEFAULT, - aForwarder->GetTextureForwarder() - ); - - return mTextureClient; -} - TextureClient* IMFYCbCrImage::GetD3D11TextureClient(KnowsCompositor* aForwarder) { @@ -362,10 +260,6 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder) LayersBackend backend = aForwarder->GetCompositorBackendType(); if (!device || backend != LayersBackend::LAYERS_D3D11) { - if (backend == LayersBackend::LAYERS_D3D9 || - backend == LayersBackend::LAYERS_D3D11) { - return GetD3D9TextureClient(aForwarder); - } return nullptr; } return GetD3D11TextureClient(aForwarder); diff --git a/gfx/layers/IMFYCbCrImage.h b/gfx/layers/IMFYCbCrImage.h index eaca37f5b10a..c4c70e111a86 100644 --- a/gfx/layers/IMFYCbCrImage.h +++ b/gfx/layers/IMFYCbCrImage.h @@ -23,13 +23,9 @@ public: virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override; - static DXGIYCbCrTextureData* GetD3D9TextureData(Data aData, - gfx::IntSize aSize); static DXGIYCbCrTextureData* GetD3D11TextureData(Data aData, gfx::IntSize aSize); protected: - - TextureClient* GetD3D9TextureClient(KnowsCompositor* aForwarder); TextureClient* GetD3D11TextureClient(KnowsCompositor* aForwarder); ~IMFYCbCrImage(); diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp index 6be6ab738d0f..785cd8d59067 100644 --- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -15,7 +15,6 @@ #ifdef XP_WIN #include "gfxWindowsPlatform.h" // for gfxWindowsPlatform #include "mozilla/layers/TextureD3D11.h" -#include "mozilla/layers/TextureD3D9.h" #endif #include "gfxUtils.h" #include "IPDLActor.h" diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 0d8e4b70b33f..59ddbf990bba 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -34,9 +34,7 @@ #include "mozilla/ipc/CrossProcessSemaphore.h" #ifdef XP_WIN -#include "DeviceManagerD3D9.h" #include "mozilla/gfx/DeviceManagerDx.h" -#include "mozilla/layers/TextureD3D9.h" #include "mozilla/layers/TextureD3D11.h" #include "mozilla/layers/TextureDIB.h" #include "gfxWindowsPlatform.h" @@ -1051,15 +1049,6 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator, { data = DXGITextureData::Create(aSize, aFormat, aAllocFlags); } - if (aLayersBackend == LayersBackend::LAYERS_D3D9 && - moz2DBackend == gfx::BackendType::CAIRO && - aAllocator->IsSameProcess() && - aSize.width <= aMaxTextureSize && - aSize.height <= aMaxTextureSize && - NS_IsMainThread() && - DeviceManagerD3D9::GetDevice()) { - data = D3D9TextureData::Create(aSize, aFormat, aAllocFlags); - } if (aLayersBackend != LayersBackend::LAYERS_WR && !data && aFormat == SurfaceFormat::B8G8R8X8 && diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index cc8ae604454a..8be73130aaff 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -173,11 +173,6 @@ already_AddRefed CreateTextureHostD3D11(const SurfaceDescriptor& aD ISurfaceAllocator* aDeallocator, TextureFlags aFlags); -// implemented in TextureD3D9.cpp -already_AddRefed CreateTextureHostD3D9(const SurfaceDescriptor& aDesc, - ISurfaceAllocator* aDeallocator, - TextureFlags aFlags); - already_AddRefed TextureHost::Create(const SurfaceDescriptor& aDesc, ISurfaceAllocator* aDeallocator, @@ -212,16 +207,9 @@ TextureHost::Create(const SurfaceDescriptor& aDesc, #endif #ifdef XP_WIN - case SurfaceDescriptor::TSurfaceDescriptorD3D9: - return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags); - case SurfaceDescriptor::TSurfaceDescriptorD3D10: case SurfaceDescriptor::TSurfaceDescriptorDXGIYCbCr: - if (aBackend == LayersBackend::LAYERS_D3D9) { - return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags); - } else { - return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags); - } + return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags); #endif default: MOZ_CRASH("GFX: Unsupported Surface type host"); diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 5d8a894da3b5..99e0a122790a 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -30,7 +30,6 @@ #include "BlendShaderConstants.h" #include "D3D11ShareHandleImage.h" -#include "D3D9SurfaceImage.h" #include diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 38d613526c9e..0abba30ee096 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -72,7 +72,6 @@ #include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop #ifdef XP_WIN #include "mozilla/layers/CompositorD3D11.h" -#include "mozilla/layers/CompositorD3D9.h" #endif #include "GeckoProfiler.h" #include "mozilla/ipc/ProtocolTypes.h" @@ -1389,8 +1388,6 @@ CompositorBridgeParent::NewCompositor(const nsTArray& aBackendHin #ifdef XP_WIN } else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11) { compositor = new CompositorD3D11(this, mWidget); - } else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9) { - compositor = new CompositorD3D9(this, mWidget); #endif } nsCString failureReason; @@ -1404,9 +1401,6 @@ CompositorBridgeParent::NewCompositor(const nsTArray& aBackendHin Telemetry::Accumulate(Telemetry::OPENGL_COMPOSITING_FAILURE_ID, failureReason); } #ifdef XP_WIN - else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9){ - Telemetry::Accumulate(Telemetry::D3D9_COMPOSITING_FAILURE_ID, failureReason); - } else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11){ Telemetry::Accumulate(Telemetry::D3D11_COMPOSITING_FAILURE_ID, failureReason); } @@ -1423,11 +1417,6 @@ CompositorBridgeParent::NewCompositor(const nsTArray& aBackendHin Telemetry::Accumulate(Telemetry::OPENGL_COMPOSITING_FAILURE_ID, failureReason); } #ifdef XP_WIN - else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9){ - gfxCriticalNote << "[D3D9] Failed to init compositor with reason: " - << failureReason.get(); - Telemetry::Accumulate(Telemetry::D3D9_COMPOSITING_FAILURE_ID, failureReason); - } else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11){ gfxCriticalNote << "[D3D11] Failed to init compositor with reason: " << failureReason.get(); diff --git a/gfx/src/DriverCrashGuard.cpp b/gfx/src/DriverCrashGuard.cpp index e7db923981f7..f1f09a0187e7 100644 --- a/gfx/src/DriverCrashGuard.cpp +++ b/gfx/src/DriverCrashGuard.cpp @@ -5,6 +5,7 @@ #include "DriverCrashGuard.h" #include "gfxEnv.h" #include "gfxPrefs.h" +#include "gfxConfig.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" #ifdef MOZ_CRASHREPORTER @@ -456,10 +457,7 @@ D3D11LayersCrashGuard::UpdateEnvironment() (!gfxPrefs::Direct2DDisabled() && FeatureEnabled(nsIGfxInfo::FEATURE_DIRECT2D)); changed |= CheckAndUpdateBoolPref("feature-d2d", d2dEnabled); - bool d3d11Enabled = !gfxPrefs::LayersPreferD3D9(); - if (!FeatureEnabled(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS)) { - d3d11Enabled = false; - } + bool d3d11Enabled = gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING); changed |= CheckAndUpdateBoolPref("feature-d3d11", d3d11Enabled); #endif diff --git a/gfx/tests/gtest/TextureHelper.h b/gfx/tests/gtest/TextureHelper.h index 8d7953a484b5..f2d1d9840103 100644 --- a/gfx/tests/gtest/TextureHelper.h +++ b/gfx/tests/gtest/TextureHelper.h @@ -14,11 +14,9 @@ #include "mozilla/layers/TextureHost.h" #include "mozilla/RefPtr.h" #ifdef XP_WIN -#include "DeviceManagerD3D9.h" #include "IMFYCbCrImage.h" #include "mozilla/gfx/DeviceManagerDx.h" #include "mozilla/layers/TextureD3D11.h" -#include "mozilla/layers/TextureD3D9.h" #include "mozilla/layers/TextureDIB.h" #endif @@ -26,42 +24,6 @@ using mozilla::gfx::SurfaceFormat; namespace mozilla { namespace layers { -#ifdef XP_WIN - -TextureData* -CreateDXGID3D9TextureData(IntSize aSize, SurfaceFormat aFormat, - TextureFlags aTextureFlag) -{ - - RefPtr d3d9Ex; - HMODULE d3d9lib = LoadLibraryW(L"d3d9.dll"); - decltype(Direct3DCreate9Ex)* d3d9Create = - (decltype(Direct3DCreate9Ex)*)GetProcAddress(d3d9lib, "Direct3DCreate9Ex"); - HRESULT hr = d3d9Create(D3D_SDK_VERSION, getter_AddRefs(d3d9Ex)); - - if (!d3d9Ex) { - return nullptr; - } - - D3DPRESENT_PARAMETERS params = { 0 }; - params.BackBufferWidth = 1; - params.BackBufferHeight = 1; - params.BackBufferFormat = D3DFMT_A8R8G8B8; - params.BackBufferCount = 1; - params.SwapEffect = D3DSWAPEFFECT_DISCARD; - params.hDeviceWindow = nullptr; - params.Windowed = TRUE; - params.Flags = D3DPRESENTFLAG_VIDEO; - - RefPtr device; - hr = d3d9Ex->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, nullptr, - D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | - D3DCREATE_MIXED_VERTEXPROCESSING, - ¶ms, nullptr, getter_AddRefs(device)); - - return DXGID3D9TextureData::Create(aSize, aFormat, aTextureFlag, device); -} -#endif /** * Create a YCbCrTextureClient according to the given backend. @@ -109,13 +71,7 @@ CreateYCbCrTextureClientWithBackend(LayersBackend aLayersBackend) #ifdef XP_WIN RefPtr device = DeviceManagerDx::Get()->GetContentDevice(); - if (!device || aLayersBackend != LayersBackend::LAYERS_D3D11) { - if (aLayersBackend == LayersBackend::LAYERS_D3D11 || - aLayersBackend == LayersBackend::LAYERS_D3D9) { - // Create GetD3D9TextureData. - data = IMFYCbCrImage::GetD3D9TextureData(clientData, size); - } - } else { + if (device && aLayersBackend == LayersBackend::LAYERS_D3D11) { // Create YCbCrD3D11TextureData data = IMFYCbCrImage::GetD3D11TextureData(clientData, size); } @@ -154,14 +110,6 @@ CreateTextureClientWithBackend(LayersBackend aLayersBackend) moz2DBackend == BackendType::DIRECT2D1_1)) { // Create DXGITextureData. data = DXGITextureData::Create(size, format, allocFlags); - } else if (aLayersBackend == LayersBackend::LAYERS_D3D9 && - moz2DBackend == BackendType::CAIRO) { - // Create DXGID3D9TextureData or D3D9TextureData. - data = CreateDXGID3D9TextureData(size, format, textureFlags); - - if (!data && DeviceManagerD3D9::GetDevice()) { - data = D3D9TextureData::Create(size, format, allocFlags); - } } else if (!data && format == SurfaceFormat::B8G8R8X8 && moz2DBackend == BackendType::CAIRO) { // Create DIBTextureData. diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 355d1efb3839..42237858ccd2 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -466,7 +466,6 @@ private: DECL_GFX_PREF(Live, "layers.advanced.boxshadow-outer-layers", LayersAllowOuterBoxShadow, bool, false); DECL_GFX_PREF(Live, "layers.advanced.boxshadow-inset-layers", LayersAllowInsetBoxShadow, bool, false); DECL_GFX_PREF(Live, "layers.advanced.outline-layers", LayersAllowOutlineLayers, bool, false); - DECL_GFX_PREF(Skip, "layers.allow-d3d9-fallback", LayersAllowD3D9Fallback, bool, false); DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled", LayersAMDSwitchableGfxEnabled, bool, false); DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true); DECL_GFX_PREF(Once, "layers.async-pan-zoom.separate-event-thread", AsyncPanZoomSeparateEventThread, bool, false); @@ -517,7 +516,6 @@ private: DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-disabled", LayersOffMainThreadCompositionForceDisabled, bool, false); DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1); DECL_GFX_PREF(Live, "layers.orientation.sync.timeout", OrientationSyncMillis, uint32_t, (uint32_t)0); - DECL_GFX_PREF(Skip, "layers.prefer-d3d9", LayersPreferD3D9, bool, false); DECL_GFX_PREF(Once, "layers.prefer-opengl", LayersPreferOpenGL, bool, false); DECL_GFX_PREF(Live, "layers.progressive-paint", ProgressivePaint, bool, false); DECL_GFX_PREF(Live, "layers.shared-buffer-provider.enabled", PersistentBufferProviderSharedEnabled, bool, false); diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index adc6a762edd1..860245a8d08f 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -37,7 +37,6 @@ #include "gfxGDIFont.h" #include "mozilla/layers/CompositorThread.h" -#include "DeviceManagerD3D9.h" #include "mozilla/layers/ReadbackManagerD3D11.h" #include "gfxDWriteFontList.h" @@ -325,7 +324,6 @@ gfxWindowsPlatform::~gfxWindowsPlatform() { mozilla::gfx::Factory::D2DCleanup(); - DeviceManagerD3D9::Shutdown(); DeviceManagerDx::Shutdown(); /* @@ -357,7 +355,6 @@ gfxWindowsPlatform::InitAcceleration() mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3); DeviceManagerDx::Init(); - DeviceManagerD3D9::Init(); InitializeConfig(); InitializeDevices(); @@ -381,7 +378,7 @@ gfxWindowsPlatform::CanUseHardwareVideoDecoding() if (!dm) { return false; } - if (!gfxPrefs::LayersPreferD3D9() && !dm->TextureSharingWorks()) { + if (!dm->TextureSharingWorks()) { return false; } return !dm->IsWARP() && gfxPlatform::CanUseHardwareVideoDecoding(); @@ -1325,7 +1322,6 @@ gfxWindowsPlatform::InitializeConfig() if (XRE_IsParentProcess()) { // The parent process first determines which features can be attempted. // This information is relayed to content processes and the GPU process. - InitializeD3D9Config(); InitializeD3D11Config(); InitializeANGLEConfig(); InitializeD2DConfig(); @@ -1335,40 +1331,6 @@ gfxWindowsPlatform::InitializeConfig() } } -void -gfxWindowsPlatform::InitializeD3D9Config() -{ - MOZ_ASSERT(XRE_IsParentProcess()); - - FeatureState& d3d9 = gfxConfig::GetFeature(Feature::D3D9_COMPOSITING); - - if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) { - d3d9.DisableByDefault(FeatureStatus::Unavailable, "Hardware compositing is disabled", - NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D9_NEED_HWCOMP")); - return; - } - - d3d9.SetDefaultFromPref( - gfxPrefs::GetLayersAllowD3D9FallbackPrefName(), - true, - gfxPrefs::GetLayersAllowD3D9FallbackPrefDefault()); - - if (!d3d9.IsEnabled() && gfxPrefs::LayersPreferD3D9()) { - d3d9.UserEnable("Direct3D9 enabled via layers.prefer-d3d9"); - } - - nsCString message; - nsCString failureId; - if (!gfxPlatform::IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, &message, - failureId)) { - d3d9.Disable(FeatureStatus::Blacklisted, message.get(), failureId); - } - - if (gfxConfig::IsForcedOnByUser(Feature::HW_COMPOSITING)) { - d3d9.UserForceEnable("Hardware compositing is force-enabled"); - } -} - void gfxWindowsPlatform::InitializeD3D11Config() { @@ -1384,13 +1346,6 @@ gfxWindowsPlatform::InitializeD3D11Config() d3d11.EnableByDefault(); - // If the user prefers D3D9, act as though they disabled D3D11. - if (gfxPrefs::LayersPreferD3D9()) { - d3d11.UserDisable("Disabled due to user preference for Direct3D 9", - NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_PREF")); - return; - } - nsCString message; nsCString failureId; if (!gfxPlatform::IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, &message, failureId)) { @@ -1474,8 +1429,8 @@ gfxWindowsPlatform::InitializeD3D11() // is not blacklisted for D3D11 layers. This first attempt will try to create // a hardware accelerated device. If this creation fails or the hardware is // blacklisted, then this function will abort if WARP is disabled, causing us - // to fallback to D3D9 or Basic layers. If WARP is not disabled it will use - // a WARP device which should always be available on Windows 7 and higher. + // to fallback to Basic layers. If WARP is not disabled it will use a WARP + // device which should always be available on Windows 7 and higher. if (!gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) { return; } @@ -1600,8 +1555,8 @@ gfxWindowsPlatform::InitGPUProcessSupport() NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_D3D11")); } else if (!IsWin7SP1OrLater()) { // On Windows 7 Pre-SP1, DXGI 1.2 is not available and remote presentation - // for D3D11 will not work. Rather than take a regression and use D3D9, we - // revert back to in-process rendering. + // for D3D11 will not work. Rather than take a regression we revert back + // to in-process rendering. gpuProc.Disable( FeatureStatus::Unavailable, "Windows 7 Pre-SP1 cannot use the GPU process", @@ -1937,17 +1892,9 @@ gfxWindowsPlatform::GetAcceleratedCompositorBackends(nsTArray& aB aBackends.AppendElement(LayersBackend::LAYERS_OPENGL); } - if (gfxConfig::IsEnabled(Feature::D3D9_COMPOSITING) && gfxPrefs::LayersPreferD3D9()) { - aBackends.AppendElement(LayersBackend::LAYERS_D3D9); - } - if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) { aBackends.AppendElement(LayersBackend::LAYERS_D3D11); } - - if (gfxConfig::IsEnabled(Feature::D3D9_COMPOSITING) && !gfxPrefs::LayersPreferD3D9()) { - aBackends.AppendElement(LayersBackend::LAYERS_D3D9); - } } void @@ -1958,7 +1905,6 @@ gfxWindowsPlatform::ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData gfxPlatform::ImportGPUDeviceData(aData); gfxConfig::ImportChange(Feature::D3D11_COMPOSITING, aData.d3d11Compositing()); - gfxConfig::ImportChange(Feature::D3D9_COMPOSITING, aData.d3d9Compositing()); DeviceManagerDx* dm = DeviceManagerDx::Get(); if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) { @@ -1996,7 +1942,6 @@ gfxWindowsPlatform::ImportContentDeviceData(const mozilla::gfx::ContentDeviceDat const DevicePrefs& prefs = aData.prefs(); gfxConfig::Inherit(Feature::D3D11_COMPOSITING, prefs.d3d11Compositing()); - gfxConfig::Inherit(Feature::D3D9_COMPOSITING, prefs.d3d9Compositing()); gfxConfig::Inherit(Feature::DIRECT2D, prefs.useD2D1()); if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) { @@ -2015,7 +1960,6 @@ gfxWindowsPlatform::BuildContentDeviceData(ContentDeviceData* aOut) const FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING); aOut->prefs().d3d11Compositing() = d3d11.GetValue(); - aOut->prefs().d3d9Compositing() = gfxConfig::GetValue(Feature::D3D9_COMPOSITING); aOut->prefs().useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D); if (d3d11.IsEnabled()) { diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 24e626d62860..e502db08e4c5 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -50,7 +50,6 @@ class FeatureState; class DeviceManagerDx; } namespace layers { -class DeviceManagerD3D9; class ReadbackManagerD3D11; } } diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build index dee9b7bfa2cb..27fd92ea739d 100644 --- a/gfx/thebes/moz.build +++ b/gfx/thebes/moz.build @@ -256,7 +256,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'): DEFINES['MOZ_ENABLE_FREETYPE'] = True if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'): + for var in ('MOZ_ENABLE_D3D10_LAYER',): if CONFIG[var]: DEFINES[var] = True diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 26cf76ceb7b0..783de20ee10b 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -9,9 +9,6 @@ #include "BasicLayers.h" #include "gfxPrefs.h" -#ifdef MOZ_ENABLE_D3D9_LAYER -# include "LayerManagerD3D9.h" -#endif //MOZ_ENABLE_D3D9_LAYER #include "mozilla/BrowserElementParent.h" #include "mozilla/EventForwards.h" // for Modifiers #include "mozilla/ViewportFrame.h" diff --git a/old-configure.in b/old-configure.in index ea309ec20e98..097d88bf8a1f 100644 --- a/old-configure.in +++ b/old-configure.in @@ -4892,8 +4892,6 @@ if test "$MOZ_TREE_CAIRO"; then if test "$COMPILE_ENVIRONMENT"; then - MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1) - dnl D3D10 Layers depend on D2D Surfaces. if test -n "$WIN32_D2D_SURFACE_FEATURE"; then MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1) @@ -4907,7 +4905,6 @@ if test "$MOZ_TREE_CAIRO"; then AC_SUBST(MOZ_ENABLE_CAIRO_FT) AC_SUBST(MOZ_ENABLE_DWRITE_FONT) AC_SUBST(MOZ_ENABLE_D2D_SURFACE) - AC_SUBST(MOZ_ENABLE_D3D9_LAYER) AC_SUBST(MOZ_ENABLE_D3D10_LAYER) AC_SUBST(PS_SURFACE_FEATURE)