2013-05-04 10:12:40 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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 GFX_D3DSURFACEIMAGE_H
|
|
|
|
#define GFX_D3DSURFACEIMAGE_H
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-05-04 10:12:40 +00:00
|
|
|
#include "ImageContainer.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "d3d9.h"
|
2015-08-11 14:15:44 +00:00
|
|
|
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
2013-05-04 10:12:40 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2015-10-19 12:46:17 +00:00
|
|
|
class TextureClient;
|
2015-08-11 14:15:34 +00:00
|
|
|
|
2015-08-11 14:15:44 +00:00
|
|
|
class D3D9RecycleAllocator : public TextureClientRecycleAllocator
|
|
|
|
{
|
|
|
|
public:
|
2015-10-06 06:40:13 +00:00
|
|
|
explicit D3D9RecycleAllocator(CompositableForwarder* aAllocator,
|
2015-08-11 14:15:44 +00:00
|
|
|
IDirect3DDevice9* aDevice)
|
|
|
|
: TextureClientRecycleAllocator(aAllocator)
|
|
|
|
, mDevice(aDevice)
|
|
|
|
{}
|
|
|
|
|
2015-10-19 12:46:17 +00:00
|
|
|
already_AddRefed<TextureClient>
|
2015-08-11 14:15:44 +00:00
|
|
|
CreateOrRecycleClient(gfx::SurfaceFormat aFormat,
|
|
|
|
const gfx::IntSize& aSize);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual already_AddRefed<TextureClient>
|
|
|
|
Allocate(gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
BackendSelector aSelector,
|
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
TextureAllocationFlags aAllocFlags) override;
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDirect3DDevice9> mDevice;
|
2015-08-11 14:15:44 +00:00
|
|
|
};
|
|
|
|
|
2013-05-04 10:12:40 +00:00
|
|
|
// 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
|
|
|
|
// resource is ready to use.
|
2015-03-18 21:15:38 +00:00
|
|
|
class D3D9SurfaceImage : public Image {
|
2013-05-04 10:12:40 +00:00
|
|
|
public:
|
2016-03-08 21:34:49 +00:00
|
|
|
explicit D3D9SurfaceImage();
|
2014-04-07 03:09:08 +00:00
|
|
|
virtual ~D3D9SurfaceImage();
|
|
|
|
|
2015-11-17 08:09:00 +00:00
|
|
|
HRESULT AllocateAndCopy(D3D9RecycleAllocator* aAllocator,
|
|
|
|
IDirect3DSurface9* aSurface,
|
|
|
|
const gfx::IntRect& aRegion);
|
2013-05-04 10:12:40 +00:00
|
|
|
|
|
|
|
// Returns the description of the shared surface.
|
|
|
|
const D3DSURFACE_DESC& GetDesc() const;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
gfx::IntSize GetSize() override;
|
2013-05-04 10:12:40 +00:00
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
2013-05-04 10:12:40 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
|
2014-04-07 03:09:08 +00:00
|
|
|
|
2016-03-21 05:49:43 +00:00
|
|
|
already_AddRefed<IDirect3DSurface9> GetD3D9Surface();
|
|
|
|
|
2016-03-08 21:34:49 +00:00
|
|
|
virtual bool IsValid() override { return mValid; }
|
2015-03-12 09:14:51 +00:00
|
|
|
|
2016-03-08 21:34:49 +00:00
|
|
|
void Invalidate() { mValid = false; }
|
2013-05-04 10:12:40 +00:00
|
|
|
|
2016-03-08 21:34:49 +00:00
|
|
|
private:
|
2015-03-09 03:18:32 +00:00
|
|
|
|
2013-12-13 17:32:02 +00:00
|
|
|
gfx::IntSize mSize;
|
2015-10-19 12:46:17 +00:00
|
|
|
RefPtr<TextureClient> mTextureClient;
|
2015-03-12 09:13:23 +00:00
|
|
|
bool mValid;
|
2013-05-04 10:12:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namepace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GFX_D3DSURFACEIMAGE_H
|