1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GFX_D3D11_YCBCR_IMAGE_H
8 #define GFX_D3D11_YCBCR_IMAGE_H
11 #include "mozilla/layers/TextureClientRecycleAllocator.h"
12 #include "mozilla/Maybe.h"
13 #include "ImageContainer.h"
22 class DXGIYCbCrTextureClient
;
23 class DXGIYCbCrTextureData
;
25 class MOZ_RAII DXGIYCbCrTextureAllocationHelper
26 : public ITextureClientAllocationHelper
{
28 DXGIYCbCrTextureAllocationHelper(const PlanarYCbCrData
& aData
,
29 TextureFlags aTextureFlags
,
30 ID3D11Device
* aDevice
);
32 bool IsCompatible(TextureClient
* aTextureClient
) override
;
34 already_AddRefed
<TextureClient
> Allocate(
35 KnowsCompositor
* aAllocator
) override
;
38 const PlanarYCbCrData
& mData
;
39 RefPtr
<ID3D11Device
> mDevice
;
42 class D3D11YCbCrRecycleAllocator
: public TextureClientRecycleAllocator
{
44 explicit D3D11YCbCrRecycleAllocator(KnowsCompositor
* aKnowsCompositor
)
45 : TextureClientRecycleAllocator(aKnowsCompositor
) {}
48 already_AddRefed
<TextureClient
> Allocate(
49 gfx::SurfaceFormat aFormat
, gfx::IntSize aSize
, BackendSelector aSelector
,
50 TextureFlags aTextureFlags
, TextureAllocationFlags aAllocFlags
) override
;
53 class D3D11YCbCrImage
: public Image
{
54 friend class gl::GLBlitHelper
;
58 virtual ~D3D11YCbCrImage();
60 // Copies the surface into a sharable texture's surface, and initializes
62 bool SetData(KnowsCompositor
* aAllocator
, ImageContainer
* aContainer
,
63 const PlanarYCbCrData
& aData
);
65 gfx::IntSize
GetSize() const override
;
67 already_AddRefed
<gfx::SourceSurface
> GetAsSourceSurface() override
;
69 TextureClient
* GetTextureClient(KnowsCompositor
* aKnowsCompositor
) override
;
71 gfx::IntRect
GetPictureRect() const override
{ return mPictureRect
; }
73 gfx::IntSize
GetYSize() const {
74 return {mPictureRect
.XMost(), mPictureRect
.YMost()};
76 gfx::IntSize
GetCbCrSize() const {
77 return ChromaSize(GetYSize(), mChromaSubsampling
);
81 const DXGIYCbCrTextureData
* GetData() const;
83 gfx::IntRect mPictureRect
;
84 gfx::ColorDepth mColorDepth
;
85 gfx::YUVColorSpace mColorSpace
;
86 gfx::ColorRange mColorRange
;
87 gfx::ChromaSubsampling mChromaSubsampling
;
88 RefPtr
<TextureClient
> mTextureClient
;
92 } // namespace mozilla
94 #endif // GFX_D3D11_YCBCR_IMAGE_H