Skip to content

Commit

Permalink
Bug 971942: 4. layers.frame-counter, layers.draw-borders, layers.draw…
Browse files Browse the repository at this point in the history
…-tile-borders, layers.draw-bigimage-borders, layers.dump, layers.frame-counter, layers.progressive-paint, layers.low-precision-buffer moved to gfxPrefs. r=nsilva
  • Loading branch information
msreckovic committed Feb 27, 2014
1 parent 710bd9d commit e23aa36
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 125 deletions.
3 changes: 2 additions & 1 deletion gfx/layers/basic/BasicLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -542,7 +543,7 @@ static uint16_t sFrameCount = 0;
void
BasicLayerManager::RenderDebugOverlay()
{
if (!gfxPlatform::DrawFrameCounter()) {
if (!gfxPrefs::DrawFrameCounter()) {
return;
}

Expand Down
9 changes: 5 additions & 4 deletions gfx/layers/client/ClientTiledThebesLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions gfx/layers/composite/LayerManagerComposite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand All @@ -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;
Expand Down Expand Up @@ -437,7 +437,7 @@ LayerManagerComposite::Render()
return;
}

if (gfxPlatform::GetPrefLayersDump()) {
if (gfxPrefs::LayersDump()) {
this->Dump();
}

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 3 additions & 9 deletions gfx/layers/ipc/AsyncPanZoomController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down
93 changes: 3 additions & 90 deletions gfx/thebes/gfxPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -2124,13 +2060,6 @@ gfxPlatform::GetPrefLayersPreferD3D9()
return sPrefLayersPreferD3D9;
}

bool
gfxPlatform::GetPrefLayersDrawFPS()
{
InitLayersAccelerationPrefs();
return sPrefLayersDrawFPS;
}

bool
gfxPlatform::CanUseDirect3D9()
{
Expand All @@ -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()
{
Expand Down
14 changes: 0 additions & 14 deletions gfx/thebes/gfxPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,6 @@ class gfxPlatform {
// 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();

Expand All @@ -506,10 +499,7 @@ class gfxPlatform {
static bool GetPrefLayersPreferOpenGL();
static bool GetPrefLayersPreferD3D9();
static bool CanUseDirect3D9();
static bool GetPrefLayersDump();
static bool GetPrefLayersScrollGraph();
static bool GetPrefLayersEnableTiles();
static bool GetPrefLayersDrawFPS();

static bool OffMainThreadCompositionRequired();

Expand Down Expand Up @@ -602,7 +592,6 @@ class gfxPlatform {
*/
mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();

static bool DrawFrameCounter();
static nsIntRect FrameCounterBounds() {
int bits = 16;
int sizeOfBit = 3;
Expand Down Expand Up @@ -732,9 +721,6 @@ class gfxPlatform {
bool mWidgetUpdateFlashing;
bool mLayersPreferMemoryOverShmem;
bool mLayersUseDeprecated;
bool mDrawLayerBorders;
bool mDrawTileBorders;
bool mDrawBigImageBorders;
};

#endif /* GFX_PLATFORM_H */
8 changes: 8 additions & 0 deletions gfx/thebes/gfxPrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class gfxPrefs MOZ_FINAL
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.
Expand All @@ -125,8 +126,15 @@ class gfxPrefs MOZ_FINAL
// 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);
Expand Down
Loading

0 comments on commit e23aa36

Please sign in to comment.