2014-01-08 00:02:18 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
|
|
|
/* 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 GLCONTEXTEGL_H_
|
|
|
|
#define GLCONTEXTEGL_H_
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "GLLibraryEGL.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2017-01-21 02:31:02 +03:00
|
|
|
namespace widget {
|
|
|
|
class CompositorWidget;
|
|
|
|
} // namespace widget
|
2014-01-08 00:02:18 +04:00
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLContextEGL : public GLContext
|
|
|
|
{
|
|
|
|
friend class TextureImageEGL;
|
|
|
|
|
|
|
|
static already_AddRefed<GLContextEGL>
|
2015-11-27 22:02:52 +03:00
|
|
|
CreateGLContext(CreateContextFlags flags,
|
|
|
|
const SurfaceCaps& caps,
|
2014-01-08 00:02:18 +04:00
|
|
|
bool isOffscreen,
|
|
|
|
EGLConfig config,
|
2016-06-06 23:52:42 +03:00
|
|
|
EGLSurface surface,
|
2016-06-11 05:01:00 +03:00
|
|
|
nsACString* const out_failureId);
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL, override)
|
2016-06-07 02:27:43 +03:00
|
|
|
GLContextEGL(CreateContextFlags flags,
|
|
|
|
const SurfaceCaps& caps,
|
2014-01-08 00:02:18 +04:00
|
|
|
bool isOffscreen,
|
|
|
|
EGLConfig config,
|
|
|
|
EGLSurface surface,
|
|
|
|
EGLContext context);
|
|
|
|
|
|
|
|
~GLContextEGL();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual GLContextType GetContextType() const override { return GLContextType::EGL; }
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
static GLContextEGL* Cast(GLContext* gl) {
|
2014-01-10 22:55:24 +04:00
|
|
|
MOZ_ASSERT(gl->GetContextType() == GLContextType::EGL);
|
2014-01-08 00:02:18 +04:00
|
|
|
return static_cast<GLContextEGL*>(gl);
|
2014-01-08 00:02:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
bool Init() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsDoubleBuffered() const override {
|
2014-01-08 00:02:18 +04:00
|
|
|
return mIsDoubleBuffered;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetIsDoubleBuffered(bool aIsDB) {
|
|
|
|
mIsDoubleBuffered = aIsDB;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsANGLE() const override {
|
2018-06-04 05:09:29 +03:00
|
|
|
return GLLibraryEGL::Get()->IsANGLE();
|
2014-01-08 00:02:18 +04:00
|
|
|
}
|
|
|
|
|
2015-07-23 20:11:04 +03:00
|
|
|
virtual bool IsWARP() const override {
|
2018-06-04 05:09:29 +03:00
|
|
|
return GLLibraryEGL::Get()->IsWARP();
|
2015-07-23 20:11:04 +03:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool BindTexImage() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ReleaseTexImage() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
void SetEGLSurfaceOverride(EGLSurface surf);
|
2017-03-04 00:14:27 +03:00
|
|
|
EGLSurface GetEGLSurfaceOverride() {
|
|
|
|
return mSurfaceOverride;
|
|
|
|
}
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2017-08-15 23:21:37 +03:00
|
|
|
virtual bool MakeCurrentImpl() const override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2017-08-11 23:54:40 +03:00
|
|
|
virtual bool IsCurrentImpl() const override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2017-01-21 02:31:02 +03:00
|
|
|
virtual bool RenewSurface(widget::CompositorWidget* aWidget) override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ReleaseSurface() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool SetupLookupFunction() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool SwapBuffers() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2017-01-31 05:58:52 +03:00
|
|
|
virtual void GetWSIInfo(nsCString* const out) const override;
|
|
|
|
|
2014-01-08 00:02:18 +04:00
|
|
|
// hold a reference to the given surface
|
|
|
|
// for the lifetime of this context.
|
2016-06-11 04:37:07 +03:00
|
|
|
void HoldSurface(gfxASurface* aSurf);
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-09-24 22:21:05 +03:00
|
|
|
EGLSurface GetEGLSurface() const {
|
2015-04-17 19:28:41 +03:00
|
|
|
return mSurface;
|
|
|
|
}
|
|
|
|
|
2015-09-24 22:21:05 +03:00
|
|
|
EGLDisplay GetEGLDisplay() const {
|
2018-06-04 05:09:29 +03:00
|
|
|
return GLLibraryEGL::Get()->Display();
|
2015-04-17 19:28:41 +03:00
|
|
|
}
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
bool BindTex2DOffscreen(GLContext* aOffscreen);
|
|
|
|
void UnbindTex2DOffscreen(GLContext* aOffscreen);
|
2014-01-08 00:02:18 +04:00
|
|
|
void BindOffscreenFramebuffer();
|
|
|
|
|
2018-06-04 05:09:52 +03:00
|
|
|
void Destroy();
|
|
|
|
|
2014-01-08 00:02:18 +04:00
|
|
|
static already_AddRefed<GLContextEGL>
|
2015-11-27 22:02:52 +03:00
|
|
|
CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
|
|
|
|
const gfx::IntSize& size,
|
2016-06-06 23:52:42 +03:00
|
|
|
const SurfaceCaps& minCaps,
|
2016-06-11 05:01:00 +03:00
|
|
|
nsACString* const out_FailureId);
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class GLContextProviderEGL;
|
2017-01-21 03:20:59 +03:00
|
|
|
friend class GLContextEGLFactory;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-09-24 22:21:05 +03:00
|
|
|
public:
|
2017-07-18 05:17:41 +03:00
|
|
|
const EGLConfig mConfig;
|
2015-09-24 22:21:05 +03:00
|
|
|
protected:
|
2018-06-04 05:09:52 +03:00
|
|
|
const RefPtr<GLLibraryEGL> mEgl;
|
2014-01-08 00:02:18 +04:00
|
|
|
EGLSurface mSurface;
|
2018-04-25 22:30:27 +03:00
|
|
|
const EGLSurface mFallbackSurface;
|
2015-09-24 22:21:05 +03:00
|
|
|
public:
|
|
|
|
const EGLContext mContext;
|
|
|
|
protected:
|
2018-08-18 01:21:26 +03:00
|
|
|
EGLSurface mSurfaceOverride = EGL_NO_SURFACE;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxASurface> mThebesSurface;
|
2018-08-18 01:21:26 +03:00
|
|
|
bool mBound = false;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2018-08-18 01:21:26 +03:00
|
|
|
bool mIsPBuffer = false;
|
|
|
|
bool mIsDoubleBuffered = false;
|
|
|
|
bool mCanBindToTexture = false;
|
|
|
|
bool mShareWithEGLImage = false;
|
|
|
|
bool mOwnsContext = true;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
|
|
|
|
EGLenum bindToTextureFormat,
|
2015-05-28 12:45:33 +03:00
|
|
|
gfx::IntSize& pbsize);
|
2018-05-22 11:34:32 +03:00
|
|
|
#if defined(MOZ_WAYLAND)
|
|
|
|
static EGLSurface CreateWaylandBufferSurface(EGLConfig config,
|
|
|
|
gfx::IntSize& pbsize);
|
|
|
|
#endif
|
2017-06-07 03:26:49 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
public:
|
|
|
|
EGLSurface CreateCompatibleSurface(void* aWindow);
|
|
|
|
#endif // defined(MOZ_WIDGET_ANDROID)
|
2014-01-08 00:02:18 +04:00
|
|
|
};
|
|
|
|
|
2018-02-01 15:39:31 +03:00
|
|
|
bool CreateConfig(EGLConfig* config, int32_t depth, bool enableDepthBuffer);
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
|
|
|
} // namespace mozilla
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
#endif // GLCONTEXTEGL_H_
|