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"
|
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.
|
|
|
|
TemporaryRef<IDirect3DTexture9> InitTextures(
|
|
|
|
DeviceManagerD3D9* aDeviceManager,
|
|
|
|
const gfx::IntSize &aSize,
|
|
|
|
_D3DFORMAT aFormat,
|
|
|
|
RefPtr<IDirect3DSurface9>& aSurface,
|
|
|
|
D3DLOCKED_RECT& aLockedRect);
|
|
|
|
|
|
|
|
TemporaryRef<IDirect3DTexture9> DataToTexture(
|
|
|
|
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).
|
|
|
|
TemporaryRef<IDirect3DTexture9> TextureToTexture(
|
|
|
|
DeviceManagerD3D9* aDeviceManager,
|
|
|
|
IDirect3DTexture9* aTexture,
|
|
|
|
const gfx::IntSize& aSize,
|
|
|
|
_D3DFORMAT aFormat);
|
|
|
|
|
|
|
|
TemporaryRef<IDirect3DTexture9> SurfaceToTexture(
|
|
|
|
DeviceManagerD3D9* aDeviceManager,
|
|
|
|
gfxWindowsSurface* aSurface,
|
|
|
|
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;
|
2014-01-07 20:20:03 +04:00
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
|
|
|
// 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-03-21 19:28:04 +03:00
|
|
|
virtual nsIntRect 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:40 +04:00
|
|
|
// To use with DIBTextureHostD3D9
|
|
|
|
|
|
|
|
bool Update(gfxWindowsSurface* aSurface);
|
|
|
|
|
2014-01-07 20:20:03 +04:00
|
|
|
protected:
|
|
|
|
gfx::IntRect GetTileRect(uint32_t aTileIndex) const;
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
std::vector< RefPtr<IDirect3DTexture9> > mTileTextures;
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
|
|
|
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
|
|
|
/**
|
2014-02-07 17:30:01 +04:00
|
|
|
* Can only be drawn into through Cairo and need a D3D9 context on the client side.
|
2014-01-07 20:20:40 +04:00
|
|
|
* The corresponding TextureHost is TextureHostD3D9.
|
|
|
|
*/
|
|
|
|
class CairoTextureClientD3D9 : public TextureClient
|
|
|
|
{
|
|
|
|
public:
|
2014-12-22 11:49:00 +03:00
|
|
|
CairoTextureClientD3D9(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat,
|
|
|
|
TextureFlags aFlags);
|
2014-01-07 20:20:40 +04:00
|
|
|
|
|
|
|
virtual ~CairoTextureClientD3D9();
|
|
|
|
|
|
|
|
// TextureClient
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsAllocated() const override { return !!mTexture; }
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock(OpenMode aOpenMode) 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 bool IsLocked() const override { return mIsLocked; }
|
2014-01-24 18:25:04 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
|
|
|
virtual gfx::IntSize GetSize() const { return mSize; }
|
|
|
|
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const { return mFormat; }
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool CanExposeDrawTarget() const override { return true; }
|
2014-04-14 20:45:34 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::DrawTarget* BorrowDrawTarget() override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
|
|
|
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
2015-03-21 19:28:04 +03:00
|
|
|
TextureAllocationFlags aFlags = ALLOC_DEFAULT) override;
|
2014-01-07 20:20:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasInternalBuffer() const override { return true; }
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2014-07-25 13:24:46 +04:00
|
|
|
virtual TemporaryRef<TextureClient>
|
|
|
|
CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
|
2015-03-21 19:28:04 +03:00
|
|
|
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
|
2014-07-25 13:24:46 +04:00
|
|
|
|
2014-01-07 20:20:40 +04:00
|
|
|
private:
|
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
|
|
|
nsRefPtr<IDirect3DSurface9> mD3D9Surface;
|
|
|
|
RefPtr<gfx::DrawTarget> mDrawTarget;
|
|
|
|
nsRefPtr<gfxASurface> mSurface;
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
bool mIsLocked;
|
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.
|
|
|
|
*/
|
2014-01-07 20:20:22 +04:00
|
|
|
class SharedTextureClientD3D9 : public TextureClient
|
|
|
|
{
|
|
|
|
public:
|
2014-12-22 11:49:00 +03:00
|
|
|
SharedTextureClientD3D9(ISurfaceAllocator* aAllocator,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
TextureFlags aFlags);
|
2014-01-07 20:20:40 +04:00
|
|
|
|
|
|
|
virtual ~SharedTextureClientD3D9();
|
|
|
|
|
2015-04-29 20:34:00 +03:00
|
|
|
// Creates a TextureClient and init width.
|
|
|
|
static TemporaryRef<SharedTextureClientD3D9>
|
|
|
|
Create(ISurfaceAllocator* aAllocator,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
TextureFlags aFlags,
|
|
|
|
IDirect3DTexture9* aTexture,
|
|
|
|
HANDLE aSharedHandle,
|
|
|
|
D3DSURFACE_DESC aDesc);
|
|
|
|
|
2014-01-07 20:20:40 +04:00
|
|
|
// TextureClient
|
2014-01-07 20:20:22 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsAllocated() const override { return !!mTexture; }
|
2014-01-07 20:20:22 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock(OpenMode aOpenMode) override;
|
2014-01-07 20:20:22 +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 bool IsLocked() const override { return mIsLocked; }
|
2014-01-24 18:25:04 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
2014-01-07 20:20:22 +04:00
|
|
|
|
|
|
|
virtual gfx::IntSize GetSize() const
|
|
|
|
{
|
|
|
|
return gfx::IntSize(mDesc.Width, mDesc.Height);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasInternalBuffer() const override { return true; }
|
2014-04-07 07:23:06 +04:00
|
|
|
|
2014-07-25 13:24:46 +04:00
|
|
|
// This TextureClient should not be used in a context where we use CreateSimilar
|
|
|
|
// (ex. component alpha) because the underlying texture data is always created by
|
|
|
|
// an external producer.
|
|
|
|
virtual TemporaryRef<TextureClient>
|
2015-03-21 19:28:04 +03:00
|
|
|
CreateSimilar(TextureFlags, TextureAllocationFlags) const override { return nullptr; }
|
2014-07-25 13:24:46 +04:00
|
|
|
|
2014-01-07 20:20:22 +04:00
|
|
|
private:
|
2014-01-07 20:20:40 +04:00
|
|
|
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
|
|
|
bool mIsLocked;
|
|
|
|
};
|
|
|
|
|
|
|
|
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 void Updated(const nsIntRegion* aRegion) override;
|
2014-01-29 20:27:01 +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-03-21 19:28:04 +03:00
|
|
|
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() override
|
2014-01-07 20:20:40 +04:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasInternalBuffer() 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();
|
|
|
|
|
|
|
|
RefPtr<DataTextureSourceD3D9> mTextureSource;
|
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
|
|
|
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-03-21 19:28:04 +03:00
|
|
|
virtual TemporaryRef<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();
|
|
|
|
|
2014-04-07 07:23:06 +04:00
|
|
|
RefPtr<DataTextureSourceD3D9> mTextureSource;
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
|
|
|
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; }
|
|
|
|
|
|
|
|
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() override
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
IDirect3DDevice9* GetDevice();
|
|
|
|
|
|
|
|
HANDLE mHandles[3];
|
|
|
|
RefPtr<IDirect3DTexture9> mTextures[3];
|
|
|
|
RefPtr<DataTextureSourceD3D9> mTextureSources[3];
|
|
|
|
|
|
|
|
RefPtr<CompositorD3D9> mCompositor;
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
|
|
|
nsRefPtr<IDirect3DSurface9> mSurface;
|
|
|
|
SurfaceInitMode mInitMode;
|
|
|
|
bool mInitialized;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_TEXTURED3D9_H */
|