summaryrefslogtreecommitdiffstats
path: root/gfx/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/GLBlitHelper.cpp5
-rw-r--r--gfx/gl/GLContext.cpp17
-rw-r--r--gfx/gl/GLContextEAGL.h19
-rw-r--r--gfx/gl/GLContextProvider.h8
-rw-r--r--gfx/gl/GLContextProviderEAGL.mm74
-rw-r--r--gfx/gl/GLTypes.h7
-rw-r--r--gfx/gl/SharedSurface.cpp14
-rw-r--r--gfx/gl/SharedSurfaceIO.cpp11
-rw-r--r--gfx/gl/moz.build1
9 files changed, 51 insertions, 105 deletions
diff --git a/gfx/gl/GLBlitHelper.cpp b/gfx/gl/GLBlitHelper.cpp
index dd9fa00235..c5c8995dab 100644
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -1176,8 +1176,6 @@ bool GLBlitHelper::BlitImage(MacIOSurface* const iosurf,
MOZ_ASSERT(false);
return false;
}
- const auto glCGL = static_cast<GLContextCGL*>(mGL);
- const auto cglContext = glCGL->GetCGLContext();
const auto& srcOrigin = OriginPos::BottomLeft;
@@ -1268,8 +1266,7 @@ bool GLBlitHelper::BlitImage(MacIOSurface* const iosurf,
mGL->fBindTexture(texTarget, texs[p]);
mGL->TexParams_SetClampNoMips(texTarget);
- auto err = iosurf->CGLTexImageIOSurface2D(mGL, cglContext, p);
- if (err) {
+ if (!iosurf->BindTexImage(mGL, p)) {
return false;
}
diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp
index 9036653af8..5eba6c58aa 100644
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -2049,17 +2049,24 @@ static void ReportArrayContents(
nsTArray<GLContext::NamedResource> copy(aArray.Clone());
copy.Sort();
+ // Accumulate the output in a buffer to avoid interleaved output.
+ nsCString line;
+
GLContext* lastContext = nullptr;
for (uint32_t i = 0; i < copy.Length(); ++i) {
if (lastContext != copy[i].origin) {
- if (lastContext) printf_stderr("\n");
- printf_stderr(" [%p - %s] ", copy[i].origin,
- copy[i].originDeleted ? "deleted" : "live");
+ if (lastContext) {
+ printf_stderr("%s\n", line.BeginReading());
+ line.Assign("");
+ }
+ line.Append(nsPrintfCString(" [%p - %s] ", copy[i].origin,
+ copy[i].originDeleted ? "deleted" : "live"));
lastContext = copy[i].origin;
}
- printf_stderr("%d ", copy[i].name);
+ line.AppendInt(copy[i].name);
+ line.Append(' ');
}
- printf_stderr("\n");
+ printf_stderr("%s\n", line.BeginReading());
}
void GLContext::ReportOutstandingNames() {
diff --git a/gfx/gl/GLContextEAGL.h b/gfx/gl/GLContextEAGL.h
index 6e137e7b70..2b062d1a0f 100644
--- a/gfx/gl/GLContextEAGL.h
+++ b/gfx/gl/GLContextEAGL.h
@@ -10,7 +10,11 @@
#include "GLContext.h"
#include <CoreGraphics/CoreGraphics.h>
-#include <OpenGLES/EAGL.h>
+#ifdef __OBJC__
+# include <OpenGLES/EAGL.h>
+#else
+typedef void EAGLContext;
+#endif
namespace mozilla {
namespace gl {
@@ -23,7 +27,7 @@ class GLContextEAGL : public GLContext {
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEAGL, override)
GLContextEAGL(const GLContextDesc&, EAGLContext* context,
- GLContext* sharedContext, ContextProfile profile);
+ GLContext* sharedContext);
~GLContextEAGL();
@@ -36,8 +40,6 @@ class GLContextEAGL : public GLContext {
return static_cast<GLContextEAGL*>(gl);
}
- bool AttachToWindow(nsIWidget* aWidget);
-
EAGLContext* GetEAGLContext() const { return mContext; }
virtual bool MakeCurrentImpl() const override;
@@ -54,18 +56,9 @@ class GLContextEAGL : public GLContext {
virtual GLuint GetDefaultFramebuffer() override { return mBackbufferFB; }
- virtual bool RenewSurface(widget::CompositorWidget*) override {
- // FIXME: should use the passed widget instead of the existing one.
- return RecreateRB();
- }
-
private:
GLuint mBackbufferRB = 0;
GLuint mBackbufferFB = 0;
-
- void* mLayer = nullptr;
-
- bool RecreateRB();
};
} // namespace gl
diff --git a/gfx/gl/GLContextProvider.h b/gfx/gl/GLContextProvider.h
index c63f1ada0b..277b76efa8 100644
--- a/gfx/gl/GLContextProvider.h
+++ b/gfx/gl/GLContextProvider.h
@@ -60,10 +60,6 @@ namespace gl {
# define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderLinux
#endif
-#ifndef GL_CONTEXT_PROVIDER_DEFAULT
-# define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
-#endif
-
#if defined(MOZ_WIDGET_UIKIT)
# define GL_CONTEXT_PROVIDER_NAME GLContextProviderEAGL
# include "GLContextProviderImpl.h"
@@ -73,6 +69,10 @@ namespace gl {
# endif
#endif
+#ifndef GL_CONTEXT_PROVIDER_DEFAULT
+# define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
+#endif
+
#ifdef MOZ_GL_PROVIDER
# define GL_CONTEXT_PROVIDER_NAME MOZ_GL_PROVIDER
# include "GLContextProviderImpl.h"
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) {
diff --git a/gfx/gl/GLTypes.h b/gfx/gl/GLTypes.h
index f5b317b4b7..6caa1cc623 100644
--- a/gfx/gl/GLTypes.h
+++ b/gfx/gl/GLTypes.h
@@ -55,6 +55,13 @@ typedef signed long int GLsizeiptr;
#endif /* #if !defined(__gltypes_h_) && !defined(__gl_h_) */
+#ifdef XP_IOS
+# ifndef GLdouble_defined
+typedef double GLdouble;
+# endif
+typedef double GLclampd;
+#endif
+
#include <stdint.h>
// ARB_sync
diff --git a/gfx/gl/SharedSurface.cpp b/gfx/gl/SharedSurface.cpp
index 2fbfd3f625..0465926521 100644
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -89,13 +89,13 @@ UniquePtr<SurfaceFactory> SurfaceFactory::Create(
return SurfaceFactory_D3D11Interop::Create(gl);
}
#endif
- return nullptr;
+ break;
case layers::TextureType::MacIOSurface:
#ifdef XP_MACOSX
return MakeUnique<SurfaceFactory_IOSurface>(gl);
#else
- return nullptr;
+ break;
#endif
case layers::TextureType::DMABUF:
@@ -105,13 +105,13 @@ UniquePtr<SurfaceFactory> SurfaceFactory::Create(
return SurfaceFactory_DMABUF::Create(gl);
}
#endif
- return nullptr;
+ break;
case layers::TextureType::AndroidNativeWindow:
#ifdef MOZ_WIDGET_ANDROID
return MakeUnique<SurfaceFactory_SurfaceTexture>(gl);
#else
- return nullptr;
+ break;
#endif
case layers::TextureType::AndroidHardwareBuffer:
@@ -121,7 +121,7 @@ UniquePtr<SurfaceFactory> SurfaceFactory::Create(
return SurfaceFactory_AndroidHardwareBuffer::Create(gl);
}
#endif
- return nullptr;
+ break;
case layers::TextureType::EGLImage:
#ifdef MOZ_WIDGET_ANDROID
@@ -129,17 +129,15 @@ UniquePtr<SurfaceFactory> SurfaceFactory::Create(
return SurfaceFactory_EGLImage::Create(gl);
}
#endif
- return nullptr;
+ break;
case layers::TextureType::Unknown:
case layers::TextureType::Last:
break;
}
-#ifdef MOZ_X11
// Silence a warning.
Unused << gl;
-#endif
return nullptr;
}
diff --git a/gfx/gl/SharedSurfaceIO.cpp b/gfx/gl/SharedSurfaceIO.cpp
index 1fd0f22d31..459faa64b3 100644
--- a/gfx/gl/SharedSurfaceIO.cpp
+++ b/gfx/gl/SharedSurfaceIO.cpp
@@ -28,7 +28,7 @@ SurfaceFactory_IOSurface::SurfaceFactory_IOSurface(GLContext& gl)
// -
// Surface
-static void BackTextureWithIOSurf(GLContext* const gl, const GLuint tex,
+static bool BackTextureWithIOSurf(GLContext* const gl, const GLuint tex,
MacIOSurface* const ioSurf) {
MOZ_ASSERT(gl->IsCurrent());
@@ -43,10 +43,7 @@ static void BackTextureWithIOSurf(GLContext* const gl, const GLuint tex,
gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T,
LOCAL_GL_CLAMP_TO_EDGE);
- CGLContextObj cgl = GLContextCGL::Cast(gl)->GetCGLContext();
- MOZ_ASSERT(cgl);
-
- ioSurf->CGLTexImageIOSurface2D(gl, cgl, 0);
+ return ioSurf->BindTexImage(gl, 0);
}
/*static*/
@@ -65,7 +62,9 @@ UniquePtr<SharedSurface_IOSurface> SharedSurface_IOSurface::Create(
// -
auto tex = MakeUnique<Texture>(*desc.gl);
- BackTextureWithIOSurf(desc.gl, tex->name, ioSurf);
+ if (!BackTextureWithIOSurf(desc.gl, tex->name, ioSurf)) {
+ return nullptr;
+ }
const GLenum target = LOCAL_GL_TEXTURE_RECTANGLE;
auto fb = MozFramebuffer::CreateForBacking(desc.gl, desc.size, 0, false,
diff --git a/gfx/gl/moz.build b/gfx/gl/moz.build
index f45e85b8f4..965b0add48 100644
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -12,6 +12,7 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
gl_provider = "CGL"
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
gl_provider = "EAGL"
+ DEFINES["GLES_SILENCE_DEPRECATION"] = 1
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
gl_provider = "Linux"
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":