Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / gfx / webrender_bindings / RenderDMABUFTextureHost.h
bloba94b7c9c9df753a7433065d4d8f580a59daaed6c
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"
15 namespace mozilla {
17 namespace layers {
18 class SurfaceDescriptorDMABuf;
21 namespace wr {
23 class RenderDMABUFTextureHost final : public RenderTextureHostSWGL {
24 public:
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;
46 private:
47 virtual ~RenderDMABUFTextureHost();
48 void DeleteTextureHandle();
50 RefPtr<DMABufSurface> mSurface;
51 RefPtr<gl::GLContext> mGL;
52 RefPtr<gfx::DataSourceSurface> mReadback;
55 } // namespace wr
56 } // namespace mozilla
58 #endif // MOZILLA_GFX_RENDERDMABUFTEXTUREHOST_H