Bug 870816 - Replace DEBUG_INVALIDATIONS with a pref called nglayout.debug.invalidation. r=mattwoodrow

This commit is contained in:
Jonathan Watt 2013-05-14 00:47:02 +01:00
parent a656f45a92
commit ab3b6bcd32
5 changed files with 84 additions and 38 deletions

View File

@ -33,7 +33,6 @@
#ifdef DEBUG
#include <stdio.h>
//#define DEBUG_INVALIDATIONS
//#define DEBUG_DISPLAY_ITEM_DATA
#endif
@ -822,10 +821,12 @@ InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsIntRegion& aRegion,
nsIntRegion rgn = aRegion;
rgn.MoveBy(-aTranslation);
aLayer->InvalidateRegion(rgn);
#ifdef DEBUG_INVALIDATIONS
nsAutoCString str;
AppendToString(str, rgn);
printf("Invalidating layer %p: %s\n", aLayer, str.get());
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
nsAutoCString str;
AppendToString(str, rgn);
printf("Invalidating layer %p: %s\n", aLayer, str.get());
}
#endif
}
@ -980,8 +981,10 @@ FrameLayerBuilder::ProcessRemovedDisplayItems(nsRefPtrHashKey<DisplayItemData>*
ThebesLayer* t = data->mLayer->AsThebesLayer();
if (t) {
#ifdef DEBUG_INVALIDATIONS
printf("Invalidating unused display item (%i) belonging to frame %p from layer %p\n", data->mDisplayItemKey, data->mFrameList[0], t);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Invalidating unused display item (%i) belonging to frame %p from layer %p\n", data->mDisplayItemKey, data->mFrameList[0], t);
}
#endif
InvalidatePostTransformRegion(t,
data->mGeometry->ComputeInvalidationRegion(),
@ -1273,8 +1276,10 @@ ResetScrollPositionForLayerPixelAlignment(const nsIFrame* aActiveScrolledRoot)
static void
InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aActiveScrolledRoot)
{
#ifdef DEBUG_INVALIDATIONS
printf("Invalidating entire layer %p\n", aLayer);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Invalidating entire layer %p\n", aLayer);
}
#endif
nsIntRect invalidate = aLayer->GetValidRegion().GetBounds();
aLayer->InvalidateRegion(invalidate);
@ -1321,14 +1326,18 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aActiveScrolledRoot,
#endif
}
if (!data->mRegionToInvalidate.IsEmpty()) {
#ifdef DEBUG_INVALIDATIONS
printf("Invalidating deleted frame content from layer %p\n", layer.get());
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Invalidating deleted frame content from layer %p\n", layer.get());
}
#endif
layer->InvalidateRegion(data->mRegionToInvalidate);
#ifdef DEBUG_INVALIDATIONS
nsAutoCString str;
AppendToString(str, data->mRegionToInvalidate);
printf("Invalidating layer %p: %s\n", layer.get(), str.get());
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
nsAutoCString str;
AppendToString(str, data->mRegionToInvalidate);
printf("Invalidating layer %p: %s\n", layer.get(), str.get());
}
#endif
data->mRegionToInvalidate.SetEmpty();
}
@ -2243,8 +2252,10 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
// Note that whenever the layer's scale changes, we invalidate the whole thing,
// so it doesn't matter whether we are using the old scale at last paint
// or a new scale here
#ifdef DEBUG_INVALIDATIONS
printf("Display item type %s(%p) changed layers %p to %p!\n", aItem->Name(), aItem->Frame(), t, aNewLayer);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Display item type %s(%p) changed layers %p to %p!\n", aItem->Name(), aItem->Frame(), t, aNewLayer);
}
#endif
InvalidatePostTransformRegion(t,
oldGeometry->ComputeInvalidationRegion(),
@ -2284,16 +2295,20 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
// This item is being added for the first time, invalidate its entire area.
//TODO: We call GetGeometry again in AddThebesDisplayItem, we should reuse this.
combined = aClip.ApplyNonRoundedIntersection(aGeometry->ComputeInvalidationRegion());
#ifdef DEBUG_INVALIDATIONS
printf("Display item type %s(%p) added to layer %p!\n", aItem->Name(), aItem->Frame(), aNewLayer);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Display item type %s(%p) added to layer %p!\n", aItem->Name(), aItem->Frame(), aNewLayer);
}
#endif
} else if (isInvalid || (aItem->IsInvalid(invalid) && invalid.IsEmpty())) {
// Either layout marked item as needing repainting, invalidate the entire old and new areas.
combined = oldClip->ApplyNonRoundedIntersection(oldGeometry->ComputeInvalidationRegion());
combined.MoveBy(shift);
combined.Or(combined, aClip.ApplyNonRoundedIntersection(aGeometry->ComputeInvalidationRegion()));
#ifdef DEBUG_INVALIDATIONS
printf("Display item type %s(%p) (in layer %p) belongs to an invalidated frame!\n", aItem->Name(), aItem->Frame(), aNewLayer);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Display item type %s(%p) (in layer %p) belongs to an invalidated frame!\n", aItem->Name(), aItem->Frame(), aNewLayer);
}
#endif
} else {
// Let the display item check for geometry changes and decide what needs to be
@ -2316,9 +2331,11 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
if (aClip.ComputeRegionInClips(oldClip, shift, &clip)) {
combined.And(combined, clip);
}
#ifdef DEBUG_INVALIDATIONS
if (!combined.IsEmpty()) {
printf("Display item type %s(%p) (in layer %p) changed geometry!\n", aItem->Name(), aItem->Frame(), aNewLayer);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
if (!combined.IsEmpty()) {
printf("Display item type %s(%p) (in layer %p) changed geometry!\n", aItem->Name(), aItem->Frame(), aNewLayer);
}
}
#endif
}
@ -2421,8 +2438,10 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayer* aLayer,
invalid.GetBounds());
}
if (!invalid.IsEmpty()) {
#ifdef DEBUG_INVALIDATIONS
printf("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), aLayer);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), aLayer);
}
#endif
if (hasClip) {
invalid.And(invalid, intClip);

View File

@ -114,6 +114,7 @@ typedef FrameMetrics::ViewID ViewID;
/* static */ uint32_t nsLayoutUtils::sFontSizeInflationMaxRatio;
/* static */ bool nsLayoutUtils::sFontSizeInflationForceEnabled;
/* static */ bool nsLayoutUtils::sFontSizeInflationDisabledInMasterProcess;
/* static */ bool nsLayoutUtils::sInvalidationDebuggingIsEnabled;
static ViewID sScrollIdCounter = FrameMetrics::START_SCROLL_ID;
@ -4979,6 +4980,8 @@ nsLayoutUtils::Initialize()
"font.size.inflation.forceEnabled");
Preferences::AddBoolVarCache(&sFontSizeInflationDisabledInMasterProcess,
"font.size.inflation.disabledInMasterProcess");
Preferences::AddBoolVarCache(&sInvalidationDebuggingIsEnabled,
"nglayout.debug.invalidation");
#ifdef MOZ_FLEXBOX
Preferences::RegisterCallback(FlexboxEnabledPrefChangeCallback,

View File

@ -1728,6 +1728,15 @@ public:
return sFontSizeInflationMappingIntercept;
}
/**
* Returns true if the nglayout.debug.invalidation pref is set to true.
* Note that sInvalidationDebuggingIsEnabled is declared outside this function to
* allow it to be accessed an manipulated from breakpoint conditions.
*/
static bool InvalidationDebuggingIsEnabled() {
return sInvalidationDebuggingIsEnabled;
}
static void Initialize();
static void Shutdown();
@ -1855,6 +1864,7 @@ private:
static uint32_t sFontSizeInflationMaxRatio;
static bool sFontSizeInflationForceEnabled;
static bool sFontSizeInflationDisabledInMasterProcess;
static bool sInvalidationDebuggingIsEnabled;
};
// Helper-functions for nsLayoutUtils::SortFrameList()

