Bug 971942: 6. layers.low-precision-resolution, layers.prefer-opengl, layers.prefer-d3d9, layers.enable-tiles, gfx.direct2d.disabled, gfx.direct2d.force-enabled, moved to gfxPrefs. r=bschouten

This commit is contained in:
Milan Sreckovic 2014-02-26 21:53:32 -05:00
parent bc67325654
commit cdd2e94e6e
7 changed files with 18 additions and 81 deletions

View File

@ -11,6 +11,7 @@
#include "gfxASurface.h" // for gfxASurface, etc
#include "gfxContext.h" // for gfxContext
#include "gfxRect.h" // for gfxRect
#include "gfxPrefs.h" // for gfxPrefs
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/gfx/2D.h" // for DrawTarget
#include "mozilla/gfx/Matrix.h" // for Matrix
@ -171,7 +172,7 @@ ClientLayerManager::CreateThebesLayerWithHint(ThebesLayerCreationHint aHint)
#ifdef MOZ_B2G
aHint == SCROLLABLE &&
#endif
gfxPlatform::GetPrefLayersEnableTiles() && AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_OPENGL) {
gfxPrefs::LayersTilesEnabled() && AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_OPENGL) {
nsRefPtr<ClientTiledThebesLayer> layer =
new ClientTiledThebesLayer(this);
CREATE_SHADOW(Thebes);

View File

@ -11,6 +11,7 @@
#include "CompositorChild.h" // for CompositorChild
#include "gfxContext.h" // for gfxContext, etc
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxRect.h" // for gfxRect
#include "mozilla/MathAlgorithms.h" // for Abs
#include "mozilla/gfx/Point.h" // for IntSize
@ -83,7 +84,8 @@ TiledContentClient::TiledContentClient(ClientTiledThebesLayer* aThebesLayer,
{
MOZ_COUNT_CTOR(TiledContentClient);
mLowPrecisionTiledBuffer.SetResolution(gfxPlatform::GetLowPrecisionResolution());
// The preference is int in "thousands", so adjust:
mLowPrecisionTiledBuffer.SetResolution(gfxPrefs::LowPrecisionResolution()/1000.f);
}
void

View File

@ -264,7 +264,7 @@ gfxPlatform::gfxPlatform()
// XXX - When 957560 is fixed, the pref can go away entirely
mLayersUseDeprecated =
Preferences::GetBool("layers.use-deprecated-textures", true)
&& !Preferences::GetBool("layers.prefer-opengl", false);
&& !gfxPrefs::LayersPreferOpenGL();
#else
mLayersUseDeprecated = false;
#endif
@ -1501,22 +1501,6 @@ gfxPlatform::GetBackendPref(const char* aBackendPrefName, uint32_t &aBackendBitm
return result;
}
float
gfxPlatform::GetLowPrecisionResolution()
{
static int32_t sLowPrecisionResolutionX1000 = 250;
static bool sLowPrecisionResolutionPrefCached = false;
if (!sLowPrecisionResolutionPrefCached) {
sLowPrecisionResolutionPrefCached = true;
mozilla::Preferences::AddIntVarCache(&sLowPrecisionResolutionX1000,
"layers.low-precision-resolution",
sLowPrecisionResolutionX1000);
}
return sLowPrecisionResolutionX1000/1000.f;
}
bool
gfxPlatform::OffMainThreadCompositingEnabled()
{
@ -1962,9 +1946,6 @@ gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
* and remember the values. Changing these preferences during the run will
* not have any effect until we restart.
*/
static bool sPrefLayersPreferOpenGL = false;
static bool sPrefLayersPreferD3D9 = false;
static bool sPrefLayersEnableTiles = false;
static bool sLayersSupportsD3D9 = false;
static bool sBufferRotationCheckPref = true;
static bool sPrefBrowserTabsRemoteAutostart = false;
@ -1982,9 +1963,6 @@ InitLayersAccelerationPrefs()
// explicit.
MOZ_ASSERT(NS_IsMainThread(), "can only initialize prefs on the main thread");
sPrefLayersPreferOpenGL = Preferences::GetBool("layers.prefer-opengl", false);
sPrefLayersPreferD3D9 = Preferences::GetBool("layers.prefer-d3d9", false);
sPrefLayersEnableTiles = Preferences::GetBool("layers.enable-tiles", false);
sPrefBrowserTabsRemoteAutostart = Preferences::GetBool("browser.tabs.remote.autostart", false);
#ifdef XP_WIN
@ -2028,20 +2006,6 @@ bool gfxPlatform::OffMainThreadCompositionRequired()
#endif
}
bool
gfxPlatform::GetPrefLayersPreferOpenGL()
{
InitLayersAccelerationPrefs();
return sPrefLayersPreferOpenGL;
}
bool
gfxPlatform::GetPrefLayersPreferD3D9()
{
InitLayersAccelerationPrefs();
return sPrefLayersPreferD3D9;
}
bool
gfxPlatform::CanUseDirect3D9()
{
@ -2051,13 +2015,6 @@ gfxPlatform::CanUseDirect3D9()
return sLayersSupportsD3D9;
}
bool
gfxPlatform::GetPrefLayersEnableTiles()
{
InitLayersAccelerationPrefs();
return sPrefLayersEnableTiles;
}
bool
gfxPlatform::BufferRotationEnabled()
{

View File

@ -485,9 +485,6 @@ public:
// platform-specific override, by default do nothing
}
// Retrieve the resolution that a low precision buffer should render at.
static float GetLowPrecisionResolution();
static bool OffMainThreadCompositingEnabled();
/** Use gfxPlatform::GetPref* methods instead of direct calls to Preferences
@ -495,10 +492,7 @@ public:
* only once, and remain the same until restart.
*/
static bool GetPrefLayersOffMainThreadCompositionEnabled();
static bool GetPrefLayersPreferOpenGL();
static bool GetPrefLayersPreferD3D9();
static bool CanUseDirect3D9();
static bool GetPrefLayersEnableTiles();
static bool OffMainThreadCompositionRequired();

View File

@ -98,13 +98,14 @@ private:
T mValue;
};
public:
// This is where DECL_GFX_PREF for each of the preferences should go.
// We will keep these in an alphabetical order to make it easier to see if
// a method accessing a pref already exists. Just add yours in the list.
DECL_GFX_PREF(Live, "gfx.canvas.azure.accelerated", CanvasAzureAccelerated, bool, false);
DECL_GFX_PREF(Once, "gfx.direct2d.disabled", Direct2DDisabled, bool, false);
DECL_GFX_PREF(Once, "gfx.direct2d.force-enabled", Direct2DForceEnabled, bool, false);
DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs", WorkAroundDriverBugs, bool, true);
DECL_GFX_PREF(Live, "gl.msaa-level", MSAALevel, uint32_t, 2);
@ -132,13 +133,17 @@ public:
DECL_GFX_PREF(Live, "layers.draw-borders", DrawLayerBorders, bool, false);
DECL_GFX_PREF(Live, "layers.draw-tile-borders", DrawTileBorders, bool, false);
DECL_GFX_PREF(Once, "layers.dump", LayersDump, bool, false);
DECL_GFX_PREF(Once, "layers.enable-tiles", LayersTilesEnabled, bool, false);
DECL_GFX_PREF(Live, "layers.frame-counter", DrawFrameCounter, bool, false);
DECL_GFX_PREF(Live, "layers.low-precision-buffer", UseLowPrecisionBuffer, bool, false);
DECL_GFX_PREF(Live, "layers.low-precision-resolution", LowPrecisionResolution, int32_t, 250);
DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.enabled", LayersOffMainThreadCompositionEnabled, bool, false);
DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-enabled", LayersOffMainThreadCompositionForceEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.testing.enabled", LayersOffMainThreadCompositionTestingEnabled, bool, false);
DECL_GFX_PREF(Live, "layers.orientation.sync.timeout", OrientationSyncMillis, uint32_t, (uint32_t)0);
DECL_GFX_PREF(Once, "layers.prefer-d3d9", LayersPreferD3D9, bool, false);
DECL_GFX_PREF(Once, "layers.prefer-opengl", LayersPreferOpenGL, bool, false);
DECL_GFX_PREF(Once, "layers.progressive-paint", UseProgressiveTilePainting, bool, false);
DECL_GFX_PREF(Once, "layers.scroll-graph", LayersScrollGraph, bool, false);

