gfxEnv.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. * This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef GFX_ENV_H
  6. #define GFX_ENV_H
  7. #include "prenv.h"
  8. // To register the check for an environment variable existence (and not empty),
  9. // add a line in this file using the DECL_GFX_ENV macro.
  10. //
  11. // For example this line in the .h:
  12. // DECL_GFX_ENV("MOZ_DISABLE_CONTEXT_SHARING_GLX",DisableContextSharingGLX);
  13. // means that you can call
  14. // bool var = gfxEnv::DisableContextSharingGLX();
  15. // and that the value will be checked only once, first time we call it, then cached.
  16. #define DECL_GFX_ENV(Env, Name) \
  17. static bool Name() { \
  18. static bool isSet = IsEnvSet(Env);\
  19. return isSet; \
  20. }
  21. class gfxEnv final
  22. {
  23. public:
  24. // This is where DECL_GFX_ENV for each of the environment variables should go.
  25. // We will keep these in an alphabetical order by the environment variable,
  26. // to make it easier to see if a method accessing an entry already exists.
  27. // Just insert yours in the list.
  28. // Debugging inside of ContainerLayerComposite
  29. DECL_GFX_ENV("DUMP_DEBUG", DumpDebug);
  30. // OpenGL shader debugging in OGLShaderProgram, in DEBUG only
  31. DECL_GFX_ENV("MOZ_DEBUG_SHADERS", DebugShaders);
  32. // Disabling context sharing in GLContextProviderGLX
  33. DECL_GFX_ENV("MOZ_DISABLE_CONTEXT_SHARING_GLX", DisableContextSharingGlx);
  34. // Disabling the crash guard in DriverCrashGuard
  35. DECL_GFX_ENV("MOZ_DISABLE_CRASH_GUARD", DisableCrashGuard);
  36. DECL_GFX_ENV("MOZ_FORCE_CRASH_GUARD_NIGHTLY", ForceCrashGuardNightly);
  37. // We force present to work around some Windows bugs - disable that if this
  38. // environment variable is set.
  39. DECL_GFX_ENV("MOZ_DISABLE_FORCE_PRESENT", DisableForcePresent);
  40. // Together with paint dumping, only when MOZ_DUMP_PAINTING is defined.
  41. // Dumping compositor textures is broken pretty badly. For example,
  42. // on Linux it crashes TextureHost::GetAsSurface() returns null.
  43. // Expect to have to fix things like this if you turn it on.
  44. // Meanwhile, content-side texture dumping
  45. // (conditioned on DebugDumpPainting()) is a good replacement.
  46. DECL_GFX_ENV("MOZ_DUMP_COMPOSITOR_TEXTURES", DumpCompositorTextures);
  47. // Dumping the layer list in LayerSorter
  48. DECL_GFX_ENV("MOZ_DUMP_LAYER_SORT_LIST", DumpLayerSortList);
  49. // Paint dumping, only when MOZ_DUMP_PAINTING is defined.
  50. DECL_GFX_ENV("MOZ_DUMP_PAINT", DumpPaint);
  51. DECL_GFX_ENV("MOZ_DUMP_PAINT_INTERMEDIATE", DumpPaintIntermediate);
  52. DECL_GFX_ENV("MOZ_DUMP_PAINT_ITEMS", DumpPaintItems);
  53. DECL_GFX_ENV("MOZ_DUMP_PAINT_TO_FILE", DumpPaintToFile);
  54. // Force double buffering in ContentClient
  55. DECL_GFX_ENV("MOZ_FORCE_DOUBLE_BUFFERING", ForceDoubleBuffering);
  56. // Force gfxDevCrash to use MOZ_CRASH in Beta and Release
  57. DECL_GFX_ENV("MOZ_GFX_CRASH_MOZ_CRASH", GfxDevCrashMozCrash);
  58. // Force gfxDevCrash to use telemetry in Nightly and Aurora
  59. DECL_GFX_ENV("MOZ_GFX_CRASH_TELEMETRY", GfxDevCrashTelemetry);
  60. DECL_GFX_ENV("MOZ_GFX_VR_NO_DISTORTION", VRNoDistortion);
  61. // Debugging in GLContext
  62. DECL_GFX_ENV("MOZ_GL_DEBUG", GlDebug);
  63. DECL_GFX_ENV("MOZ_GL_DEBUG_VERBOSE", GlDebugVerbose);
  64. DECL_GFX_ENV("MOZ_GL_DEBUG_ABORT_ON_ERROR", GlDebugAbortOnError);
  65. // Count GL extensions
  66. DECL_GFX_ENV("MOZ_GL_DUMP_EXTS", GlDumpExtensions);
  67. // Very noisy GLContext and GLContextProviderELG
  68. DECL_GFX_ENV("MOZ_GL_SPEW", GlSpew);
  69. // Do extra work before and after each GLX call in GLContextProviderGLX
  70. DECL_GFX_ENV("MOZ_GLX_DEBUG", GlxDebug);
  71. // Use X compositing
  72. DECL_GFX_ENV("MOZ_LAYERS_ENABLE_XLIB_SURFACES", LayersEnableXlibSurfaces);
  73. // GL compositing on Windows
  74. DECL_GFX_ENV("MOZ_LAYERS_PREFER_EGL", LayersPreferEGL);
  75. // Offscreen GL context for main layer manager
  76. DECL_GFX_ENV("MOZ_LAYERS_PREFER_OFFSCREEN", LayersPreferOffscreen);
  77. // Stop the VR rendering
  78. DECL_GFX_ENV("NO_VR_RENDERING", NoVRRendering);
  79. // WARNING:
  80. // Please make sure that you've added your new envvar to the list above in
  81. // alphabetical order. Please do not just append it to the end of the list.
  82. private:
  83. // Helper function, can be re-used in the other macros
  84. static bool IsEnvSet(const char* aName) {
  85. const char* val = PR_GetEnv(aName);
  86. return (val != 0 && *val != '\0');
  87. }
  88. gfxEnv() {};
  89. ~gfxEnv() {};
  90. gfxEnv(const gfxEnv&) = delete;
  91. gfxEnv& operator=(const gfxEnv&) = delete;
  92. };
  93. #undef DECL_GFX_ENV
  94. #endif /* GFX_ENV_H */