Bug 1666648 [wpt PR 25683] - Fix #23969: Use inexact test type for DUPLICATE-BASENAME...
[gecko.git] / gfx / gl / SharedSurfaceEGL.h
bloba6325fd340369a059f056b94bdb0a8f23b2d0da2
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef SHARED_SURFACE_EGL_H_
7 #define SHARED_SURFACE_EGL_H_
9 #include "mozilla/Attributes.h"
10 #include "mozilla/Mutex.h"
11 #include "CompositorTypes.h"
12 #include "SharedSurface.h"
14 #ifdef MOZ_WIDGET_ANDROID
15 # include "AndroidNativeWindow.h"
16 # include "GLLibraryEGL.h"
17 #endif
19 namespace mozilla {
20 namespace gl {
22 class GLLibraryEGL;
24 // -
25 // EGLImage
27 class SharedSurface_EGLImage final : public SharedSurface {
28 mutable Mutex mMutex;
29 EGLSync mSync = 0;
31 public:
32 const EGLImage mImage;
34 static UniquePtr<SharedSurface_EGLImage> Create(const SharedSurfaceDesc&);
36 protected:
37 SharedSurface_EGLImage(const SharedSurfaceDesc&,
38 UniquePtr<MozFramebuffer>&& fb, EGLImage);
40 void UpdateProdTexture(const MutexAutoLock& curAutoLock);
42 public:
43 virtual ~SharedSurface_EGLImage();
45 virtual void LockProdImpl() override {}
46 virtual void UnlockProdImpl() override {}
48 virtual void ProducerAcquireImpl() override {}
49 virtual void ProducerReleaseImpl() override;
51 virtual void ProducerReadAcquireImpl() override;
52 virtual void ProducerReadReleaseImpl() override{};
54 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
57 class SurfaceFactory_EGLImage final : public SurfaceFactory {
58 public:
59 static UniquePtr<SurfaceFactory_EGLImage> Create(GLContext&);
61 private:
62 explicit SurfaceFactory_EGLImage(const PartialSharedSurfaceDesc& desc)
63 : SurfaceFactory(desc) {}
65 public:
66 virtual UniquePtr<SharedSurface> CreateSharedImpl(
67 const SharedSurfaceDesc& desc) override {
68 return SharedSurface_EGLImage::Create(desc);
72 // -
73 // SurfaceTexture
75 #ifdef MOZ_WIDGET_ANDROID
77 class SharedSurface_SurfaceTexture final : public SharedSurface {
78 const java::GeckoSurface::GlobalRef mSurface;
79 const EGLSurface mEglSurface;
80 const std::weak_ptr<EglDisplay> mEglDisplay;
81 EGLSurface mOrigEglSurface = 0;
83 public:
84 static UniquePtr<SharedSurface_SurfaceTexture> Create(
85 const SharedSurfaceDesc&);
87 java::GeckoSurface::Param JavaSurface() { return mSurface; }
89 protected:
90 SharedSurface_SurfaceTexture(const SharedSurfaceDesc&,
91 java::GeckoSurface::Param surface, EGLSurface);
93 public:
94 virtual ~SharedSurface_SurfaceTexture();
96 virtual void LockProdImpl() override;
97 virtual void UnlockProdImpl() override;
99 virtual void ProducerAcquireImpl() override {}
100 virtual void ProducerReleaseImpl() override {}
101 virtual void ProducerReadReleaseImpl() override;
103 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
105 virtual void Commit() override;
107 virtual void WaitForBufferOwnership() override;
109 virtual bool IsBufferAvailable() const override;
112 class SurfaceFactory_SurfaceTexture final : public SurfaceFactory {
113 public:
114 explicit SurfaceFactory_SurfaceTexture(GLContext&);
116 virtual UniquePtr<SharedSurface> CreateSharedImpl(
117 const SharedSurfaceDesc& desc) override {
118 return SharedSurface_SurfaceTexture::Create(desc);
122 #endif // MOZ_WIDGET_ANDROID
124 } // namespace gl
126 } /* namespace mozilla */
128 #endif /* SHARED_SURFACE_EGL_H_ */