View File

@ -65,6 +65,7 @@
#include "d3dkmtQueryStatistics.h"
#include "SurfaceCache.h"
#include "gfxPrefs.h"
using namespace mozilla;
using namespace mozilla::gfx;
@ -110,29 +111,6 @@ public:
NS_IMPL_ISUPPORTS1(GfxD2DSurfaceReporter, nsIMemoryReporter)
namespace
{
bool OncePreferenceDirect2DDisabled()
{
static int preferenceValue = -1;
if (preferenceValue < 0) {
preferenceValue = Preferences::GetBool("gfx.direct2d.disabled", false);
}
return !!preferenceValue;
}
bool OncePreferenceDirect2DForceEnabled()
{
static int preferenceValue = -1;
if (preferenceValue < 0) {
preferenceValue = Preferences::GetBool("gfx.direct2d.force-enabled", false);
}
return !!preferenceValue;
}
} // anonymous namespace
#endif
class GfxD2DVramReporter MOZ_FINAL : public nsIMemoryReporter
@ -399,10 +377,10 @@ gfxWindowsPlatform::UpdateRenderMode()
// These will only be evaluated once, and any subsequent changes to
// the preferences will be ignored until restart.
d2dDisabled = OncePreferenceDirect2DDisabled();
d2dForceEnabled = OncePreferenceDirect2DForceEnabled();
d2dDisabled = gfxPrefs::Direct2DDisabled();
d2dForceEnabled = gfxPrefs::Direct2DForceEnabled();
bool tryD2D = (!d2dBlocked && !GetPrefLayersPreferD3D9()) || d2dForceEnabled;
bool tryD2D = d2dForceEnabled || (!d2dBlocked && !gfxPrefs::LayersPreferD3D9());
// Do not ever try if d2d is explicitly disabled,
// or if we're not using DWrite fonts.

View File

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "APZCCallbackHelper.h"
#include "gfxPlatform.h" // For gfxPlatform::GetPrefLayersEnableTiles
#include "gfxPrefs.h" // For gfxPrefs::LayersTilesEnabled
#include "mozilla/Preferences.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h"
@ -72,7 +72,7 @@ MaybeAlignAndClampDisplayPort(mozilla::layers::FrameMetrics& aFrameMetrics,
// Expand the display port to the next tile boundaries, if tiled thebes layers
// are enabled.
if (gfxPlatform::GetPrefLayersEnableTiles()) {
if (gfxPrefs::LayersTilesEnabled()) {
displayPort =
ExpandDisplayPortToTileBoundaries(displayPort + aActualScrollOffset,
aFrameMetrics.LayersPixelsPerCSSPixel())