2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2015-03-31 08:21:15 +03:00
|
|
|
* 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_D311_SHARE_HANDLE_IMAGE_H
|
|
|
|
#define GFX_D311_SHARE_HANDLE_IMAGE_H
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2015-03-31 08:21:15 +03:00
|
|
|
#include "ImageContainer.h"
|
|
|
|
#include "d3d11.h"
|
|
|
|
#include "mozilla/layers/TextureClient.h"
|
2015-08-19 04:04:14 +03:00
|
|
|
#include "mozilla/layers/TextureD3D11.h"
|
2015-08-19 04:04:46 +03:00
|
|
|
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
2015-03-31 08:21:15 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2015-08-19 04:04:46 +03:00
|
|
|
class D3D11RecycleAllocator : public TextureClientRecycleAllocator
|
|
|
|
{
|
|
|
|
public:
|
2016-09-27 06:22:20 +03:00
|
|
|
explicit D3D11RecycleAllocator(KnowsCompositor* aAllocator,
|
2015-08-19 04:04:46 +03:00
|
|
|
ID3D11Device* aDevice)
|
|
|
|
: TextureClientRecycleAllocator(aAllocator)
|
|
|
|
, mDevice(aDevice)
|
|
|
|
{}
|
|
|
|
|
2015-10-15 18:53:37 +03:00
|
|
|
already_AddRefed<TextureClient>
|
2015-08-19 04:04:46 +03:00
|
|
|
CreateOrRecycleClient(gfx::SurfaceFormat aFormat,
|
|
|
|
const gfx::IntSize& aSize);
|
|
|
|
|
|
|
|
protected:
|
2017-11-30 21:03:02 +03:00
|
|
|
virtual already_AddRefed<TextureClient> Allocate(
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
BackendSelector aSelector,
|
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
TextureAllocationFlags aAllocFlags) override;
|
2015-08-19 04:04:46 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ID3D11Device> mDevice;
|
2015-08-19 04:04:46 +03:00
|
|
|
};
|
|
|
|
|
2015-03-31 08:21:15 +03:00
|
|
|
// Image class that wraps a ID3D11Texture2D. 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-11-17 11:09:00 +03:00
|
|
|
class D3D11ShareHandleImage final : public Image {
|
2015-03-31 08:21:15 +03:00
|
|
|
public:
|
2015-11-17 11:09:00 +03:00
|
|
|
D3D11ShareHandleImage(const gfx::IntSize& aSize,
|
|
|
|
const gfx::IntRect& aRect);
|
2017-11-30 21:03:02 +03:00
|
|
|
virtual ~D3D11ShareHandleImage() {}
|
2015-03-31 08:21:15 +03:00
|
|
|
|
2016-09-21 12:24:43 +03:00
|
|
|
bool AllocateTexture(D3D11RecycleAllocator* aAllocator, ID3D11Device* aDevice);
|
2015-03-31 08:21:15 +03:00
|
|
|
|
2017-11-30 21:03:02 +03:00
|
|
|
gfx::IntSize GetSize() const override;
|
|
|
|
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
|
|
|
TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
|
|
|
|
gfx::IntRect GetPictureRect() const override { return mPictureRect; }
|
2015-03-31 08:21:15 +03:00
|
|
|
|
|
|
|
ID3D11Texture2D* GetTexture() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
gfx::IntSize mSize;
|
2015-05-07 12:07:35 +03:00
|
|
|
gfx::IntRect mPictureRect;
|
2015-10-15 18:53:37 +03:00
|
|
|
RefPtr<TextureClient> mTextureClient;
|
2016-09-21 12:24:43 +03:00
|
|
|
RefPtr<ID3D11Texture2D> mTexture;
|
2015-03-31 08:21:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namepace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GFX_D3DSURFACEIMAGE_H
|