1527534.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. From dcd5a0e59bef209aa8301a427b749830876cdada Mon Sep 17 00:00:00 2001
  2. From: Jeff Gilbert <jgilbert@mozilla.com>
  3. Date: Tue, 19 Feb 2019 15:43:39 -0800
  4. Subject: [PATCH] Bug 1527534 - Reuse LoadApitraceLibrary. r=lsalzman a=lizzard
  5. Differential Revision: https://phabricator.services.mozilla.com/D20418
  6. diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp
  7. index d91d03aee6a9..f4d8c1f80176 100644
  8. --- a/gfx/gl/GLContextProviderEGL.cpp
  9. +++ b/gfx/gl/GLContextProviderEGL.cpp
  10. @@ -265,11 +265,8 @@ GLContextEGL::~GLContextEGL() {
  11. }
  12. bool GLContextEGL::Init() {
  13. -#if defined(ANDROID)
  14. - // We can't use LoadApitraceLibrary here because the GLContext
  15. - // expects its own handle to the GL library
  16. - if (!OpenLibrary(APITRACE_LIB))
  17. -#endif
  18. + mLibrary = LoadApitraceLibrary();
  19. + if (!mLibrary) {
  20. if (!OpenLibrary(GLES2_LIB)) {
  21. #if defined(XP_UNIX)
  22. if (!OpenLibrary(GLES2_LIB2)) {
  23. @@ -278,6 +275,7 @@ bool GLContextEGL::Init() {
  24. }
  25. #endif
  26. }
  27. + }
  28. SetupLookupFunction();
  29. if (!InitWithPrefix("gl", true)) return false;
  30. diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp
  31. index fe4bd9811949..ef693e283968 100644
  32. --- a/gfx/gl/GLLibraryEGL.cpp
  33. +++ b/gfx/gl/GLLibraryEGL.cpp
  34. @@ -63,9 +63,18 @@ static const char* sEGLExtensionNames[] = {
  35. "EGL_ANGLE_device_creation_d3d11",
  36. };
  37. -#if defined(ANDROID)
  38. +PRLibrary* LoadApitraceLibrary() {
  39. + const char* path = nullptr;
  40. +
  41. +#ifdef ANDROID
  42. + // We only need to explicitly dlopen egltrace
  43. + // on android as we can use LD_PRELOAD or other tricks
  44. + // on other platforms. We look for it in /data/local
  45. + // as that's writeable by all users.
  46. + path = "/data/local/tmp/egltrace.so";
  47. +#endif
  48. + if (!path) return nullptr;
  49. -static PRLibrary* LoadApitraceLibrary() {
  50. // Initialization of gfx prefs here is only needed during the unit tests...
  51. gfxPrefs::GetSingleton();
  52. if (!gfxPrefs::UseApitrace()) {
  53. @@ -73,7 +82,6 @@ static PRLibrary* LoadApitraceLibrary() {
  54. }
  55. static PRLibrary* sApitraceLibrary = nullptr;
  56. -
  57. if (sApitraceLibrary) return sApitraceLibrary;
  58. nsAutoCString logFile;
  59. @@ -87,20 +95,19 @@ static PRLibrary* LoadApitraceLibrary() {
  60. nsAutoCString logPath;
  61. logPath.AppendPrintf("%s/%s", getenv("GRE_HOME"), logFile.get());
  62. +#ifndef XP_WIN // Windows is missing setenv and forbids PR_LoadLibrary.
  63. // apitrace uses the TRACE_FILE environment variable to determine where
  64. // to log trace output to
  65. printf_stderr("Logging GL tracing output to %s", logPath.get());
  66. setenv("TRACE_FILE", logPath.get(), false);
  67. - printf_stderr("Attempting load of %s\n", APITRACE_LIB);
  68. -
  69. - sApitraceLibrary = PR_LoadLibrary(APITRACE_LIB);
  70. + printf_stderr("Attempting load of %s\n", path);
  71. + sApitraceLibrary = PR_LoadLibrary(path);
  72. +#endif
  73. return sApitraceLibrary;
  74. }
  75. -#endif // ANDROID
  76. -
  77. #ifdef XP_WIN
  78. // see the comment in GLLibraryEGL::EnsureInitialized() for the rationale here.
  79. static PRLibrary* LoadLibraryForEGLOnWindows(const nsAString& filename) {
  80. diff --git a/gfx/gl/GLLibraryEGL.h b/gfx/gl/GLLibraryEGL.h
  81. index 069a2f0908d7..3f200bf76b3f 100644
  82. --- a/gfx/gl/GLLibraryEGL.h
  83. +++ b/gfx/gl/GLLibraryEGL.h
  84. @@ -18,18 +18,6 @@
  85. #include <bitset>
  86. #include <vector>
  87. -#ifdef ANDROID
  88. -// We only need to explicitly dlopen egltrace
  89. -// on android as we can use LD_PRELOAD or other tricks
  90. -// on other platforms. We look for it in /data/local
  91. -// as that's writeable by all users
  92. -//
  93. -// This should really go in GLLibraryEGL.cpp but we currently reference
  94. -// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
  95. -// will come in subsequent patches on Bug 732865
  96. -#define APITRACE_LIB "/data/local/tmp/egltrace.so"
  97. -#endif
  98. -
  99. #if defined(MOZ_X11)
  100. #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)mozilla::DefaultXDisplay())
  101. #else
  102. @@ -49,6 +37,7 @@ class DataSourceSurface;
  103. namespace gl {
  104. class GLContext;
  105. +PRLibrary* LoadApitraceLibrary();
  106. void BeforeEGLCall(const char* funcName);
  107. void AfterEGLCall(const char* funcName);
  108. diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h
  109. index b2e094672b59..fae5bec1e78e 100644
  110. --- a/gfx/thebes/gfxPrefs.h
  111. +++ b/gfx/thebes/gfxPrefs.h
  112. @@ -433,9 +433,7 @@ class gfxPrefs final {
  113. SmoothScrollMSDPhysicsRegularSpringConstant, int32_t, 1000);
  114. DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false);
  115. -#if defined(ANDROID)
  116. DECL_GFX_PREF(Once, "gfx.apitrace.enabled", UseApitrace, bool, false);
  117. -#endif
  118. #if defined(RELEASE_OR_BETA)
  119. // "Skip" means this is locked to the default value in beta and release.
  120. DECL_GFX_PREF(Skip, "gfx.blocklist.all", BlocklistAll, int32_t, 0);
  121. --
  122. 2.20.1