Bug 1913305 - Add test. r=mtigley
[gecko.git] / gfx / webrender_bindings / RenderEGLImageTextureHost.h
blob4fe2adad2cb27880d9d9b88eb125f129bfc8c146
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_RENDEREGLIMAGETEXTUREHOST_H
8 #define MOZILLA_GFX_RENDEREGLIMAGETEXTUREHOST_H
10 #include "mozilla/layers/TextureHostOGL.h"
11 #include "RenderTextureHostSWGL.h"
13 namespace mozilla {
15 namespace wr {
17 // RenderEGLImageTextureHost is created only for SharedSurface_EGLImage that is
18 // created in parent process.
19 class RenderEGLImageTextureHost final : public RenderTextureHostSWGL {
20 public:
21 RenderEGLImageTextureHost(EGLImage aImage, EGLSync aSync, gfx::IntSize aSize,
22 gfx::SurfaceFormat aFormat);
24 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
25 void Unlock() override;
26 size_t Bytes() override {
27 return mSize.width * mSize.height * BytesPerPixel(mFormat);
30 RenderEGLImageTextureHost* AsRenderEGLImageTextureHost() override {
31 return this;
34 RefPtr<layers::TextureSource> CreateTextureSource(
35 layers::TextureSourceProvider* aProvider) override;
37 // RenderTextureHostSWGL
38 gfx::SurfaceFormat GetFormat() const override;
39 gfx::ColorDepth GetColorDepth() const override {
40 return gfx::ColorDepth::COLOR_8;
42 size_t GetPlaneCount() const override { return 1; };
43 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
44 PlaneInfo& aPlaneInfo) override;
45 void UnmapPlanes() override;
47 private:
48 virtual ~RenderEGLImageTextureHost();
49 bool CreateTextureHandle();
50 void DeleteTextureHandle();
51 bool WaitSync();
52 already_AddRefed<gfx::DataSourceSurface> ReadTexImage();
54 const EGLImage mImage;
55 EGLSync mSync;
56 const gfx::IntSize mSize;
57 const gfx::SurfaceFormat mFormat;
59 RefPtr<gl::GLContext> mGL;
60 GLenum mTextureTarget;
61 GLuint mTextureHandle;
62 RefPtr<gfx::DataSourceSurface> mReadback;
65 } // namespace wr
66 } // namespace mozilla
68 #endif // MOZILLA_GFX_RENDEREGLIMAGETEXTUREHOST_H