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_RENDERDMABUFTEXTUREHOST_H
8 #define MOZILLA_GFX_RENDERDMABUFTEXTUREHOST_H
10 #include "mozilla/layers/TextureHostOGL.h"
11 #include "RenderTextureHost.h"
12 #include "RenderTextureHostSWGL.h"
13 #include "mozilla/widget/DMABufSurface.h"
18 class SurfaceDescriptorDMABuf
;
23 class RenderDMABUFTextureHost final
: public RenderTextureHostSWGL
{
25 explicit RenderDMABUFTextureHost(DMABufSurface
* aSurface
);
27 wr::WrExternalImage
Lock(uint8_t aChannelIndex
, gl::GLContext
* aGL
) override
;
28 void Unlock() override
;
29 void ClearCachedResources() override
;
31 size_t Bytes() override
{
32 return mSurface
->GetWidth() * mSurface
->GetHeight() *
33 BytesPerPixel(mSurface
->GetFormat());
36 // RenderTextureHostSWGL
37 gfx::SurfaceFormat
GetFormat() const override
;
38 gfx::ColorDepth
GetColorDepth() const override
{
39 return gfx::ColorDepth::COLOR_8
;
41 size_t GetPlaneCount() const override
{ return mSurface
->GetTextureCount(); };
42 bool MapPlane(RenderCompositor
* aCompositor
, uint8_t aChannelIndex
,
43 PlaneInfo
& aPlaneInfo
) override
;
44 void UnmapPlanes() override
;
47 virtual ~RenderDMABUFTextureHost();
48 void DeleteTextureHandle();
50 RefPtr
<DMABufSurface
> mSurface
;
51 RefPtr
<gl::GLContext
> mGL
;
52 RefPtr
<gfx::DataSourceSurface
> mReadback
;
56 } // namespace mozilla
58 #endif // MOZILLA_GFX_RENDERDMABUFTEXTUREHOST_H