Bug 1214802 - gfxEnv - consolidate environment variables used by the graphics code in one place. r=botond

This commit is contained in:
Milan Sreckovic 2015-10-28 14:31:00 +01:00
parent e35fedeed5
commit 74f8f7a12b
20 changed files with 189 additions and 92 deletions

View File

@ -17,6 +17,7 @@
#include "GLScreenBuffer.h"
#include "gfxCrashReporterUtils.h"
#include "gfxEnv.h"
#include "gfxUtils.h"
#include "GLContextProvider.h"
#include "GLTextureImage.h"
@ -637,16 +638,16 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
#ifdef MOZ_GL_DEBUG
if (PR_GetEnv("MOZ_GL_DEBUG"))
if (gfxEnv::GlDebug())
sDebugMode |= DebugEnabled;
// enables extra verbose output, informing of the start and finish of every GL call.
// useful e.g. to record information to investigate graphics system crashes/lockups
if (PR_GetEnv("MOZ_GL_DEBUG_VERBOSE"))
if (gfxEnv::GlDebugVerbose())
sDebugMode |= DebugTrace;
// aborts on GL error. Can be useful to debug quicker code that is known not to generate any GL error in principle.
if (PR_GetEnv("MOZ_GL_DEBUG_ABORT_ON_ERROR"))
if (gfxEnv::GlDebugAbortOnError())
sDebugMode |= DebugAbortOnError;
#endif
@ -2582,8 +2583,7 @@ GLContext::FlushIfHeavyGLCallsSinceLastFlush()
/*static*/ bool
GLContext::ShouldDumpExts()
{
static bool ret = PR_GetEnv("MOZ_GL_DUMP_EXTS");
return ret;
return gfxEnv::GlDumpExtensions();
}
bool
@ -2613,8 +2613,7 @@ DoesStringMatch(const char* aString, const char *aWantedString)
/*static*/ bool
GLContext::ShouldSpew()
{
static bool ret = PR_GetEnv("MOZ_GL_SPEW");
return ret;
return gfxEnv::GlSpew();
}
void

View File

