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"
15 class RenderBufferTextureHost final
: public RenderTextureHostSWGL
{
17 RenderBufferTextureHost(uint8_t* aBuffer
,
18 const layers::BufferDescriptor
& aDescriptor
);
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
{
29 RenderBufferData(uint8_t* aData
, size_t aBufferSize
)
30 : mData(aData
), mBufferSize(aBufferSize
) {}
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
;
54 virtual ~RenderBufferTextureHost();
56 uint8_t* GetBuffer() const { return mBuffer
; }
59 layers::BufferDescriptor mDescriptor
;
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
;
75 bool mDestroyed
= false;
79 } // namespace mozilla
81 #endif // MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H