2013-08-04 11:46:17 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_TEXTURED3D9_H
|
|
|
|
#define MOZILLA_GFX_TEXTURED3D9_H
|
|
|
|
|
|
|
|
#include "mozilla/layers/Compositor.h"
|
|
|
|
#include "mozilla/layers/TextureClient.h"
|
|
|
|
#include "mozilla/layers/TextureHost.h"
|
2013-07-26 23:28:31 +04:00
|
|
|
#include "mozilla/GfxMessageUtils.h"
|
2015-10-19 15:46:17 +03:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-08-04 11:46:17 +04:00
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
#include "d3d9.h"
|
|
|
|
#include <vector>
|
2013-11-22 02:07:56 +04:00
|
|
|
#include "DeviceManagerD3D9.h"
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2014-01-07 20:20:40 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfxs {
|
|
|
|
class DrawTarget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class CompositorD3D9;
|
|
|
|
|
|
|
|
class TextureSourceD3D9
|
|
|
|
{
|
2013-11-22 02:07:56 +04:00
|
|
|
friend class DeviceManagerD3D9;
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
public:
|
2013-11-22 02:07:56 +04:00
|
|
|
TextureSourceD3D9()
|
|
|
|
: mPreviousHost(nullptr)
|
|
|
|
, mNextHost(nullptr)
|
|
|
|
, mCreatingDeviceManager(nullptr)
|
|
|
|
{}
|
|
|
|
virtual ~TextureSourceD3D9();
|
|
|
|
|
2014-01-07 20:20:03 +04:00
|
|
|
virtual IDirect3DTexture9* GetD3D9Texture() { return mTexture; }
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2014-01-07 20:20:03 +04:00
|
|
|
StereoMode GetStereoMode() const { return mStereoMode; };
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2013-11-22 02:07:56 +04:00
|
|
|
// Release all texture memory resources held by the texture host.
|
|
|
|
virtual void ReleaseTextureResources()
|
|
|
|
{
|
2014-01-07 20:20:03 +04:00
|
|
|
mTexture = nullptr;
|
2013-11-22 02:07:56 +04:00
|
|
|
}
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
protected:
|
|
|
|
virtual gfx::IntSize GetSize() const { return mSize; }
|
|
|
|
void SetSize(const gfx::IntSize& aSize) { mSize = aSize; }
|
|
|
|
|
2013-11-22 02:07:56 +04:00
|
|
|
// Helper methods for creating and copying textures.
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<IDirect3DTexture9> InitTextures(
|
2013-11-22 02:07:56 +04:00
|
|
|
DeviceManagerD3D9* aDeviceManager,
|
|
|
|
const gfx::IntSize &aSize,
|
|
|
|
_D3DFORMAT aFormat,
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDirect3DSurface9>& aSurface,
|
2013-11-22 02:07:56 +04:00
|
|
|
D3DLOCKED_RECT& aLockedRect);
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<IDirect3DTexture9> DataToTexture(
|
2013-11-22 02:07:56 +04:00
|
|
|
DeviceManagerD3D9* aDeviceManager,
|
|
|
|
unsigned char *aData,
|
|
|
|
int aStride,
|
|
|
|
const gfx::IntSize &aSize,
|
|
|
|
_D3DFORMAT aFormat,
|
|
|
|
uint32_t aBPP);
|
|
|
|
|
|
|
|
// aTexture should be in SYSTEMMEM, returns a texture in the default
|
|
|
|
// pool (that is, in video memory).
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<IDirect3DTexture9> TextureToTexture(
|
2013-11-22 02:07:56 +04:00
|
|
|
DeviceManagerD3D9* aDeviceManager,
|
|
|
|
IDirect3DTexture9* aTexture,
|
|
|
|
const gfx::IntSize& aSize,
|
|
|
|
_D3DFORMAT aFormat);
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
gfx::IntSize mSize;
|
2013-11-22 02:07:56 +04:00
|
|
|
|
|
|
|
// Linked list of all objects holding d3d9 textures.
|
|
|
|
TextureSourceD3D9* mPreviousHost;
|
|
|
|
TextureSourceD3D9* mNextHost;
|
|
|
|
// The device manager that created our textures.
|
|
|
|
DeviceManagerD3D9* mCreatingDeviceManager;
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
StereoMode mStereoMode;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
2014-01-07 20:20:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A TextureSource that implements the DataTextureSource interface.
|
|
|
|
* it can be used without a TextureHost and is able to upload texture data
|
|
|
|
* from a gfx::DataSourceSurface.
|
|
|
|
*/
|
|
|
|
class DataTextureSourceD3D9 : public DataTextureSource
|
|
|
|
, public TextureSourceD3D9
|
2014-04-28 15:27:25 +04:00
|
|
|
, public BigImageIterator
|
2014-01-07 20:20:03 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
|
|
|
|
CompositorD3D9* aCompositor,
|
2014-04-26 06:34:05 +04:00
|
|
|
TextureFlags aFlags = TextureFlags::DEFAULT,
|
2014-01-31 02:58:49 +04:00
|
|
|
StereoMode aStereoMode = StereoMode::MONO);
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2014-01-07 20:20:40 +04:00
|
|
|
DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
|
2014-01-29 20:27:01 +04:00
|
|
|
gfx::IntSize aSize,
|
2014-01-07 20:20:40 +04:00
|
|
|
CompositorD3D9* aCompositor,
|
|
|
|
IDirect3DTexture9* aTexture,
|
2014-04-26 06:34:05 +04:00
|
|
|
TextureFlags aFlags = TextureFlags::DEFAULT);
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2014-01-07 20:20:03 +04:00
|
|
|
virtual ~DataTextureSourceD3D9();
|
|
|
|
|
2016-02-08 13:57:00 +03:00
|
|
|
virtual const char* Name() const override { return "DataTextureSourceD3D9"; }
|
|
|
|
|
2014-01-07 20:20:03 +04:00
|
|
|
// DataTextureSource
|
|
|
|
|
|
|
|
virtual bool Update(gfx::DataSourceSurface* aSurface,
|
|
|
|
nsIntRegion* aDestRegion = nullptr,
|
2015-03-21 19:28:04 +03:00
|
|
|
gfx::IntPoint* aSrcOffset = nullptr) override;
|
2014-01-07 20:20:03 +04:00
|
|
|
|
|
|
|
// TextureSource
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual TextureSourceD3D9* AsSourceD3D9() override { return this; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual IDirect3DTexture9* GetD3D9Texture() override;
|
2014-01-07 20:20:11 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual DataTextureSource* AsDataTextureSource() override { return this; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override { mTexture = nullptr; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetCompositor(Compositor* aCompositor) override;
|
2014-01-07 20:20:11 +04:00
|
|
|
|
2014-04-28 15:27:25 +04:00
|
|
|
// BigImageIterator
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual BigImageIterator* AsBigImageIterator() override { return mIsTiled ? this : nullptr; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual size_t GetTileCount() override { return mTileTextures.size(); }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool NextTile() override { return (++mCurrentTile < mTileTextures.size()); }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-05-07 12:07:35 +03:00
|
|
|
virtual gfx::IntRect GetTileRect() override;
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void EndBigImageIteration() override { mIterating = false; }
|
2014-01-07 20:20:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void BeginBigImageIteration() override
|
2014-01-07 20:20:03 +04:00
|
|
|
{
|
|
|
|
mIterating = true;
|
|
|
|
mCurrentTile = 0;
|
|
|
|
}
|
|
|
|
|
2014-01-29 20:27:01 +04:00
|
|
|
/**
|
|
|
|
* Copy the content of aTexture using the GPU.
|
|
|
|
*/
|
|
|
|
bool UpdateFromTexture(IDirect3DTexture9* aTexture, const nsIntRegion* aRegion);
|
|
|
|
|
2014-01-07 20:20:03 +04:00
|
|
|
protected:
|
|
|
|
gfx::IntRect GetTileRect(uint32_t aTileIndex) const;
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
std::vector< RefPtr<IDirect3DTexture9> > mTileTextures;
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
2014-01-07 20:20:03 +04:00
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
uint32_t mCurrentTile;
|
2014-01-07 20:20:11 +04:00
|
|
|
TextureFlags mFlags;
|
2014-01-07 20:20:03 +04:00
|
|
|
bool mIsTiled;
|
|
|
|
bool mIterating;
|
2013-08-04 11:46:17 +04:00
|
|
|
};
|
|
|
|
|
2014-01-07 20:20:40 +04:00
|
|
|
/**
|
2015-07-03 18:54:35 +03:00
|
|
|
* Needs a D3D9 context on the client side.
|
2014-01-07 20:20:40 +04:00
|
|
|
* The corresponding TextureHost is TextureHostD3D9.
|
|
|
|
*/
|
2015-10-19 15:46:17 +03:00
|
|
|
class D3D9TextureData : public TextureData
|
2014-01-07 20:20:40 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-10-19 15:46:17 +03:00
|
|
|
~D3D9TextureData();
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual bool SupportsMoz2D() const override { return true; }
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2016-02-25 16:15:58 +03:00
|
|
|
virtual bool HasIntermediateBuffer() const override { return true; }
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual bool Serialize(SurfaceDescriptor& aOutDescrptor) override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual bool Lock(OpenMode aMode, FenceHandle*) override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Unlock() override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
2014-04-14 20:45:34 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
|
2015-07-27 18:47:29 +03:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual TextureData*
|
2016-03-21 17:18:20 +03:00
|
|
|
CreateSimilar(ClientIPCAllocator* aAllocator,
|
2015-10-19 15:46:17 +03:00
|
|
|
TextureFlags aFlags,
|
|
|
|
TextureAllocationFlags aAllocFlags) const override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
static D3D9TextureData*
|
|
|
|
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureAllocationFlags aFlags);
|
2014-07-25 13:24:46 +04:00
|
|
|
|
2016-03-21 17:18:20 +03:00
|
|
|
virtual void Deallocate(ClientIPCAllocator* aAllocator) override {}
|
2015-11-20 18:55:26 +03:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
protected:
|
|
|
|
D3D9TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
|
|
|
IDirect3DTexture9* aTexture);
|
2015-11-24 21:07:02 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
|
|
|
RefPtr<IDirect3DSurface9> mD3D9Surface;
|
2014-01-07 20:20:40 +04:00
|
|
|
gfx::IntSize mSize;
|
|
|
|
gfx::SurfaceFormat mFormat;
|
2014-02-05 00:35:22 +04:00
|
|
|
bool mNeedsClear;
|
2014-06-18 02:55:31 +04:00
|
|
|
bool mNeedsClearWhite;
|
2014-02-07 17:30:01 +04:00
|
|
|
bool mLockRect;
|
2014-01-07 20:20:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-10-19 15:46:17 +03:00
|
|
|
class DXGID3D9TextureData : public TextureData
|
2014-01-07 20:20:22 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-10-19 15:46:17 +03:00
|
|
|
static DXGID3D9TextureData*
|
|
|
|
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureFlags aFlags, IDirect3DDevice9* aDevice);
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
~DXGID3D9TextureData();
|
2015-04-29 20:34:00 +03:00
|
|
|
|
2015-12-16 18:41:21 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return gfx::IntSize(mDesc.Width, mDesc.Height); }
|
2014-01-07 20:20:22 +04:00
|
|
|
|
2015-08-11 17:15:34 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
|
2014-01-24 18:25:04 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual void Unlock() override {}
|
2014-01-07 20:20:22 +04:00
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
|
2014-01-07 20:20:22 +04:00
|
|
|
|
2016-02-25 16:15:58 +03:00
|
|
|
virtual bool HasIntermediateBuffer() const override { return false; }
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2016-03-21 17:18:20 +03:00
|
|
|
virtual void Deallocate(ClientIPCAllocator* aAllocator) override {}
|
2014-07-25 13:24:46 +04:00
|
|
|
|
2015-08-11 17:15:34 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-10-19 15:46:17 +03:00
|
|
|
protected:
|
|
|
|
DXGID3D9TextureData(gfx::SurfaceFormat aFormat,
|
|
|
|
IDirect3DTexture9* aTexture, HANDLE aHandle,
|
|
|
|
IDirect3DDevice9* aDevice);
|
2015-09-21 17:54:40 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDirect3DDevice9> mDevice;
|
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
2014-01-07 20:20:22 +04:00
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
HANDLE mHandle;
|
|
|
|
D3DSURFACE_DESC mDesc;
|
2014-01-07 20:20:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class TextureHostD3D9 : public TextureHost
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TextureHostD3D9(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorD3D9& aDescriptor);
|
|
|
|
|
2015-03-27 13:16:34 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetCompositor(Compositor* aCompositor) override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock() override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Unlock() override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
|
2014-01-07 20:20:40 +04:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-02-25 16:15:58 +03:00
|
|
|
virtual bool HasIntermediateBuffer() const override { return true; }
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2014-01-07 20:20:40 +04:00
|
|
|
protected:
|
|
|
|
TextureHostD3D9(TextureFlags aFlags);
|
|
|
|
IDirect3DDevice9* GetDevice();
|
|
|
|
|
2015-06-02 13:21:00 +03:00
|
|
|
virtual void UpdatedInternal(const nsIntRegion* aRegion) override;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataTextureSourceD3D9> mTextureSource;
|
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
2014-01-07 20:20:40 +04:00
|
|
|
gfx::IntSize mSize;
|
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
bool mIsLocked;
|
|
|
|
};
|
2014-01-07 20:20:22 +04:00
|
|
|
|
2014-04-07 07:23:06 +04:00
|
|
|
class DXGITextureHostD3D9 : public TextureHost
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DXGITextureHostD3D9(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorD3D10& aDescriptor);
|
|
|
|
|
2015-03-27 13:16:34 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override;
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetCompositor(Compositor* aCompositor) override;
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock() override;
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Unlock() override;
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
|
2014-04-07 07:23:06 +04:00
|
|
|
{
|
|
|
|
return nullptr; // TODO: cf bug 872568
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-07-29 14:15:20 +04:00
|
|
|
void OpenSharedHandle();
|
|
|
|
IDirect3DDevice9* GetDevice();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataTextureSourceD3D9> mTextureSource;
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
2014-04-07 07:23:06 +04:00
|
|
|
WindowsHandle mHandle;
|
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
bool mIsLocked;
|
|
|
|
};
|
|
|
|
|
2015-03-23 05:13:56 +03:00
|
|
|
class DXGIYCbCrTextureHostD3D9 : public TextureHost
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DXGIYCbCrTextureHostD3D9(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorDXGIYCbCr& aDescriptor);
|
|
|
|
|
2015-03-27 13:16:34 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
2015-03-23 05:13:56 +03:00
|
|
|
|
|
|
|
virtual void DeallocateDeviceData() override {}
|
|
|
|
|
|
|
|
virtual void SetCompositor(Compositor* aCompositor) override;
|
|
|
|
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return gfx::SurfaceFormat::YUV; }
|
|
|
|
|
|
|
|
virtual bool Lock() override;
|
|
|
|
virtual void Unlock() override;
|
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
|
2015-03-23 05:13:56 +03:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
IDirect3DDevice9* GetDevice();
|
|
|
|
|
|
|
|
HANDLE mHandles[3];
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDirect3DTexture9> mTextures[3];
|
|
|
|
RefPtr<DataTextureSourceD3D9> mTextureSources[3];
|
2015-03-23 05:13:56 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
2015-03-23 05:13:56 +03:00
|
|
|
gfx::IntSize mSize;
|
|
|
|
gfx::IntSize mSizeY;
|
|
|
|
gfx::IntSize mSizeCbCr;
|
|
|
|
bool mIsLocked;
|
|
|
|
};
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
class CompositingRenderTargetD3D9 : public CompositingRenderTarget,
|
|
|
|
public TextureSourceD3D9
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CompositingRenderTargetD3D9(IDirect3DTexture9* aTexture,
|
|
|
|
SurfaceInitMode aInit,
|
2013-11-07 13:53:08 +04:00
|
|
|
const gfx::IntRect& aRect);
|
2013-08-04 11:46:17 +04:00
|
|
|
// use for rendering to the main window, cannot be rendered as a texture
|
|
|
|
CompositingRenderTargetD3D9(IDirect3DSurface9* aSurface,
|
|
|
|
SurfaceInitMode aInit,
|
2013-11-07 13:53:08 +04:00
|
|
|
const gfx::IntRect& aRect);
|
2013-11-22 02:07:56 +04:00
|
|
|
virtual ~CompositingRenderTargetD3D9();
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2016-02-08 13:57:00 +03:00
|
|
|
virtual const char* Name() const override { return "CompositingRenderTargetD3D9"; }
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual TextureSourceD3D9* AsSourceD3D9() override
|
2013-08-04 11:46:17 +04:00
|
|
|
{
|
2014-01-07 20:20:03 +04:00
|
|
|
MOZ_ASSERT(mTexture,
|
2013-08-04 11:46:17 +04:00
|
|
|
"No texture, can't be indirectly rendered. Is this the screen backbuffer?");
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override;
|
2013-08-04 11:46:17 +04:00
|
|
|
|
|
|
|
void BindRenderTarget(IDirect3DDevice9* aDevice);
|
|
|
|
|
|
|
|
IDirect3DSurface9* GetD3D9Surface() const { return mSurface; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class CompositorD3D9;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDirect3DSurface9> mSurface;
|
2013-08-04 11:46:17 +04:00
|
|
|
SurfaceInitMode mInitMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_TEXTURED3D9_H */
|