RenderSharedSurfaceTextureHost.h (1728B)
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_RENDERSHAREDSURFACETEXTUREHOST_H 8 #define MOZILLA_GFX_RENDERSHAREDSURFACETEXTUREHOST_H 9 10 #include "RenderTextureHostSWGL.h" 11 12 namespace mozilla { 13 namespace gfx { 14 class SourceSurfaceSharedDataWrapper; 15 } 16 17 namespace wr { 18 19 /** 20 * This class allows for surfaces managed by SharedSurfacesParent to be inserted 21 * into the render texture cache by wrapping an existing surface wrapper. These 22 * surfaces are backed by BGRA/X shared memory buffers. 23 */ 24 class RenderSharedSurfaceTextureHost final : public RenderTextureHostSWGL { 25 public: 26 explicit RenderSharedSurfaceTextureHost( 27 gfx::SourceSurfaceSharedDataWrapper* aSurface); 28 29 // RenderTextureHost 30 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override; 31 void Unlock() override; 32 size_t Bytes() override; 33 34 // RenderTextureHostSWGL 35 size_t GetPlaneCount() const override; 36 37 gfx::SurfaceFormat GetFormat() const override; 38 39 gfx::ColorDepth GetColorDepth() const override; 40 41 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex, 42 PlaneInfo& aPlaneInfo) override; 43 44 void UnmapPlanes() override; 45 46 private: 47 virtual ~RenderSharedSurfaceTextureHost(); 48 49 RefPtr<gfx::SourceSurfaceSharedDataWrapper> mSurface; 50 gfx::DataSourceSurface::MappedSurface mMap; 51 bool mLocked; 52 }; 53 54 } // namespace wr 55 } // namespace mozilla 56 57 #endif // MOZILLA_GFX_RENDERSHAREDSURFACETEXTUREHOST_H