View File

@ -28,6 +28,7 @@
#include "nsRefreshDriver.h"
#include "nsITimer.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsComponentManagerUtils.h"
#include "prlog.h"
@ -980,8 +981,10 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mPresShellsToInvalidateIfHidden.Clear();
if (mViewManagerFlushIsPending) {
#ifdef DEBUG_INVALIDATIONS
printf("Starting ProcessPendingUpdates\n");
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Starting ProcessPendingUpdates\n");
}
#endif
#ifndef MOZ_WIDGET_GONK
// Waiting for bug 830475 to work on B2G.
@ -994,8 +997,10 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mViewManagerFlushIsPending = false;
nsRefPtr<nsViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
vm->ProcessPendingUpdates();
#ifdef DEBUG_INVALIDATIONS
printf("Ending ProcessPendingUpdates\n");
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Ending ProcessPendingUpdates\n");
}
#endif
}
}

View File

@ -24,6 +24,7 @@
#include "nsRefreshDriver.h"
#include "mozilla/Preferences.h"
#include "nsContentUtils.h"
#include "nsLayoutUtils.h"
/**
XXX TODO XXX
@ -324,13 +325,17 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
"Widgets that we paint must all be display roots");
if (mPresShell) {
#ifdef DEBUG_INVALIDATIONS
printf("--COMPOSITE-- %p\n", mPresShell);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("--COMPOSITE-- %p\n", mPresShell);
}
#endif
mPresShell->Paint(aView, damageRegion,
nsIPresShell::PAINT_COMPOSITE);
#ifdef DEBUG_INVALIDATIONS
printf("--ENDCOMPOSITE--\n");
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("--ENDCOMPOSITE--\n");
}
#endif
mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
}
@ -385,8 +390,10 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
#ifdef DEBUG_INVALIDATIONS
printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
}
#endif
nsAutoScriptBlocker scriptBlocker;
NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
@ -394,8 +401,10 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
SetPainting(true);
mPresShell->Paint(aView, nsRegion(),
nsIPresShell::PAINT_LAYERS);
#ifdef DEBUG_INVALIDATIONS
printf("---- PAINT END ----\n");
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("---- PAINT END ----\n");
}
#endif
aView->SetForcedRepaint(false);
SetPainting(false);