Bug 1053992 - Add a red square in the top-right corner of FPS display for unused APZ transforms (i.e. when content is sync-scrolling). r=BenWa

This commit is contained in:
Kartikaya Gupta 2014-09-04 13:54:54 -04:00
parent b609197c3b
commit bf40c0ed98
3 changed files with 39 additions and 2 deletions

View File

@ -424,6 +424,24 @@ ContainerRender(ContainerT* aContainer,
RenderLayers(aContainer, aManager, RenderTargetPixel::FromUntyped(aClipRect)); RenderLayers(aContainer, aManager, RenderTargetPixel::FromUntyped(aClipRect));
} }
aContainer->mPrepared = nullptr; aContainer->mPrepared = nullptr;
// If it is a scrollable container layer with no child layers, and one of the APZCs
// attached to it has a nonempty async transform, then that transform is not applied
// to any visible content. Display a warning box (conditioned on the FPS display being
// enabled).
if (gfxPrefs::LayersDrawFPS() && aContainer->IsScrollInfoLayer()) {
// Since aContainer doesn't have any children we can just iterate from the top metrics
// on it down to the bottom using GetFirstChild and not worry about walking onto another
// underlying layer.
for (LayerMetricsWrapper i(aContainer); i; i = i.GetFirstChild()) {
if (AsyncPanZoomController* apzc = i.GetApzc()) {
if (!Matrix4x4(apzc->GetCurrentAsyncTransform()).IsIdentity()) {
aManager->UnusedApzTransformWarning();
break;
}
}
}
}
} }
ContainerLayerComposite::ContainerLayerComposite(LayerManagerComposite *aManager) ContainerLayerComposite::ContainerLayerComposite(LayerManagerComposite *aManager)

View File

@ -103,7 +103,9 @@ LayerManagerComposite::ClearCachedResources(Layer* aSubtree)
* LayerManagerComposite * LayerManagerComposite
*/ */
LayerManagerComposite::LayerManagerComposite(Compositor* aCompositor) LayerManagerComposite::LayerManagerComposite(Compositor* aCompositor)
: mCompositor(aCompositor) : mWarningLevel(0.0f)
, mUnusedApzTransformWarning(false)
, mCompositor(aCompositor)
, mInTransaction(false) , mInTransaction(false)
, mIsCompositorReady(false) , mIsCompositorReady(false)
, mDebugOverlayWantsNextFrame(false) , mDebugOverlayWantsNextFrame(false)
@ -346,11 +348,11 @@ LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
mFPS = MakeUnique<FPSState>(); mFPS = MakeUnique<FPSState>();
} }
float alpha = 1;
#ifdef ANDROID #ifdef ANDROID
// Draw a translation delay warning overlay // Draw a translation delay warning overlay
int width; int width;
int border; int border;
float alpha = 1;
if ((now - mWarnTime).ToMilliseconds() < kVisualWarningDuration) { if ((now - mWarnTime).ToMilliseconds() < kVisualWarningDuration) {
EffectChain effects; EffectChain effects;
@ -385,6 +387,18 @@ LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
float fillRatio = mCompositor->GetFillRatio(); float fillRatio = mCompositor->GetFillRatio();
mFPS->DrawFPS(now, drawFrameColorBars ? 10 : 0, 0, unsigned(fillRatio), mCompositor); mFPS->DrawFPS(now, drawFrameColorBars ? 10 : 0, 0, unsigned(fillRatio), mCompositor);
if (mUnusedApzTransformWarning) {
// If we have an unused APZ transform on this composite, draw a 20x20 red box
// in the top-right corner
EffectChain effects;
effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(1, 0, 0, 1));
mCompositor->DrawQuad(gfx::Rect(aBounds.width - 20, 0, aBounds.width, 20),
aBounds, effects, alpha, gfx::Matrix4x4());
mUnusedApzTransformWarning = false;
SetDebugOverlayWantsNextFrame(true);
}
} else { } else {
mFPS = nullptr; mFPS = nullptr;
} }

View File

@ -257,6 +257,10 @@ public:
} }
} }
void UnusedApzTransformWarning() {
mUnusedApzTransformWarning = true;
}
private: private:
/** Region we're clipping our current drawing to. */ /** Region we're clipping our current drawing to. */
nsIntRegion mClippingRegion; nsIntRegion mClippingRegion;
@ -297,6 +301,7 @@ private:
float mWarningLevel; float mWarningLevel;
mozilla::TimeStamp mWarnTime; mozilla::TimeStamp mWarnTime;
bool mUnusedApzTransformWarning;
RefPtr<Compositor> mCompositor; RefPtr<Compositor> mCompositor;
UniquePtr<LayerProperties> mClonedLayerTreeProperties; UniquePtr<LayerProperties> mClonedLayerTreeProperties;