summaryrefslogtreecommitdiffstats
path: root/gfx/gl/GLContextProviderEAGL.mm
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl/GLContextProviderEAGL.mm')
-rw-r--r--gfx/gl/GLContextProviderEAGL.mm74
1 files changed, 9 insertions, 65 deletions
diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm
index 6e27498028..648d6642d4 100644
--- a/gfx/gl/GLContextProviderEAGL.mm
+++ b/gfx/gl/GLContextProviderEAGL.mm
@@ -5,6 +5,7 @@
#include "GLContextProvider.h"
#include "GLContextEAGL.h"
+#include "GLLibraryLoader.h"
#include "nsDebug.h"
#include "nsIWidget.h"
#include "gfxFailure.h"
@@ -38,58 +39,12 @@ GLContextEAGL::~GLContextEAGL() {
MarkDestroyed();
- if (mLayer) {
- mLayer = nil;
- }
-
if (mContext) {
[EAGLContext setCurrentContext:nil];
[mContext release];
}
}
-bool GLContextEAGL::AttachToWindow(nsIWidget* aWidget) {
- // This should only be called once
- MOZ_ASSERT(!mBackbufferFB && !mBackbufferRB);
-
- UIView* view =
- reinterpret_cast<UIView*>(aWidget->GetNativeData(NS_NATIVE_WIDGET));
-
- if (!view) {
- MOZ_CRASH("no view!");
- }
-
- mLayer = [view layer];
-
- fGenFramebuffers(1, &mBackbufferFB);
- return RecreateRB();
-}
-
-bool GLContextEAGL::RecreateRB() {
- MakeCurrent();
-
- CAEAGLLayer* layer = (CAEAGLLayer*)mLayer;
-
- if (mBackbufferRB) {
- // It doesn't seem to be enough to just call renderbufferStorage: below,
- // we apparently have to recreate the RB.
- fDeleteRenderbuffers(1, &mBackbufferRB);
- mBackbufferRB = 0;
- }
-
- fGenRenderbuffers(1, &mBackbufferRB);
- fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mBackbufferRB);
-
- [mContext renderbufferStorage:LOCAL_GL_RENDERBUFFER fromDrawable:layer];
-
- fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mBackbufferFB);
- fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
- LOCAL_GL_RENDERBUFFER, mBackbufferRB);
-
- return LOCAL_GL_FRAMEBUFFER_COMPLETE ==
- fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
-}
-
bool GLContextEAGL::MakeCurrentImpl() const {
if (mContext) {
GLContext::ResetTLSCurrentContext();
@@ -107,7 +62,7 @@ bool GLContextEAGL::IsCurrentImpl() const {
static PRFuncPtr GLAPIENTRY GetLoadedProcAddress(const char* const name) {
PRLibrary* lib = nullptr;
- const auto& ret = PR_FindFunctionSymbolAndLibrary(name, &leakedLibRef);
+ const auto& ret = PR_FindFunctionSymbolAndLibrary(name, &lib);
if (lib) {
PR_UnloadLibrary(lib);
}
@@ -173,29 +128,17 @@ static RefPtr<GLContext> CreateEAGLContext(const GLContextDesc& desc,
already_AddRefed<GLContext> GLContextProviderEAGL::CreateForCompositorWidget(
CompositorWidget* aCompositorWidget, bool aHardwareWebRender,
bool aForceAccelerated) {
- if (!aCompositorWidget) {
- MOZ_ASSERT(false);
- return nullptr;
+ CreateContextFlags flags = CreateContextFlags::ALLOW_OFFLINE_RENDERER;
+ if (aForceAccelerated) {
+ flags |= CreateContextFlags::FORBID_SOFTWARE;
}
-
- const GLContextDesc desc = {};
- auto glContext = CreateEAGLContext(desc, GetGlobalContextEAGL());
- if (!glContext) {
- return nullptr;
- }
-
- if (!GLContextEAGL::Cast(glContext)->AttachToWindow(
- aCompositorWidget->RealWidget())) {
- return nullptr;
- }
-
- return glContext.forget();
+ nsCString failureUnused;
+ return CreateHeadless({flags}, &failureUnused);
}
already_AddRefed<GLContext> GLContextProviderEAGL::CreateHeadless(
const GLContextCreateDesc& createDesc, nsACString* const out_failureId) {
auto desc = GLContextDesc{createDesc};
- desc.isOffcreen = true;
return CreateEAGLContext(desc, GetGlobalContextEAGL()).forget();
}
@@ -208,7 +151,8 @@ GLContext* GLContextProviderEAGL::GetGlobalContext() {
MOZ_RELEASE_ASSERT(!gGlobalContext,
"GFX: Global GL context already initialized.");
- RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE);
+ nsCString discardFailureId;
+ RefPtr<GLContext> temp = CreateHeadless({}, &discardFailureId);
gGlobalContext = temp;
if (!gGlobalContext) {