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
|
2017-05-04 00:23:45 +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_D3D11_YCBCR_IMAGE_H
|
|
|
|
#define GFX_D3D11_YCBCR_IMAGE_H
|
|
|
|
|
|
|
|
#include "d3d11.h"
|
|
|
|
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "ImageContainer.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2017-07-18 05:17:41 +03:00
|
|
|
namespace gl {
|
|
|
|
class GLBlitHelper;
|
|
|
|
}
|
2017-05-04 00:23:45 +03:00
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class ImageContainer;
|
|
|
|
class DXGIYCbCrTextureClient;
|
2017-07-18 05:17:41 +03:00
|
|
|
class DXGIYCbCrTextureData;
|
2017-05-04 00:23:45 +03:00
|
|
|
|
2018-06-28 06:56:36 +03:00
|
|
|
class DXGIYCbCrTextureAllocationHelper : public ITextureClientAllocationHelper {
|
|
|
|
public:
|
|
|
|
DXGIYCbCrTextureAllocationHelper(const PlanarYCbCrData& aData,
|
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
ID3D11Device* aDevice);
|
|
|
|
|
|
|
|
bool IsCompatible(TextureClient* aTextureClient) override;
|
|
|
|
|
|
|
|
already_AddRefed<TextureClient> Allocate(
|
|
|
|
KnowsCompositor* aAllocator) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const PlanarYCbCrData& mData;
|
|
|
|
RefPtr<ID3D11Device> mDevice;
|
|
|
|
};
|
|
|
|
|
2017-05-04 00:23:45 +03:00
|
|
|
class D3D11YCbCrRecycleAllocator : public TextureClientRecycleAllocator {
|
|
|
|
public:
|
2018-05-31 03:35:24 +03:00
|
|
|
explicit D3D11YCbCrRecycleAllocator(KnowsCompositor* aAllocator)
|
2017-05-04 00:23:45 +03:00
|
|
|
: TextureClientRecycleAllocator(aAllocator) {}
|
|
|
|
|
2017-11-30 21:03:02 +03:00
|
|
|
KnowsCompositor* GetAllocator() const { return mSurfaceAllocator; }
|
2017-05-04 00:23:45 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
already_AddRefed<TextureClient> Allocate(
|
|
|
|
gfx::SurfaceFormat aFormat, gfx::IntSize aSize, BackendSelector aSelector,
|
|
|
|
TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class D3D11YCbCrImage : public Image {
|
2017-07-18 05:17:41 +03:00
|
|
|
friend class gl::GLBlitHelper;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-05-04 00:23:45 +03:00
|
|
|
public:
|
|
|
|
D3D11YCbCrImage();
|
|
|
|
virtual ~D3D11YCbCrImage();
|
|
|
|
|
|
|
|
// Copies the surface into a sharable texture's surface, and initializes
|
|
|
|
// the image.
|
|
|
|
bool SetData(KnowsCompositor* aAllocator, ImageContainer* aContainer,
|
|
|
|
const PlanarYCbCrData& aData);
|
|
|
|
|
2017-11-30 21:03:02 +03:00
|
|
|
gfx::IntSize GetSize() const override;
|
2017-05-04 00:23:45 +03:00
|
|
|
|
|
|
|
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
|
|
|
|
|
|
|
TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
|
|
|
|
|
2017-11-30 21:03:02 +03:00
|
|
|
gfx::IntRect GetPictureRect() const override { return mPictureRect; }
|
2017-05-04 00:23:45 +03:00
|
|
|
|
|
|
|
private:
|
2017-07-18 05:17:41 +03:00
|
|
|
const DXGIYCbCrTextureData* GetData() const;
|
|
|
|
|
2017-05-04 00:23:45 +03:00
|
|
|
gfx::IntSize mYSize;
|
|
|
|
gfx::IntSize mCbCrSize;
|
|
|
|
gfx::IntRect mPictureRect;
|
2018-09-25 23:44:55 +03:00
|
|
|
gfx::ColorDepth mColorDepth;
|
2017-05-04 00:23:45 +03:00
|
|
|
YUVColorSpace mColorSpace;
|
|
|
|
RefPtr<TextureClient> mTextureClient;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GFX_D3D11_YCBCR_IMAGE_H
|