Bug 1882457 - Update the release process docs for the monorepo migration. r=ahal...
[gecko.git] / gfx / layers / D3D11YCbCrImage.h
blob0b4408ca37ee83d064de4643c104de550582fe53
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
10 #include "d3d11.h"
11 #include "mozilla/layers/TextureClientRecycleAllocator.h"
12 #include "mozilla/Maybe.h"
13 #include "ImageContainer.h"
15 namespace mozilla {
16 namespace gl {
17 class GLBlitHelper;
19 namespace layers {
21 class ImageContainer;
22 class DXGIYCbCrTextureClient;
23 class DXGIYCbCrTextureData;
25 class MOZ_RAII DXGIYCbCrTextureAllocationHelper
26 : public ITextureClientAllocationHelper {
27 public:
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;
37 protected:
38 const PlanarYCbCrData& mData;
39 RefPtr<ID3D11Device> mDevice;
42 class D3D11YCbCrRecycleAllocator : public TextureClientRecycleAllocator {
43 public:
44 explicit D3D11YCbCrRecycleAllocator(KnowsCompositor* aKnowsCompositor)
45 : TextureClientRecycleAllocator(aKnowsCompositor) {}
47 protected:
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;
56 public:
57 D3D11YCbCrImage();
58 virtual ~D3D11YCbCrImage();
60 // Copies the surface into a sharable texture's surface, and initializes
61 // the image.
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 nsresult BuildSurfaceDescriptorBuffer(
70 SurfaceDescriptorBuffer& aSdBuffer, BuildSdbFlags aFlags,
71 const std::function<MemoryOrShmem(uint32_t)>& aAllocate) override;
73 TextureClient* GetTextureClient(KnowsCompositor* aKnowsCompositor) override;
75 gfx::IntRect GetPictureRect() const override { return mPictureRect; }
77 gfx::IntSize GetYSize() const {
78 return {mPictureRect.XMost(), mPictureRect.YMost()};
80 gfx::IntSize GetCbCrSize() const {
81 return ChromaSize(GetYSize(), mChromaSubsampling);
84 private:
85 nsresult ReadIntoBuffer(
86 const std::function<nsresult(const PlanarYCbCrData&, const gfx::IntSize&,
87 gfx::SurfaceFormat)>& aCopy);
89 const DXGIYCbCrTextureData* GetData() const;
91 gfx::IntRect mPictureRect;
92 gfx::ColorDepth mColorDepth;
93 gfx::YUVColorSpace mColorSpace;
94 gfx::ColorRange mColorRange;
95 gfx::ChromaSubsampling mChromaSubsampling;
96 RefPtr<TextureClient> mTextureClient;
99 } // namespace layers
100 } // namespace mozilla
102 #endif // GFX_D3D11_YCBCR_IMAGE_H