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"
17 // RenderEGLImageTextureHost is created only for SharedSurface_EGLImage that is
18 // created in parent process.
19 class RenderEGLImageTextureHost final
: public RenderTextureHostSWGL
{
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
{
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
;
48 virtual ~RenderEGLImageTextureHost();
49 bool CreateTextureHandle();
50 void DeleteTextureHandle();
52 already_AddRefed
<gfx::DataSourceSurface
> ReadTexImage();
54 const EGLImage mImage
;
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
;
66 } // namespace mozilla
68 #endif // MOZILLA_GFX_RENDEREGLIMAGETEXTUREHOST_H