Bug 971942: 4. layers.frame-counter, layers.draw-borders, layers.draw-tile-borders, layers.draw-bigimage-borders, layers.dump, layers.frame-counter, layers.progressive-paint, layers.low-precision-buffer moved to gfxPrefs. r=nsilva

This commit is contained in:
Milan Sreckovic 2014-02-26 21:53:31 -05:00
parent 710bd9d8f9
commit e23aa3622d
8 changed files with 29 additions and 125 deletions

View File

@ -24,6 +24,7 @@
#include "gfxImageSurface.h" // for gfxImageSurface
#include "gfxMatrix.h" // for gfxMatrix
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxPoint.h" // for gfxIntSize, gfxPoint
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils
@ -542,7 +543,7 @@ static uint16_t sFrameCount = 0;
void
BasicLayerManager::RenderDebugOverlay()
{
if (!gfxPlatform::DrawFrameCounter()) {
if (!gfxPrefs::DrawFrameCounter()) {
return;
}

View File

@ -8,6 +8,7 @@
#include "ClientLayerManager.h" // for ClientLayerManager, etc
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxRect.h" // for gfxRect
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/gfx/BaseSize.h" // for BaseSize
@ -176,8 +177,8 @@ ClientTiledThebesLayer::RenderLayer()
// Fast path for no progressive updates, no low-precision updates and no
// critical display-port set, or no display-port set.
const FrameMetrics& parentMetrics = GetParent()->GetFrameMetrics();
if ((!gfxPlatform::UseProgressiveTilePainting() &&
!gfxPlatform::UseLowPrecisionBuffer() &&
if ((!gfxPrefs::UseProgressiveTilePainting() &&
!gfxPrefs::UseLowPrecisionBuffer() &&
parentMetrics.mCriticalDisplayPort.IsEmpty()) ||
parentMetrics.mDisplayPort.IsEmpty()) {
mValidRegion = mVisibleRegion;
@ -212,7 +213,7 @@ ClientTiledThebesLayer::RenderLayer()
nsIntRegion lowPrecisionInvalidRegion;
if (!mPaintData.mLayoutCriticalDisplayPort.IsEmpty()) {
if (gfxPlatform::UseLowPrecisionBuffer()) {
if (gfxPrefs::UseLowPrecisionBuffer()) {
// Calculate the invalid region for the low precision buffer
lowPrecisionInvalidRegion.Sub(mVisibleRegion, mLowPrecisionValidRegion);
@ -232,7 +233,7 @@ ClientTiledThebesLayer::RenderLayer()
if (!invalidRegion.IsEmpty() && mPaintData.mLowPrecisionPaintCount == 0) {
bool updatedBuffer = false;
// Only draw progressively when the resolution is unchanged.
if (gfxPlatform::UseProgressiveTilePainting() &&
if (gfxPrefs::UseProgressiveTilePainting() &&
!ClientManager()->HasShadowTarget() &&
mContentClient->mTiledBuffer.GetFrameResolution() == mPaintData.mResolution) {
// Store the old valid region, then clear it before painting.

View File

@ -21,7 +21,7 @@
#include "Units.h" // for ScreenIntRect
#include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs
#ifdef XP_MACOSX
#include "gfxPlatformMac.h"
#endif
@ -389,7 +389,7 @@ static uint16_t sFrameCount = 0;
void
LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
{
if (gfxPlatform::GetPrefLayersDrawFPS()) {
if (gfxPrefs::LayersDrawFPS()) {
if (!mFPS) {
mFPS = new FPSState();
}
@ -400,7 +400,7 @@ LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
mFPS = nullptr;
}
if (gfxPlatform::DrawFrameCounter()) {
if (gfxPrefs::DrawFrameCounter()) {
profiler_set_frame_number(sFrameCount);
uint16_t frameNumber = sFrameCount;
@ -437,7 +437,7 @@ LayerManagerComposite::Render()
return;
}
if (gfxPlatform::GetPrefLayersDump()) {
if (gfxPrefs::LayersDump()) {
this->Dump();
}
@ -447,7 +447,7 @@ LayerManagerComposite::Render()
if (composer2D && composer2D->TryRender(mRoot, mWorldMatrix)) {
if (mFPS) {
double fps = mFPS->mCompositionFps.AddFrameAndGetFps(TimeStamp::Now());
if (gfxPlatform::GetPrefLayersDrawFPS()) {
if (gfxPrefs::LayersDrawFPS()) {
printf_stderr("HWComposer: FPS is %g\n", fps);
}
}
@ -655,7 +655,7 @@ LayerManagerComposite::ComputeRenderIntegrity()
{
// We only ever have incomplete rendering when progressive tiles are enabled.
Layer* root = GetRoot();
if (!gfxPlatform::UseProgressiveTilePainting() || !root) {
if (!gfxPrefs::UseProgressiveTilePainting() || !root) {
return 1.f;
}

View File

@ -19,7 +19,7 @@
#include "base/message_loop.h" // for MessageLoop
#include "base/task.h" // for NewRunnableMethod, etc
#include "base/tracked.h" // for FROM_HERE
#include "gfxPlatform.h" // for gfxPlatform::UseProgressiveTilePainting
#include "gfxPrefs.h" // for gfxPrefs::UseProgressiveTilePainting
#include "gfxTypes.h" // for gfxFloat
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/BasicEvents.h" // for Modifiers, MODIFIER_*
@ -287,11 +287,6 @@ static bool gCrossSlideEnabled = false;
*/
static bool gAllowCheckerboarding = true;
/**
* Pref that enables progressive tile painting
*/
static bool gUseProgressiveTilePainting = false;
/**
* Pref that enables enlarging of the displayport along one axis when its
* opposite's scrollable rect is within the composition bounds. That is, we
@ -424,7 +419,6 @@ AsyncPanZoomController::InitializeGlobalState()
Preferences::AddBoolVarCache(&gCrossSlideEnabled, "apz.cross_slide.enabled", gCrossSlideEnabled);
Preferences::AddIntVarCache(&gAxisLockMode, "apz.axis_lock_mode", gAxisLockMode);
Preferences::AddBoolVarCache(&gAllowCheckerboarding, "apz.allow-checkerboarding", gAllowCheckerboarding);
gUseProgressiveTilePainting = gfxPlatform::UseProgressiveTilePainting();
Preferences::AddBoolVarCache(&gEnlargeDisplayPortWhenOnlyScrollable, "apz.enlarge_displayport_when_only_scrollable",
gEnlargeDisplayPortWhenOnlyScrollable);
@ -2055,7 +2049,7 @@ void AsyncPanZoomController::UpdateSharedCompositorFrameMetrics()
FrameMetrics* frame = mSharedFrameMetricsBuffer ?
static_cast<FrameMetrics*>(mSharedFrameMetricsBuffer->memory()) : nullptr;
if (gUseProgressiveTilePainting && frame && mSharedLock) {
if (frame && mSharedLock && gfxPrefs::UseProgressiveTilePainting()) {
mSharedLock->Lock();
*frame = mFrameMetrics;
mSharedLock->Unlock();
@ -2070,7 +2064,7 @@ void AsyncPanZoomController::ShareCompositorFrameMetrics() {
// Only create the shared memory buffer if it hasn't already been created,
// we are using progressive tile painting, and we have a
// compositor to pass the shared memory back to the content process/thread.
if (!mSharedFrameMetricsBuffer && gUseProgressiveTilePainting && compositor) {
if (!mSharedFrameMetricsBuffer && compositor && gfxPrefs::UseProgressiveTilePainting()) {
// Create shared memory and initialize it with the current FrameMetrics value
mSharedFrameMetricsBuffer = new ipc::SharedMemoryBasic;

View File

@ -109,8 +109,6 @@ static int gCMSIntent = -2;
static void ShutdownCMS();
static void MigratePrefs();
static bool sDrawFrameCounter = false;
#include "mozilla/gfx/2D.h"
using namespace mozilla::gfx;
@ -249,9 +247,6 @@ static const char *gPrefLangNames[] = {
gfxPlatform::gfxPlatform()
: mAzureCanvasBackendCollector(MOZ_THIS_IN_INITIALIZER_LIST(),
&gfxPlatform::GetAzureBackendInfo)
, mDrawLayerBorders(false)
, mDrawTileBorders(false)
, mDrawBigImageBorders(false)
{
mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
@ -274,16 +269,6 @@ gfxPlatform::gfxPlatform()
mLayersUseDeprecated = false;
#endif
Preferences::AddBoolVarCache(&mDrawLayerBorders,
"layers.draw-borders",
false);
Preferences::AddBoolVarCache(&mDrawTileBorders,
"layers.draw-tile-borders",
false);
Preferences::AddBoolVarCache(&mDrawBigImageBorders,
"layers.draw-bigimage-borders",
false);
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
InitBackendPrefs(canvasMask, BackendType::CAIRO,
@ -445,10 +430,6 @@ gfxPlatform::Init()
Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording", nullptr);
mozilla::Preferences::AddBoolVarCache(&sDrawFrameCounter,
"layers.frame-counter",
false);
CreateCMSOutputProfile();
#ifdef USE_SKIA
@ -1315,24 +1296,18 @@ mozilla::layers::DiagnosticTypes
gfxPlatform::GetLayerDiagnosticTypes()
{
mozilla::layers::DiagnosticTypes type = DIAGNOSTIC_NONE;
if (mDrawLayerBorders) {
if (gfxPrefs::DrawLayerBorders()) {
type |= mozilla::layers::DIAGNOSTIC_LAYER_BORDERS;
}
if (mDrawTileBorders) {
if (gfxPrefs::DrawTileBorders()) {
type |= mozilla::layers::DIAGNOSTIC_TILE_BORDERS;
}
if (mDrawBigImageBorders) {
if (gfxPrefs::DrawBigImageBorders()) {
type |= mozilla::layers::DIAGNOSTIC_BIGIMAGE_BORDERS;
}
return type;
}
bool
gfxPlatform::DrawFrameCounter()
{
return sDrawFrameCounter;
}
void
gfxPlatform::GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
{
@ -1529,38 +1504,6 @@ gfxPlatform::GetBackendPref(const char* aBackendPrefName, uint32_t &aBackendBitm
return result;
}
bool
gfxPlatform::UseProgressiveTilePainting()
{
static bool sUseProgressiveTilePainting;
static bool sUseProgressiveTilePaintingPrefCached = false;
if (!sUseProgressiveTilePaintingPrefCached) {
sUseProgressiveTilePaintingPrefCached = true;
mozilla::Preferences::AddBoolVarCache(&sUseProgressiveTilePainting,
"layers.progressive-paint",
false);
}
return sUseProgressiveTilePainting;
}
bool
gfxPlatform::UseLowPrecisionBuffer()
{
static bool sUseLowPrecisionBuffer;
static bool sUseLowPrecisionBufferPrefCached = false;
if (!sUseLowPrecisionBufferPrefCached) {
sUseLowPrecisionBufferPrefCached = true;
mozilla::Preferences::AddBoolVarCache(&sUseLowPrecisionBuffer,
"layers.low-precision-buffer",
false);
}
return sUseLowPrecisionBuffer;
}
float
gfxPlatform::GetLowPrecisionResolution()
{
@ -2028,9 +1971,6 @@ static bool sPrefLayersOffMainThreadCompositionForceEnabled = false;
static bool sPrefLayersAccelerationDisabled = false;
static bool sPrefLayersPreferOpenGL = false;
static bool sPrefLayersPreferD3D9 = false;
static bool sPrefLayersDrawFPS = false;
static bool sPrefLayersDump = false;
static bool sPrefLayersScrollGraph = false;
static bool sPrefLayersEnableTiles = false;
static bool sLayersSupportsD3D9 = false;
static bool sBufferRotationCheckPref = true;
@ -2055,13 +1995,9 @@ InitLayersAccelerationPrefs()
sPrefLayersAccelerationDisabled = Preferences::GetBool("layers.acceleration.disabled", false);
sPrefLayersPreferOpenGL = Preferences::GetBool("layers.prefer-opengl", false);
sPrefLayersPreferD3D9 = Preferences::GetBool("layers.prefer-d3d9", false);
sPrefLayersDump = Preferences::GetBool("layers.dump", false);
sPrefLayersScrollGraph = Preferences::GetBool("layers.scroll-graph", false);
sPrefLayersEnableTiles = Preferences::GetBool("layers.enable-tiles", false);
sPrefBrowserTabsRemoteAutostart = Preferences::GetBool("browser.tabs.remote.autostart", false);
Preferences::AddBoolVarCache(&sPrefLayersDrawFPS, "layers.acceleration.draw-fps", false);
#ifdef XP_WIN
if (gfxPrefs::LayersAccelerationForceEnabled()) {
sLayersSupportsD3D9 = true;
@ -2124,13 +2060,6 @@ gfxPlatform::GetPrefLayersPreferD3D9()
return sPrefLayersPreferD3D9;
}
bool
gfxPlatform::GetPrefLayersDrawFPS()
{
InitLayersAccelerationPrefs();
return sPrefLayersDrawFPS;
}
bool
gfxPlatform::CanUseDirect3D9()
{
@ -2140,22 +2069,6 @@ gfxPlatform::CanUseDirect3D9()
return sLayersSupportsD3D9;
}
bool
gfxPlatform::GetPrefLayersDump()
{
InitLayersAccelerationPrefs();
return sPrefLayersDump;
}
bool
gfxPlatform::GetPrefLayersScrollGraph()
{
// this function is called from the compositor thread, so it is not
// safe to init the prefs etc. from here.
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
return sPrefLayersScrollGraph;
}
bool
gfxPlatform::GetPrefLayersEnableTiles()
{

View File

@ -485,13 +485,6 @@ public:
// platform-specific override, by default do nothing
}
// Break large OMTC tiled thebes layer painting into small paints.
static bool UseProgressiveTilePainting();
// When a critical display-port is set, render the visible area outside of
// it into a buffer at a lower precision. Requires tiled buffers.
static bool UseLowPrecisionBuffer();
// Retrieve the resolution that a low precision buffer should render at.
static float GetLowPrecisionResolution();
@ -506,10 +499,7 @@ public:
static bool GetPrefLayersPreferOpenGL();
static bool GetPrefLayersPreferD3D9();
static bool CanUseDirect3D9();
static bool GetPrefLayersDump();
static bool GetPrefLayersScrollGraph();
static bool GetPrefLayersEnableTiles();
static bool GetPrefLayersDrawFPS();
static bool OffMainThreadCompositionRequired();
@ -602,7 +592,6 @@ public:
*/
mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();
static bool DrawFrameCounter();
static nsIntRect FrameCounterBounds() {
int bits = 16;
int sizeOfBit = 3;
@ -732,9 +721,6 @@ private:
bool mWidgetUpdateFlashing;
bool mLayersPreferMemoryOverShmem;
bool mLayersUseDeprecated;
bool mDrawLayerBorders;
bool mDrawTileBorders;
bool mDrawBigImageBorders;
};
#endif /* GFX_PLATFORM_H */

View File

@ -108,6 +108,7 @@ public:
DECL_GFX_PREF(Live, "gl.msaa-level", MSAALevel, uint32_t, 2);
DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabled, bool, false);
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, true);
DECL_GFX_PREF(Once, "layers.acceleration.force-enabled", LayersAccelerationForceEnabled, bool, false);
#ifdef XP_WIN
// On windows, ignore the preference value, forcing async video to false.
@ -125,8 +126,15 @@ public:
// preference value, defaulting to true.
DECL_GFX_PREF(Once, "layers.componentalpha.enabled", ComponentAlphaEnabled, bool, true);
#endif
DECL_GFX_PREF(Live, "layers.draw-bigimage-borders", DrawBigImageBorders, bool, false);
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(Live, "layers.frame-counter", DrawFrameCounter, bool, false);
DECL_GFX_PREF(Live, "layers.low-precision-buffer", UseLowPrecisionBuffer, bool, false);
DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
DECL_GFX_PREF(Live, "layers.orientation.sync.timeout", OrientationSyncMillis, uint32_t, (uint32_t)0);
DECL_GFX_PREF(Once, "layers.progressive-paint", UseProgressiveTilePainting, bool, false);
DECL_GFX_PREF(Once, "layers.scroll-graph", LayersScrollGraph, bool, false);
DECL_GFX_PREF(Once, "layout.frame_rate", LayoutFrameRate, int32_t, -1);

View File

@ -27,6 +27,7 @@
#include "nsLayoutUtils.h"
#include "Layers.h"
#include "gfxPlatform.h"
#include "gfxPrefs.h"
#include "nsIDocument.h"
/**
@ -450,7 +451,7 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView)
// If we draw the frame counter we need to make sure we invalidate the area
// for it to make it on screen
if (gfxPlatform::DrawFrameCounter()) {
if (gfxPrefs::DrawFrameCounter()) {
nsRect counterBounds = gfxPlatform::FrameCounterBounds().ToAppUnits(AppUnitsPerDevPixel());
r = r.Or(r, counterBounds);
}