summaryrefslogtreecommitdiff
path: root/gfx/layers
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/layers')
-rw-r--r--gfx/layers/D3D9SurfaceImage.cpp83
-rw-r--r--gfx/layers/D3D9SurfaceImage.h48
-rw-r--r--gfx/layers/IMFYCbCrImage.cpp96
-rw-r--r--gfx/layers/IMFYCbCrImage.h2
-rw-r--r--gfx/layers/client/CompositableClient.cpp1
-rw-r--r--gfx/layers/client/TextureClient.cpp11
-rw-r--r--gfx/layers/composite/TextureHost.cpp14
-rw-r--r--gfx/layers/d3d11/CompositorD3D11.cpp1
-rw-r--r--gfx/layers/ipc/CompositorBridgeParent.cpp7
-rw-r--r--gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp1
10 files changed, 131 insertions, 133 deletions
diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp
index 91dce6291d..c5538105dc 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<IDirect3DTexture9> 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<IDirect3DSurface9>
+DXGID3D9TextureData::GetD3D9Surface() const
+{
+ RefPtr<IDirect3DSurface9> 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 a5326bb996..81cfa2cadd 100644
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -40,6 +40,54 @@ protected:
RefPtr<IDirect3DDevice9> 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<IDirect3DSurface9> 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<IDirect3DDevice9> mDevice;
+ RefPtr<IDirect3DTexture9> 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 6740fdbe07..47c0ce927a 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"
@@ -135,97 +134,6 @@ FinishTextures(IDirect3DDevice9* aDevice,
return true;
}
-static bool UploadData(IDirect3DDevice9* aDevice,
- RefPtr<IDirect3DTexture9>& aTexture,
- HANDLE& aHandle,
- uint8_t* aSrc,
- const gfx::IntSize& aSrcSize,
- int32_t aSrcStride)
-{
- RefPtr<IDirect3DSurface9> 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);
-}
-
-TextureClient*
-IMFYCbCrImage::GetD3D9TextureClient(KnowsCompositor* aForwarder)
-{
- RefPtr<IDirect3DDevice9> device = DeviceManagerD3D9::GetDevice();
- if (!device) {
- return nullptr;
- }
-
- RefPtr<IDirect3DTexture9> textureY;
- HANDLE shareHandleY = 0;
- if (!UploadData(device, textureY, shareHandleY,
- mData.mYChannel, mData.mYSize, mData.mYStride)) {
- return nullptr;
- }
-
- RefPtr<IDirect3DTexture9> textureCb;
- HANDLE shareHandleCb = 0;
- if (!UploadData(device, textureCb, shareHandleCb,
- mData.mCbChannel, mData.mCbCrSize, mData.mCbCrStride)) {
- return nullptr;
- }
-
- RefPtr<IDirect3DTexture9> textureCr;
- HANDLE shareHandleCr = 0;
- if (!UploadData(device, textureCr, shareHandleCr,
- mData.mCrChannel, mData.mCbCrSize, mData.mCbCrStride)) {
- return nullptr;
- }
-
- RefPtr<IDirect3DQuery9> 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;
- }
-
- mTextureClient = TextureClient::CreateWithData(
- DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT,
- textureY, textureCb, textureCr,
- shareHandleY, shareHandleCb, shareHandleCr,
- GetSize(), mData.mYSize, mData.mCbCrSize),
- TextureFlags::DEFAULT,
- aForwarder->GetTextureForwarder()
- );
-
- return mTextureClient;
-}
-
TextureClient*
IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
{
@@ -242,10 +150,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;
}
diff --git a/gfx/layers/IMFYCbCrImage.h b/gfx/layers/IMFYCbCrImage.h
index 9a42987279..511f865dec 100644
--- a/gfx/layers/IMFYCbCrImage.h
+++ b/gfx/layers/IMFYCbCrImage.h
@@ -24,8 +24,6 @@ public:
protected:
- TextureClient* GetD3D9TextureClient(KnowsCompositor* aForwarder);
-
~IMFYCbCrImage();
RefPtr<IMFMediaBuffer> mBuffer;
diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp
index 52b9a46372..936ba7abca 100644
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -17,7 +17,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 462cd40d43..e8139e9a92 100644
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -33,9 +33,7 @@
#include "mozilla/layers/ShadowLayers.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"
@@ -1033,15 +1031,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 (!data && aFormat == SurfaceFormat::B8G8R8X8 &&
moz2DBackend == gfx::BackendType::CAIRO &&
diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp
index 94e7b5427c..d550945ef6 100644
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -168,11 +168,6 @@ already_AddRefed<TextureHost> CreateTextureHostD3D11(const SurfaceDescriptor& aD
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);
-// implemented in TextureD3D9.cpp
-already_AddRefed<TextureHost> CreateTextureHostD3D9(const SurfaceDescriptor& aDesc,
- ISurfaceAllocator* aDeallocator,
- TextureFlags aFlags);
-
already_AddRefed<TextureHost>
TextureHost::Create(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
@@ -211,16 +206,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 505e5881d4..7655d097b2 100644
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -28,7 +28,6 @@
#include "BlendShaderConstants.h"
#include "D3D11ShareHandleImage.h"
-#include "D3D9SurfaceImage.h"
#include <dxgi1_2.h>
diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp
index 25ac10130d..e650b2dcf1 100644
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -63,7 +63,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"
@@ -1617,8 +1616,6 @@ CompositorBridgeParent::NewCompositor(const nsTArray<LayersBackend>& 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;
@@ -1637,10 +1634,6 @@ CompositorBridgeParent::NewCompositor(const nsTArray<LayersBackend>& aBackendHin
<< failureReason.get();
}
#ifdef XP_WIN
- else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9){
- gfxCriticalNote << "[D3D9] Failed to init compositor with reason: "
- << failureReason.get();
- }
else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11){
gfxCriticalNote << "[D3D11] Failed to init compositor with reason: "
<< failureReason.get();
diff --git a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
index 56d0386868..623bf9e5df 100644
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
@@ -61,7 +61,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"