mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 8430335. Cache the current context on B2G. r=jgilbert
This avoids the call to EGLGetCurrentContext() which calls EGLGetError which can be expensive. --HG-- extra : rebase_source : dc1357cdd45979b741d132b54f2a77cdde95bd00
This commit is contained in:
parent
ab59354e6b
commit
0870915334
@ -268,6 +268,7 @@ GLContextEGL::~GLContextEGL()
|
||||
#endif
|
||||
|
||||
sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
|
||||
sEGLLibrary.UnsetCachedCurrentContext();
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 17
|
||||
if (!mIsOffscreen) {
|
||||
@ -381,7 +382,18 @@ GLContextEGL::MakeCurrentImpl(bool aForce) {
|
||||
// Assume that EGL has the same problem as WGL does,
|
||||
// where MakeCurrent with an already-current context is
|
||||
// still expensive.
|
||||
if (aForce || sEGLLibrary.fGetCurrentContext() != mContext) {
|
||||
bool hasDifferentContext = false;
|
||||
if (sEGLLibrary.CachedCurrentContext() != mContext) {
|
||||
// even if the cached context doesn't match the current one
|
||||
// might still
|
||||
if (sEGLLibrary.fGetCurrentContext() != mContext) {
|
||||
hasDifferentContext = true;
|
||||
} else {
|
||||
sEGLLibrary.SetCachedCurrentContext(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
if (aForce || hasDifferentContext) {
|
||||
EGLSurface surface = mSurfaceOverride != EGL_NO_SURFACE
|
||||
? mSurfaceOverride
|
||||
: mSurface;
|
||||
@ -402,7 +414,11 @@ GLContextEGL::MakeCurrentImpl(bool aForce) {
|
||||
printf_stderr("EGL Error: 0x%04x\n", eglError);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
sEGLLibrary.SetCachedCurrentContext(mContext);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(sEGLLibrary.CachedCurrentContext() == sEGLLibrary.fGetCurrentContext());
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "gfxCrashReporterUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsPrintfCString.h"
|
||||
@ -20,7 +21,9 @@ namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
GLLibraryEGL sEGLLibrary;
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
ThreadLocal<EGLContext> GLLibraryEGL::sCurrentContext;
|
||||
#endif
|
||||
// should match the order of EGLExtensions, and be null-terminated.
|
||||
static const char *sEGLExtensionNames[] = {
|
||||
"EGL_KHR_image_base",
|
||||
@ -104,6 +107,10 @@ GLLibraryEGL::EnsureInitialized()
|
||||
|
||||
mozilla::ScopedGfxFeatureReporter reporter("EGL");
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
NS_ABORT_IF_FALSE(sCurrentContext.init());
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#ifdef MOZ_WEBGL
|
||||
if (!mEGLLibrary) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#endif
|
||||
|
||||
#include "GLLibraryLoader.h"
|
||||
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
#include <bitset>
|
||||
@ -529,6 +529,29 @@ public:
|
||||
static void AfterGLCall(const char* glFunction);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
EGLContext CachedCurrentContext() {
|
||||
return sCurrentContext.get();
|
||||
}
|
||||
void UnsetCachedCurrentContext() {
|
||||
sCurrentContext.set(nullptr);
|
||||
}
|
||||
void SetCachedCurrentContext(EGLContext aCtx) {
|
||||
sCurrentContext.set(aCtx);
|
||||
}
|
||||
|
||||
private:
|
||||
static ThreadLocal<EGLContext> sCurrentContext;
|
||||
public:
|
||||
|
||||
#else
|
||||
EGLContext CachedCurrentContext() {
|
||||
return nullptr;
|
||||
}
|
||||
void UnsetCachedCurrentContext() {}
|
||||
void SetCachedCurrentContext(EGLContext aCtx) { }
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool mInitialized;
|
||||
PRLibrary* mEGLLibrary;
|
||||
|
Loading…
Reference in New Issue
Block a user