Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / gfx / webrender_bindings / RenderBufferTextureHost.h
blob0fd2ef26b735f68be6f718e0b2ca32f57b7361dc
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 MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H
8 #define MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H
10 #include "RenderTextureHostSWGL.h"
12 namespace mozilla {
13 namespace wr {
15 class RenderBufferTextureHost final : public RenderTextureHostSWGL {
16 public:
17 RenderBufferTextureHost(uint8_t* aBuffer,
18 const layers::BufferDescriptor& aDescriptor);
20 // RenderTextureHost
21 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
22 void Unlock() override;
24 size_t Bytes() override {
25 return mSize.width * mSize.height * BytesPerPixel(mFormat);
27 class RenderBufferData {
28 public:
29 RenderBufferData(uint8_t* aData, size_t aBufferSize)
30 : mData(aData), mBufferSize(aBufferSize) {}
31 const uint8_t* mData;
32 size_t mBufferSize;
35 RenderBufferData GetBufferDataForRender(uint8_t aChannelIndex);
37 // RenderTextureHostSWGL
38 size_t GetPlaneCount() const override;
40 gfx::SurfaceFormat GetFormat() const override;
42 gfx::ColorDepth GetColorDepth() const override;
44 gfx::YUVRangedColorSpace GetYUVColorSpace() const override;
46 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
47 PlaneInfo& aPlaneInfo) override;
49 void UnmapPlanes() override;
51 void Destroy() override;
53 private:
54 virtual ~RenderBufferTextureHost();
56 uint8_t* GetBuffer() const { return mBuffer; }
58 uint8_t* mBuffer;
59 layers::BufferDescriptor mDescriptor;
60 gfx::IntSize mSize;
61 gfx::SurfaceFormat mFormat;
63 RefPtr<gfx::DataSourceSurface> mSurface;
64 gfx::DataSourceSurface::MappedSurface mMap;
66 RefPtr<gfx::DataSourceSurface> mYSurface;
67 RefPtr<gfx::DataSourceSurface> mCbSurface;
68 RefPtr<gfx::DataSourceSurface> mCrSurface;
69 gfx::DataSourceSurface::MappedSurface mYMap;
70 gfx::DataSourceSurface::MappedSurface mCbMap;
71 gfx::DataSourceSurface::MappedSurface mCrMap;
73 bool mLocked;
75 bool mDestroyed = false;
78 } // namespace wr
79 } // namespace mozilla
81 #endif // MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H