Bug 1527534 - Reuse LoadApitraceLibrary. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D20418
This commit is contained in:
Jeff Gilbert 2019-02-19 15:43:39 -08:00
Родитель 212b1367d5
Коммит 8fda14347f
4 изменённых файлов: 19 добавлений и 27 удалений

Просмотреть файл

@ -366,11 +366,8 @@ GLContextEGL::~GLContextEGL() {
}
bool GLContextEGL::Init() {
#if defined(ANDROID)
// We can't use LoadApitraceLibrary here because the GLContext
// expects its own handle to the GL library
if (!OpenLibrary(APITRACE_LIB))
#endif
mLibrary = LoadApitraceLibrary();
if (!mLibrary) {
if (!OpenLibrary(GLES2_LIB)) {
#if defined(XP_UNIX)
if (!OpenLibrary(GLES2_LIB2)) {
@ -379,6 +376,7 @@ bool GLContextEGL::Init() {
}
#endif
}
}
SetupLookupFunction();
if (!InitWithPrefix("gl", true)) return false;

Просмотреть файл

@ -72,9 +72,18 @@ static const char* sEGLExtensionNames[] = {
"EGL_KHR_create_context_no_error",
"EGL_MOZ_create_context_provoking_vertex_dont_care"};
#if defined(ANDROID)
PRLibrary* LoadApitraceLibrary() {
const char* path = nullptr;
#ifdef ANDROID
// We only need to explicitly dlopen egltrace
// on android as we can use LD_PRELOAD or other tricks
// on other platforms. We look for it in /data/local
// as that's writeable by all users.
path = "/data/local/tmp/egltrace.so";
#endif
if (!path) return nullptr;
static PRLibrary* LoadApitraceLibrary() {
// Initialization of gfx prefs here is only needed during the unit tests...
gfxPrefs::GetSingleton();
if (!gfxPrefs::UseApitrace()) {
@ -82,7 +91,6 @@ static PRLibrary* LoadApitraceLibrary() {
}
static PRLibrary* sApitraceLibrary = nullptr;
if (sApitraceLibrary) return sApitraceLibrary;
nsAutoCString logFile;
@ -96,20 +104,19 @@ static PRLibrary* LoadApitraceLibrary() {
nsAutoCString logPath;
logPath.AppendPrintf("%s/%s", getenv("GRE_HOME"), logFile.get());
#ifndef XP_WIN // Windows is missing setenv and forbids PR_LoadLibrary.
// apitrace uses the TRACE_FILE environment variable to determine where
// to log trace output to
printf_stderr("Logging GL tracing output to %s", logPath.get());
setenv("TRACE_FILE", logPath.get(), false);
printf_stderr("Attempting load of %s\n", APITRACE_LIB);
sApitraceLibrary = PR_LoadLibrary(APITRACE_LIB);
printf_stderr("Attempting load of %s\n", path);
sApitraceLibrary = PR_LoadLibrary(path);
#endif
return sApitraceLibrary;
}
#endif // ANDROID
#ifdef XP_WIN
// see the comment in GLLibraryEGL::EnsureInitialized() for the rationale here.
static PRLibrary* LoadLibraryForEGLOnWindows(const nsAString& filename) {

Просмотреть файл

@ -18,18 +18,6 @@
#include <bitset>
#include <vector>
#ifdef ANDROID
// We only need to explicitly dlopen egltrace
// on android as we can use LD_PRELOAD or other tricks
// on other platforms. We look for it in /data/local
// as that's writeable by all users
//
// This should really go in GLLibraryEGL.cpp but we currently reference
// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
// will come in subsequent patches on Bug 732865
# define APITRACE_LIB "/data/local/tmp/egltrace.so"
#endif
#if defined(MOZ_X11)
# define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)mozilla::DefaultXDisplay())
#else
@ -51,6 +39,7 @@ class DataSourceSurface;
namespace gl {
class GLContext;
PRLibrary* LoadApitraceLibrary();
void BeforeEGLCall(const char* funcName);
void AfterEGLCall(const char* funcName);

Просмотреть файл

@ -451,9 +451,7 @@ class gfxPrefs final {
SmoothScrollMSDPhysicsRegularSpringConstant, int32_t, 1000);
DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false);
#if defined(ANDROID)
DECL_GFX_PREF(Once, "gfx.apitrace.enabled", UseApitrace, bool, false);
#endif
#if defined(RELEASE_OR_BETA)
// "Skip" means this is locked to the default value in beta and release.
DECL_GFX_PREF(Skip, "gfx.blocklist.all", BlocklistAll, int32_t, 0);