Bug 904890 - Part 1: Implement ISharedImage for D3D9SurfaceImage. r=nical

* * *
[mq]: fix-things
This commit is contained in:
Matt Woodrow 2014-04-07 15:09:08 +12:00
Родитель 8b20108cc3
Коммит 91d9c51764
2 изменённых файлов: 33 добавлений и 3 удалений

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

@ -6,10 +6,20 @@
#include "D3D9SurfaceImage.h"
#include "gfxImageSurface.h"
#include "gfx2DGlue.h"
#include "mozilla/layers/TextureD3D9.h"
#include "mozilla/gfx/Types.h"
namespace mozilla {
namespace layers {
D3D9SurfaceImage::D3D9SurfaceImage()
: Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
, mSize(0, 0)
{}
D3D9SurfaceImage::~D3D9SurfaceImage() {}
HRESULT
D3D9SurfaceImage::SetData(const Data& aData)
{
@ -172,6 +182,19 @@ D3D9SurfaceImage::DeprecatedGetAsSurface()
return surface.forget();
}
TextureClient*
D3D9SurfaceImage::GetTextureClient(CompositableClient* aClient)
{
EnsureSynchronized();
if (!mTextureClient) {
RefPtr<SharedTextureClientD3D9> textureClient =
new SharedTextureClientD3D9(gfx::SurfaceFormat::B8G8R8X8, TEXTURE_FLAGS_DEFAULT);
textureClient->InitWith(mTexture, mShareHandle, mDesc);
mTextureClient = textureClient;
}
return mTextureClient;
}
TemporaryRef<gfx::SourceSurface>
D3D9SurfaceImage::GetAsSourceSurface()
{

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

@ -18,7 +18,8 @@ namespace layers {
// 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
// resource is ready to use.
class D3D9SurfaceImage : public Image {
class D3D9SurfaceImage : public Image
, public ISharedImage {
public:
struct Data {
@ -28,8 +29,10 @@ public:
nsIntRect mRegion;
};
D3D9SurfaceImage() : Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE), mSize(0, 0) {}
virtual ~D3D9SurfaceImage() {}
D3D9SurfaceImage();
virtual ~D3D9SurfaceImage();
virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
// Copies the surface into a sharable texture's surface, and initializes
// the image.
@ -49,6 +52,9 @@ public:
already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; }
private:
// Blocks the calling thread until the copy operation started in SetData()
@ -58,6 +64,7 @@ private:
gfx::IntSize mSize;
RefPtr<IDirect3DTexture9> mTexture;
RefPtr<IDirect3DQuery9> mQuery;
RefPtr<TextureClient> mTextureClient;
HANDLE mShareHandle;
D3DSURFACE_DESC mDesc;
};