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 {
|
2014-01-08 00:02:18 +04:00
|
|
|
return sEGLLibrary.IsANGLE();
|
|
|
|
}
|
|
|
|
|
2015-07-23 20:11:04 +03:00
|
|
|
virtual bool IsWARP() const override {
|
|
|
|
return sEGLLibrary.IsWARP();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool MakeCurrentImpl(bool aForce) override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsCurrent() 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 {
|
|
|
|
return sEGLLibrary.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();
|
|
|
|
|
|
|
|
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:
|
|
|
|
const EGLConfig mConfig;
|
|
|
|
protected:
|
2014-01-08 00:02:18 +04:00
|
|
|
EGLSurface mSurface;
|
2015-09-24 22:21:05 +03:00
|
|
|
public:
|
|
|
|
const EGLContext mContext;
|
|
|
|
protected:
|
2014-01-08 00:02:18 +04:00
|
|
|
EGLSurface mSurfaceOverride;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxASurface> mThebesSurface;
|
2014-01-08 00:02:18 +04:00
|
|
|
bool mBound;
|
|
|
|
|
|
|
|
bool mIsPBuffer;
|
|
|
|
bool mIsDoubleBuffered;
|
|
|
|
bool mCanBindToTexture;
|
|
|
|
bool mShareWithEGLImage;
|
2014-04-15 18:57:26 +04:00
|
|
|
bool mOwnsContext;
|
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);
|
2014-01-08 00:02:18 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
|
|
|
} // namespace mozilla
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
#endif // GLCONTEXTEGL_H_
|