2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
|
2013-02-14 03:26:24 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef SHARED_SURFACE_EGL_H_
|
|
|
|
#define SHARED_SURFACE_EGL_H_
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
2020-01-09 01:19:23 +03:00
|
|
|
#include "CompositorTypes.h"
|
2014-07-12 02:10:49 +04:00
|
|
|
#include "SharedSurface.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2017-03-04 00:14:27 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
# include "AndroidNativeWindow.h"
|
2020-09-01 16:00:39 +03:00
|
|
|
# include "GLLibraryEGL.h"
|
2017-03-04 00:14:27 +03:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2014-07-12 02:10:49 +04:00
|
|
|
class GLLibraryEGL;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
// -
|
|
|
|
// EGLImage
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
class SharedSurface_EGLImage final : public SharedSurface {
|
2022-03-16 21:47:08 +03:00
|
|
|
mutable Mutex mMutex MOZ_UNANNOTATED;
|
2020-06-15 21:25:55 +03:00
|
|
|
EGLSync mSync = 0;
|
2017-03-04 00:14:27 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
const EGLImage mImage;
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
static UniquePtr<SharedSurface_EGLImage> Create(const SharedSurfaceDesc&);
|
2020-06-11 19:44:20 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
protected:
|
|
|
|
SharedSurface_EGLImage(const SharedSurfaceDesc&,
|
|
|
|
UniquePtr<MozFramebuffer>&& fb, EGLImage);
|
2017-03-04 00:14:27 +03:00
|
|
|
|
|
|
|
void UpdateProdTexture(const MutexAutoLock& curAutoLock);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_EGLImage();
|
|
|
|
|
|
|
|
virtual void LockProdImpl() override {}
|
|
|
|
virtual void UnlockProdImpl() override {}
|
|
|
|
|
|
|
|
virtual void ProducerAcquireImpl() override {}
|
|
|
|
virtual void ProducerReleaseImpl() override;
|
|
|
|
|
|
|
|
virtual void ProducerReadAcquireImpl() override;
|
|
|
|
virtual void ProducerReadReleaseImpl() override{};
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
2017-03-04 00:14:27 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
class SurfaceFactory_EGLImage final : public SurfaceFactory {
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2020-06-15 21:25:55 +03:00
|
|
|
static UniquePtr<SurfaceFactory_EGLImage> Create(GLContext&);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
private:
|
|
|
|
explicit SurfaceFactory_EGLImage(const PartialSharedSurfaceDesc& desc)
|
|
|
|
: SurfaceFactory(desc) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2020-06-15 21:25:55 +03:00
|
|
|
virtual UniquePtr<SharedSurface> CreateSharedImpl(
|
|
|
|
const SharedSurfaceDesc& desc) override {
|
|
|
|
return SharedSurface_EGLImage::Create(desc);
|
2017-03-04 00:14:27 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
2017-03-04 00:14:27 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
// -
|
|
|
|
// SurfaceTexture
|
|
|
|
|
2017-03-04 00:14:27 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
class SharedSurface_SurfaceTexture final : public SharedSurface {
|
|
|
|
const java::GeckoSurface::GlobalRef mSurface;
|
|
|
|
const EGLSurface mEglSurface;
|
2020-09-01 16:00:39 +03:00
|
|
|
const std::weak_ptr<EglDisplay> mEglDisplay;
|
2020-06-15 21:25:55 +03:00
|
|
|
EGLSurface mOrigEglSurface = 0;
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2017-03-04 00:14:27 +03:00
|
|
|
static UniquePtr<SharedSurface_SurfaceTexture> Create(
|
2020-06-15 21:25:55 +03:00
|
|
|
const SharedSurfaceDesc&);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-28 13:33:55 +03:00
|
|
|
java::GeckoSurface::Param JavaSurface() { return mSurface; }
|
2017-03-04 00:14:27 +03:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
protected:
|
2020-06-15 21:25:55 +03:00
|
|
|
SharedSurface_SurfaceTexture(const SharedSurfaceDesc&,
|
|
|
|
java::GeckoSurface::Param surface, EGLSurface);
|
2017-03-04 00:14:27 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_SurfaceTexture();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void LockProdImpl() override;
|
2017-03-04 00:14:27 +03:00
|
|
|
virtual void UnlockProdImpl() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-01-06 02:57:44 +03:00
|
|
|
virtual void ProducerAcquireImpl() override {}
|
2017-03-04 00:14:27 +03:00
|
|
|
virtual void ProducerReleaseImpl() override {}
|
2020-07-09 21:31:12 +03:00
|
|
|
virtual void ProducerReadReleaseImpl() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-03-04 00:14:27 +03:00
|
|
|
virtual void Commit() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-03-04 00:14:27 +03:00
|
|
|
virtual void WaitForBufferOwnership() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-28 13:33:55 +03:00
|
|
|
virtual bool IsBufferAvailable() const override;
|
2022-02-02 20:01:02 +03:00
|
|
|
|
|
|
|
bool IsValid() const override;
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
2017-03-04 00:14:27 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
class SurfaceFactory_SurfaceTexture final : public SurfaceFactory {
|
2017-03-04 00:14:27 +03:00
|
|
|
public:
|
2020-06-15 21:25:55 +03:00
|
|
|
explicit SurfaceFactory_SurfaceTexture(GLContext&);
|
2020-06-11 19:44:20 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
virtual UniquePtr<SharedSurface> CreateSharedImpl(
|
|
|
|
const SharedSurfaceDesc& desc) override {
|
|
|
|
return SharedSurface_SurfaceTexture::Create(desc);
|
|
|
|
}
|
2017-03-04 00:14:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_EGL_H_ */
|