@ -26,6 +26,7 @@
#include "GLXLibrary.h"
#include "gfxXlibSurface.h"
#include "gfxContext.h"
#include "gfxEnv.h"
#include "gfxPlatform.h"
#include "GLContextGLX.h"
#include "gfxUtils.h"
@ -98,7 +99,7 @@ GLXLibrary::EnsureInitialized()
reporter.SetSuccessful();
}
if (PR_GetEnv("MOZ_GLX_DEBUG")) {
if (gfxEnv::GlxDebug()) {
mDebug = true;
}
@ -1283,16 +1284,8 @@ GLContextProviderGLX::CreateOffscreen(const IntSize& size,
/*static*/ GLContext*
GLContextProviderGLX::GetGlobalContext()
{
static bool checkedContextSharing = false;
static bool useContextSharing = false;
if (!checkedContextSharing) {
useContextSharing = getenv("MOZ_DISABLE_CONTEXT_SHARING_GLX") == 0;
checkedContextSharing = true;
}
// TODO: get GLX context sharing to work well with multiple threads
if (!useContextSharing) {
if (gfxEnv::DisableContextSharingGlx()) {
return nullptr;
}

View File

@ -10,6 +10,7 @@
#include <stdlib.h> // for getenv
#include "DirectedGraph.h" // for DirectedGraph
#include "Layers.h" // for Layer
#include "gfxEnv.h" // for gfxEnv
#include "gfxLineSegment.h" // for gfxLineSegment
#include "gfxPoint.h" // for gfxPoint
#include "gfxQuad.h" // for gfxQuad
@ -152,8 +153,6 @@ static LayerSortOrder CompareDepth(Layer* aOne, Layer* aTwo) {
}
#ifdef DEBUG
static bool gDumpLayerSortList = getenv("MOZ_DUMP_LAYER_SORT_LIST") != 0;
// #define USE_XTERM_COLORING
#ifdef USE_XTERM_COLORING
// List of color values, which can be added to the xterm foreground offset or
@ -251,7 +250,7 @@ void SortLayersBy3DZOrder(nsTArray<Layer*>& aLayers)
DirectedGraph<Layer*> graph;
#ifdef DEBUG
if (gDumpLayerSortList) {
if (gfxEnv::DumpLayerSortList()) {
for (uint32_t i = 0; i < nodeCount; i++) {
if (aLayers.ElementAt(i)->GetDebugColorIndex() == 0) {
aLayers.ElementAt(i)->SetDebugColorIndex(gColorIndex++);
@ -280,7 +279,7 @@ void SortLayersBy3DZOrder(nsTArray<Layer*>& aLayers)
}
#ifdef DEBUG
if (gDumpLayerSortList) {
if (gfxEnv::DumpLayerSortList()) {
fprintf(stderr, " --- Edge List: --- \n");
DumpEdgeList(graph);
}
@ -347,7 +346,7 @@ void SortLayersBy3DZOrder(nsTArray<Layer*>& aLayers)
} while (!noIncoming.IsEmpty());
NS_ASSERTION(!graph.GetEdgeCount(), "Cycles detected!");
#ifdef DEBUG
if (gDumpLayerSortList) {
if (gfxEnv::DumpLayerSortList()) {
fprintf(stderr, " --- Layers after sorting: --- \n");
DumpLayerList(sortedList);
}

View File

@ -15,6 +15,7 @@
#include "LayersLogging.h" // for AppendToString
#include "ReadbackLayer.h" // for ReadbackLayer
#include "UnitTransforms.h" // for ViewAs
#include "gfxEnv.h"
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h"
#include "gfxUtils.h" // for gfxUtils, etc
@ -1362,7 +1363,7 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const Matrix4x4& aTransformToS
GetForceIsolatedGroup()) {
useIntermediateSurface = true;
#ifdef MOZ_DUMP_PAINTING
} else if (gfxUtils::sDumpPaintingIntermediate && !Extend3DContext()) {
} else if (gfxEnv::DumpPaintIntermediate() && !Extend3DContext()) {
useIntermediateSurface = true;
#endif
} else {
@ -1685,9 +1686,9 @@ void
Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
{
#ifdef MOZ_DUMP_PAINTING
bool dumpCompositorTexture = gfxUtils::sDumpCompositorTextures && AsLayerComposite() &&
bool dumpCompositorTexture = gfxEnv::DumpCompositorTextures() && AsLayerComposite() &&
AsLayerComposite()->GetCompositableHost();
bool dumpClientTexture = gfxUtils::sDumpPainting && AsShadowableLayer() &&
bool dumpClientTexture = gfxEnv::DumpPaint() && AsShadowableLayer() &&
AsShadowableLayer()->GetCompositableClient();
nsCString layerId(Name());
layerId.Append('-');

View File

@ -7,6 +7,7 @@
#include "BasicLayers.h" // for BasicLayerManager
#include "gfxContext.h" // for gfxContext, etc
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxEnv.h" // for gfxEnv
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxPoint.h" // for IntSize, gfxPoint
#include "gfxTeeSurface.h" // for gfxTeeSurface
@ -26,7 +27,6 @@
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
#include "nsISupportsImpl.h" // for gfxContext::Release, etc
#include "nsIWidget.h" // for nsIWidget
#include "prenv.h" // for PR_GetEnv
#include "nsLayoutUtils.h"
#ifdef XP_WIN
#include "gfxWindowsPlatform.h"
@ -88,7 +88,7 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
backend == LayersBackend::LAYERS_BASIC;
}
if (useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) {
if (useDoubleBuffering || gfxEnv::ForceDoubleBuffering()) {
return MakeAndAddRef<ContentClientDoubleBuffered>(aForwarder);
}
return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);

View File

@ -6,7 +6,7 @@
#include "CanvasLayerComposite.h"
#include "composite/CompositableHost.h" // for CompositableHost
#include "gfx2DGlue.h" // for ToFilter
#include "gfxUtils.h" // for gfxUtils, etc
#include "gfxEnv.h" // for gfxEnv, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for Point
#include "mozilla/gfx/Rect.h" // for Rect
@ -88,7 +88,7 @@ CanvasLayerComposite::RenderLayer(const IntRect& aClipRect)
mCompositor->MakeCurrent();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpCompositorTextures) {
if (gfxEnv::DumpCompositorTextures()) {
RefPtr<gfx::DataSourceSurface> surf = mCompositableHost->GetAsSurface();
WriteSnapshotToDumpFile(this, surf);
}

View File

@ -8,8 +8,8 @@
#include "apz/src/AsyncPanZoomController.h" // for AsyncPanZoomController
#include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for LayerRect, LayerPixel, etc
#include "gfxEnv.h" // for gfxEnv
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/UniquePtr.h" // for UniquePtr
@ -40,7 +40,7 @@
#define CULLING_LOG(...)
// #define CULLING_LOG(...) printf_stderr("CULLING: " __VA_ARGS__)
#define DUMP(...) do { if (getenv("DUMP_DEBUG")) { printf_stderr(__VA_ARGS__); } } while(0)
#define DUMP(...) do { if (gfxEnv::DumpDebug()) { printf_stderr(__VA_ARGS__); } } while(0)
#define XYWH(k) (k).x, (k).y, (k).width, (k).height
#define XY(k) (k).x, (k).y
#define WH(k) (k).width, (k).height
@ -163,7 +163,7 @@ ContainerRenderVR(ContainerT* aContainer,
surfaceRect.height = std::min(maxTextureSize, surfaceRect.height);
gfx::VRHMDRenderingSupport *vrRendering = aHMD->GetRenderingSupport();
if (PR_GetEnv("NO_VR_RENDERING")) vrRendering = nullptr;
if (gfxEnv::NoVRRendering()) vrRendering = nullptr;
if (vrRendering) {
if (!aContainer->mVRRenderTargetSet || aContainer->mVRRenderTargetSet->size != surfaceRect.Size()) {
aContainer->mVRRenderTargetSet = vrRendering->CreateRenderTargetSet(compositor, surfaceRect.Size());
@ -297,7 +297,7 @@ ContainerRenderVR(ContainerT* aContainer,
// draw the temporary surface with VR distortion to the original destination
EffectChain vrEffect(aContainer);
bool skipDistortion = vrRendering || PR_GetEnv("MOZ_GFX_VR_NO_DISTORTION");
bool skipDistortion = vrRendering || gfxEnv::VRNoDistortion();
if (skipDistortion) {
vrEffect.mPrimaryEffect = new EffectRenderTarget(surface);
} else {
@ -708,7 +708,7 @@ ContainerRender(ContainerT* aContainer,
gfx::Rect visibleRect(aContainer->GetEffectiveVisibleRegion().GetBounds());
RefPtr<Compositor> compositor = aManager->GetCompositor();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpCompositorTextures) {
if (gfxEnv::DumpCompositorTextures()) {
RefPtr<gfx::DataSourceSurface> surf = surface->Dump(compositor);
if (surf) {
WriteSnapshotToDumpFile(aContainer, surf);

View File

@ -7,8 +7,8 @@
#include "CompositableHost.h" // for CompositableHost
#include "Layers.h" // for WriteSnapshotToDumpFile, etc
#include "gfx2DGlue.h" // for ToFilter
#include "gfxEnv.h" // for gfxEnv
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for IntSize, Point
@ -87,7 +87,7 @@ ImageLayerComposite::RenderLayer(const IntRect& aClipRect)
}
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpCompositorTextures) {
if (gfxEnv::DumpCompositorTextures()) {
RefPtr<gfx::DataSourceSurface> surf = mImageHost->GetAsSurface();
WriteSnapshotToDumpFile(this, surf);
}

View File

@ -7,7 +7,7 @@
#include "CompositableHost.h" // for TiledLayerProperties, etc
#include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for CSSRect, LayerPixel, etc
#include "gfxUtils.h" // for gfxUtils, etc
#include "gfxEnv.h" // for gfxEnv
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for Point
@ -115,7 +115,7 @@ PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpCompositorTextures) {
if (gfxEnv::DumpCompositorTextures()) {
RefPtr<gfx::DataSourceSurface> surf = mBuffer->GetAsSurface();
if (surf) {
WriteSnapshotToDumpFile(this, surf);

View File

@ -25,10 +25,10 @@
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder, etc
#include "mozilla/mozalloc.h" // for operator new
#include "gfxEnv.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_ERROR
#include "prenv.h" // for PR_GetEnv
using namespace mozilla::gl;
@ -45,7 +45,7 @@ namespace layers {
static bool
UsingXCompositing()
{
if (!PR_GetEnv("MOZ_LAYERS_ENABLE_XLIB_SURFACES")) {
if (!gfxEnv::LayersEnableXlibSurfaces()) {
return false;
}
return (gfxSurfaceType::Xlib ==

View File

@ -13,10 +13,11 @@
#include "Layers.h" // for WriteSnapshotToDumpFile
#include "LayerScope.h" // for LayerScope
#include "gfxCrashReporterUtils.h" // for ScopedGfxFeatureReporter
#include "gfxEnv.h" // for gfxEnv
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for NextPowerOfTwo, gfxUtils, etc
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/ArrayUtils.h" // for ArrayLength
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/gfx/BasePoint.h" // for BasePoint
@ -104,14 +105,14 @@ CompositorOGL::CreateContext()
}
#ifdef XP_WIN
if (PR_GetEnv("MOZ_LAYERS_PREFER_EGL")) {
if (gfxEnv::LayersPreferEGL()) {
printf_stderr("Trying GL layers...\n");
context = gl::GLContextProviderEGL::CreateForWindow(mWidget);
}
#endif
// Allow to create offscreen GL context for main Layer Manager
if (!context && PR_GetEnv("MOZ_LAYERS_PREFER_OFFSCREEN")) {
if (!context && gfxEnv::LayersPreferOffscreen()) {
SurfaceCaps caps = SurfaceCaps::ForRGB();
caps.preserve = false;
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == gfxImageFormat::RGB16_565;
@ -1388,7 +1389,7 @@ CompositorOGL::EndFrame()
MOZ_ASSERT(mCurrentRenderTarget == mWindowRenderTarget, "Rendering target not properly restored");
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpCompositorTextures) {
if (gfxEnv::DumpCompositorTextures()) {
IntRect rect;
if (mUseExternalSurfaceSize) {
rect = IntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height);

View File

@ -5,12 +5,12 @@
#include "OGLShaderProgram.h"
#include <stdint.h> // for uint32_t
#include <sstream> // for ostringstream
#include "gfxEnv.h"
#include "gfxRect.h" // for gfxRect
#include "mozilla/DebugOnly.h" // for DebugOnly
#include "nsAString.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsString.h" // for nsAutoCString
#include "prenv.h" // for PR_GetEnv
#include "Layers.h"
#include "GLContext.h"
@ -577,7 +577,7 @@ ShaderProgramOGL::CreateShader(GLenum aShaderType, const char *aShaderSource)
*/
if (!success
#ifdef DEBUG
|| (len > 10 && PR_GetEnv("MOZ_DEBUG_SHADERS"))
|| (len > 10 && gfxEnv::DebugShaders())
#endif
)
{
@ -630,7 +630,7 @@ ShaderProgramOGL::CreateProgram(const char *aVertexShaderString,
*/
if (!success
#ifdef DEBUG
|| (len > 10 && PR_GetEnv("MOZ_DEBUG_SHADERS"))
|| (len > 10 && gfxEnv::DebugShaders())
#endif
)
{

View File

@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DriverCrashGuard.h"
#include "gfxEnv.h"
#include "gfxPrefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
@ -71,8 +72,7 @@ DriverCrashGuard::Initialize()
}
// Check to see if all guards have been disabled through the environment.
static bool sAllGuardsDisabled = !!PR_GetEnv("MOZ_DISABLE_CRASH_GUARD");
if (sAllGuardsDisabled) {
if (gfxEnv::DisableCrashGuard()) {
return;
}

124
gfx/thebes/gfxEnv.h Normal file
View File

@ -0,0 +1,124 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_ENV_H
#define GFX_ENV_H
#include "prenv.h"
// To register the check for an environment variable existence (and not empty),
// add a line in this file using the DECL_GFX_ENV macro.
//
// For example this line in the .h:
// DECL_GFX_ENV_ONCE("MOZ_DISABLE_CONTEXT_SHARING_GLX",DisableContextSharingGLX);
// means that you can call
// bool var = gfxEnv::DisableContextSharingGLX();
// and that the value will be checked only once, first time we call it, then cached.
#define DECL_GFX_ENV_LIVE(Env, Name) \
static bool Name() { \
return IsEnvSet(Env); \
}
#define DECL_GFX_ENV_ONCE(Env, Name) \
static bool Name() { \
static bool isSet = IsEnvSet(Env);\
return isSet; \
}
class gfxEnv final
{
public:
// This is where DECL_GFX_ENV for each of the environment variables should go.
// We will keep these in an alphabetical order by the environment variable,
// to make it easier to see if a method accessing an entry already exists.
// Just insert yours in the list.
// Debugging inside of ContainerLayerComposite
DECL_GFX_ENV_LIVE("DUMP_DEBUG", DumpDebug);
// OpenGL shader debugging in OGLShaderProgram, in DEBUG only
DECL_GFX_ENV_LIVE("MOZ_DEBUG_SHADERS", DebugShaders);
// Disabling context sharing in GLContextProviderGLX
DECL_GFX_ENV_ONCE("MOZ_DISABLE_CONTEXT_SHARING_GLX", DisableContextSharingGlx);
// Disabling the crash guard in DriverCrashGuard
DECL_GFX_ENV_ONCE("MOZ_DISABLE_CRASH_GUARD", DisableCrashGuard);
// Together with paint dumping, only when MOZ_DUMP_PAINTING is defined.
// Dumping compositor textures is broken pretty badly. For example,
// on Linux it crashes TextureHost::GetAsSurface() returns null.
// Expect to have to fix things like this if you turn it on.
// Meanwhile, content-side texture dumping
// (conditioned on DebugDumpPainting()) is a good replacement.
DECL_GFX_ENV_ONCE("MOZ_DUMP_COMPOSITOR_TEXTURES", DumpCompositorTextures);
// Dumping the layer list in LayerSorter
DECL_GFX_ENV_ONCE("MOZ_DUMP_LAYER_SORT_LIST", DumpLayerSortList);
// Paint dumping, only when MOZ_DUMP_PAINTING is defined.
DECL_GFX_ENV_ONCE("MOZ_DUMP_PAINT", DumpPaint);
DECL_GFX_ENV_ONCE("MOZ_DUMP_PAINT_INTERMEDIATE", DumpPaintIntermediate);
DECL_GFX_ENV_ONCE("MOZ_DUMP_PAINT_ITEMS", DumpPaintItems);
DECL_GFX_ENV_ONCE("MOZ_DUMP_PAINT_TO_FILE", DumpPaintToFile);
// Force double buffering in ContentClient
DECL_GFX_ENV_LIVE("MOZ_FORCE_DOUBLE_BUFFERING", ForceDoubleBuffering);
// Force gfxCrash to use MOZ_CRASH in Beta and Release
DECL_GFX_ENV_ONCE("MOZ_GFX_CRASH_MOZ_CRASH", GfxCrashMozCrash);
// Force gfxCrash to use telemetry in Nightly and Aurora
DECL_GFX_ENV_ONCE("MOZ_GFX_CRASH_TELEMETRY", GfxCrashTelemetry);
DECL_GFX_ENV_LIVE("MOZ_GFX_VR_NO_DISTORTION", VRNoDistortion);
// Debugging in GLContext
DECL_GFX_ENV_LIVE("MOZ_GL_DEBUG", GlDebug);
DECL_GFX_ENV_LIVE("MOZ_GL_DEBUG_VERBOSE", GlDebugVerbose);
DECL_GFX_ENV_LIVE("MOZ_GL_DEBUG_ABORT_ON_ERROR", GlDebugAbortOnError);
// Count GL extensions
DECL_GFX_ENV_ONCE("MOZ_GL_DUMP_EXTS", GlDumpExtensions);
// Very noisy GLContext and GLContextProviderELG
DECL_GFX_ENV_ONCE("MOZ_GL_SPEW", GlSpew);
// Do extra work before and after each GLX call in GLContextProviderGLX
DECL_GFX_ENV_LIVE("MOZ_GLX_DEBUG", GlxDebug);
// Use X compositing
DECL_GFX_ENV_LIVE("MOZ_LAYERS_ENABLE_XLIB_SURFACES", LayersEnableXlibSurfaces);
// GL compositing on Windows
DECL_GFX_ENV_LIVE("MOZ_LAYERS_PREFER_EGL", LayersPreferEGL);
// Offscreen GL context for main layer manager
DECL_GFX_ENV_LIVE("MOZ_LAYERS_PREFER_OFFSCREEN", LayersPreferOffscreen);
// Stop the VR rendering
DECL_GFX_ENV_LIVE("NO_VR_RENDERING", NoVRRendering);
// WARNING:
// Please make sure that you've added your new envvar to the list above in
// alphabetical order. Please do not just append it to the end of the list.
private:
// Helper function, can be re-used in the other macros
static bool IsEnvSet(const char* aName) {
char* val = PR_GetEnv(aName);
return (val != 0 && *val != '\0');
}
gfxEnv() {};
~gfxEnv() {};
gfxEnv(const gfxEnv&) = delete;
gfxEnv& operator=(const gfxEnv&) = delete;
};
#undef DECL_GFX_ENV_LIVE
#undef DECL_GFX_ENV_ONCE
#endif /* GFX_ENV_H */

View File

@ -17,6 +17,7 @@
#include "gfxPlatform.h"
#include "gfxPrefs.h"
#include "gfxEnv.h"
#include "gfxTextRun.h"
#include "gfxVR.h"
@ -310,12 +311,11 @@ CrashStatsLogForwarder::CrashAction(LogReason aReason)
#ifndef RELEASE_BUILD
// Non-release builds crash by default, but will use telemetry
// if this environment variable is present.
static bool useTelemetry = getenv("MOZ_GFX_CRASH_TELEMETRY") != 0;
static bool useTelemetry = gfxEnv::GfxCrashTelemetry();
#else
// Release builds use telemetry bu default, but will crash
// if this environment variable is present. Double negative
// to make the intent clear.
static bool useTelemetry = !(getenv("MOZ_GFX_CRASH_MOZ_CRASH") != 0);
// Release builds use telemetry by default, but will crash instead
// if this environment variable is present.
static bool useTelemetry = !gfxEnv::GfxCrashMozCrash();
#endif
if (useTelemetry) {

View File

@ -7,6 +7,7 @@
#include "cairo.h"
#include "gfxContext.h"
#include "gfxEnv.h"
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxDrawable.h"
@ -1670,20 +1671,6 @@ gfxUtils::DumpDisplayList() {
FILE *gfxUtils::sDumpPaintFile = stderr;
#ifdef MOZ_DUMP_PAINTING
bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0;
bool gfxUtils::sDumpPaintingIntermediate = getenv("MOZ_DUMP_PAINT_INTERMEDIATE") != 0;
bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0;
bool gfxUtils::sDumpPaintItems = getenv("MOZ_DUMP_PAINT_ITEMS") != 0;
bool gfxUtils::sDumpCompositorTextures = getenv("MOZ_DUMP_COMPOSITOR_TEXTURES") != 0;
#else
bool gfxUtils::sDumpPainting = false;
bool gfxUtils::sDumpPaintingIntermediate = false;
bool gfxUtils::sDumpPaintingToFile = false;
bool gfxUtils::sDumpPaintItems = false;
bool gfxUtils::sDumpCompositorTextures = false;
#endif
namespace mozilla {
namespace gfx {

View File

@ -305,16 +305,6 @@ public:
static bool DumpDisplayList();
static bool sDumpPainting;
static bool sDumpPaintingIntermediate;
static bool sDumpPaintingToFile;
static bool sDumpPaintItems;
// TODO: Dumping compositor textures is broken pretty badly. For example,
// on Linux it crashes because TextureHost::GetAsSurface() returns
// null. Expect to have to fix things like this if you turn it on.
// Meanwhile, content-side texture dumping (conditioned on
// sDumpPainting) is a good replacement.
static bool sDumpCompositorTextures;
static FILE* sDumpPaintFile;
};

View File

@ -15,6 +15,7 @@ EXPORTS += [
'gfxColor.h',
'gfxContext.h',
'gfxDrawable.h',
'gfxEnv.h',
'gfxFailure.h',
'gfxFont.h',
'gfxFontConstants.h',

View File

@ -22,6 +22,7 @@
#include "UnitTransforms.h"
#include "Units.h"
#include "gfx2DGlue.h"
#include "gfxEnv.h"
#include "gfxUtils.h"
#include "nsDisplayList.h"
#include "nsDocShell.h"
@ -3653,7 +3654,7 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
aItem->GetVisibleRect().ToOutsidePixels(appUnitsPerDevPixel);
RefPtr<DrawTarget> tempDT;
if (gfxUtils::sDumpPainting) {
if (gfxEnv::DumpPaint()) {
tempDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
itemVisibleRect.Size(),
SurfaceFormat::B8G8R8A8);
@ -3683,7 +3684,7 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
basic->SetTarget(nullptr);
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting && tempDT) {
if (gfxEnv::DumpPaint() && tempDT) {
RefPtr<SourceSurface> surface = tempDT->Snapshot();
DumpPaintedImage(aItem, surface);
@ -4503,10 +4504,10 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
tempManager->AbortTransaction();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::DumpDisplayList() || gfxUtils::sDumpPainting) {
if (gfxUtils::DumpDisplayList() || gfxEnv::DumpPaint()) {
fprintf_stderr(gfxUtils::sDumpPaintFile, "Basic layer tree for painting contents of display item %s(%p):\n", aItem->Name(), aItem->Frame());
std::stringstream stream;
tempManager->Dump(stream, "", gfxUtils::sDumpPaintingToFile);
tempManager->Dump(stream, "", gfxEnv::DumpPaintToFile());
fprint_stderr(gfxUtils::sDumpPaintFile, stream); // not a typo, fprint_stderr declared in LayersLogging.h
}
#endif
@ -5719,7 +5720,7 @@ FrameLayerBuilder::PaintItems(nsTArray<ClippedDisplayItem>& aItems,
nsIFrame* frame = cdi->mItem->Frame();
frame->AddStateBits(NS_FRAME_PAINTED_THEBES);
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintItems) {
if (gfxEnv::DumpPaintItems()) {
DebugPaintItem(aDrawTarget, aPresContext, cdi->mItem, aBuilder);
} else {
#else

View File

@ -73,6 +73,7 @@
#include "mozilla/dom/Element.h"
#include "nsCanvasFrame.h"
#include "gfxDrawable.h"
#include "gfxEnv.h"
#include "gfxUtils.h"
#include "nsDataHashtable.h"
#include "nsTextFrame.h"
@ -3299,7 +3300,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
startBuildDisplayList);
bool profilerNeedsDisplayList = profiler_feature_active("displaylistdump");
bool consoleNeedsDisplayList = gfxUtils::DumpDisplayList() || gfxUtils::sDumpPainting;
bool consoleNeedsDisplayList = gfxUtils::DumpDisplayList() || gfxEnv::DumpPaint();
#ifdef MOZ_DUMP_PAINTING
FILE* savedDumpFile = gfxUtils::sDumpPaintFile;
#endif
@ -3308,7 +3309,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
if (consoleNeedsDisplayList || profilerNeedsDisplayList) {
ss = MakeUnique<std::stringstream>();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintingToFile) {
if (gfxEnv::DumpPaintToFile()) {
nsCString string("dump-");
// Include the process ID in the dump file name, to make sure that in an
// e10s setup different processes don't clobber each other's dump files.
@ -3322,7 +3323,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
} else {
gfxUtils::sDumpPaintFile = stderr;
}
if (gfxUtils::sDumpPaintingToFile) {
if (gfxEnv::DumpPaintToFile()) {
*ss << "<html><head><script>\n"
"var array = {};\n"
"function ViewImage(index) { \n"
@ -3337,9 +3338,9 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
#endif
*ss << nsPrintfCString("Painting --- before optimization (dirty %d,%d,%d,%d):\n",
dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height).get();
nsFrame::PrintDisplayList(&builder, list, *ss, gfxUtils::sDumpPaintingToFile);
nsFrame::PrintDisplayList(&builder, list, *ss, gfxEnv::DumpPaintToFile());
if (gfxUtils::sDumpPainting || gfxUtils::sDumpPaintItems) {
if (gfxEnv::DumpPaint() || gfxEnv::DumpPaintItems()) {
// Flush stream now to avoid reordering dump output relative to
// messages dumped by PaintRoot below.
if (profilerNeedsDisplayList && !consoleNeedsDisplayList) {
@ -3382,12 +3383,12 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
if (consoleNeedsDisplayList || profilerNeedsDisplayList) {
*ss << "Painting --- after optimization:\n";
nsFrame::PrintDisplayList(&builder, list, *ss, gfxUtils::sDumpPaintingToFile);
nsFrame::PrintDisplayList(&builder, list, *ss, gfxEnv::DumpPaintToFile());
*ss << "Painting --- layer tree:\n";
if (layerManager) {
FrameLayerBuilder::DumpRetainedLayerTree(layerManager, *ss,
gfxUtils::sDumpPaintingToFile);
gfxEnv::DumpPaintToFile());
}
if (profilerNeedsDisplayList && !consoleNeedsDisplayList) {
@ -3398,10 +3399,10 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
}
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintingToFile) {
if (gfxEnv::DumpPaintToFile()) {
*ss << "</body></html>";
}
if (gfxUtils::sDumpPaintingToFile) {
if (gfxEnv::DumpPaintToFile()) {
fclose(gfxUtils::sDumpPaintFile);
}
gfxUtils::sDumpPaintFile = savedDumpFile;