RenderDMABUFTextureHost.h (2003B)
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/. */ 6 7 #ifndef MOZILLA_GFX_RENDERDMABUFTEXTUREHOST_H 8 #define MOZILLA_GFX_RENDERDMABUFTEXTUREHOST_H 9 10 #include "mozilla/layers/TextureHostOGL.h" 11 #include "RenderTextureHost.h" 12 #include "RenderTextureHostSWGL.h" 13 #include "mozilla/widget/DMABufSurface.h" 14 15 namespace mozilla { 16 17 namespace layers { 18 class SurfaceDescriptorDMABuf; 19 } 20 21 namespace wr { 22 23 class RenderDMABUFTextureHost final : public RenderTextureHostSWGL { 24 public: 25 explicit RenderDMABUFTextureHost(DMABufSurface* aSurface); 26 27 RenderDMABUFTextureHost* AsRenderDMABUFTextureHost() override { return this; } 28 gfx::IntSize GetSize(uint8_t aChannelIndex) const; 29 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override; 30 void Unlock() override; 31 void ClearCachedResources() override; 32 33 size_t Bytes() override { 34 return mSurface->GetWidth() * mSurface->GetHeight() * 35 BytesPerPixel(mSurface->GetFormat()); 36 } 37 RefPtr<DMABufSurface> GetSurface() { return mSurface; } 38 39 // RenderTextureHostSWGL 40 gfx::SurfaceFormat GetFormat() const override { 41 return mSurface->GetFormat(); 42 } 43 gfx::ColorDepth GetColorDepth() const override { 44 return gfx::ColorDepth::COLOR_8; 45 } 46 size_t GetPlaneCount() const override { return mSurface->GetTextureCount(); }; 47 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex, 48 PlaneInfo& aPlaneInfo) override; 49 void UnmapPlanes() override; 50 51 private: 52 virtual ~RenderDMABUFTextureHost(); 53 void DeleteTextureHandle(); 54 55 RefPtr<DMABufSurface> mSurface; 56 RefPtr<gl::GLContext> mGL; 57 RefPtr<gfx::DataSourceSurface> mReadback; 58 }; 59 60 } // namespace wr 61 } // namespace mozilla 62 63 #endif // MOZILLA_GFX_RENDERDMABUFTEXTUREHOST_H