Bug 1617179 - Remove IsCurrentlyCheckerboarding. r=botond

IsCurrentlyCheckerboarding can be removed now, as it does the same underlying
computation as "GetCheckerboardMagnitude(...) > 0". The only difference is that
the caller now needs to compute the clipped composition bounds, which is
easy enough to do at the one call site.

Differential Revision: https://phabricator.services.mozilla.com/D67377

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2020-03-19 13:51:04 +00:00
parent 610cac7e05
commit da92d0e1ad
3 changed files with 7 additions and 123 deletions

View File

@ -3653,17 +3653,20 @@ bool APZCTreeManager::GetAPZTestData(LayersId aLayersId,
}
{ // add some additional "current state" into the returned APZTestData
RecursiveMutexAutoLock treeLock(
mTreeLock); // for IsCurrentlyCheckerboarding
MutexAutoLock mapLock(mMapLock); // for mApzcMap
MutexAutoLock mapLock(mMapLock);
ClippedCompositionBoundsMap clippedCompBounds;
for (const auto& mapping : mApzcMap) {
if (mapping.first.mLayersId != aLayersId) {
continue;
}
ParentLayerRect clippedBounds = ComputeClippedCompositionBounds(
mapLock, clippedCompBounds, mapping.first);
AsyncPanZoomController* apzc = mapping.second.apzc;
std::string viewId = std::to_string(mapping.first.mScrollId);
std::string apzcState;
if (apzc->IsCurrentlyCheckerboarding()) {
if (apzc->GetCheckerboardMagnitude(clippedBounds)) {
apzcState += "checkerboarding,";
}
aOutData->RecordAdditionalData(viewId, apzcState);

View File

@ -4327,78 +4327,6 @@ CSSRect AsyncPanZoomController::GetVisibleRect(
return visible;
}
ParentLayerRect AsyncPanZoomController::RecursivelyClipCompBounds(
const ParentLayerRect& aChildCompBounds) const {
// The childCompBounds is in the ParentLayer space of a child layer, which
// is the Layer space of this layer, so we can cast it.
LayerRect compBoundsInLayerSpace = ViewAs<LayerPixel>(
aChildCompBounds, PixelCastJustification::MovingDownToChildren);
// Apply the async transform from this layer and then clip with this
// layer's composition bounds.
AsyncTransform appliesToLayer =
GetCurrentAsyncTransform(AsyncPanZoomController::eForCompositing);
ParentLayerRect compBoundsInParentSpace =
(compBoundsInLayerSpace * appliesToLayer.mScale) +
appliesToLayer.mTranslation;
{ // hold lock while reading Metrics()
RecursiveMutexAutoLock lock(mRecursiveMutex);
compBoundsInParentSpace =
compBoundsInParentSpace.Intersect(Metrics().GetCompositionBounds());
}
// Recurse up the tree
if (mParent) {
// Make sure we're not holding our lock when we do this, to be extra safe.
mRecursiveMutex.AssertNotCurrentThreadIn();
compBoundsInParentSpace =
mParent->RecursivelyClipCompBounds(compBoundsInParentSpace);
}
// Undo async transformation from above to produce return value in the same
// coordinate space as the input parameter.
compBoundsInLayerSpace =
(compBoundsInParentSpace - appliesToLayer.mTranslation) /
appliesToLayer.mScale;
return ViewAs<ParentLayerPixel>(compBoundsInLayerSpace,
PixelCastJustification::MovingDownToChildren);
}
CSSRect AsyncPanZoomController::GetRecursivelyVisibleRect() const {
CSSRect visible;
ParentLayerRect compBounds;
CSSToParentLayerScale2D zoom;
{ // scope mutex
RecursiveMutexAutoLock lock(mRecursiveMutex);
visible = GetVisibleRect(lock); // relative to scrolled frame origin
compBounds = Metrics().GetCompositionBounds();
zoom = Metrics().GetZoom();
}
if (mParent) {
// compBounds and clippedCompBounds are relative to the layer tree origin
ParentLayerRect clippedCompBounds =
mParent->RecursivelyClipCompBounds(compBounds);
// the "*RelativeToItself*" variables are relative to the comp bounds origin
ParentLayerRect visiblePartOfCompBoundsRelativeToItself =
clippedCompBounds - compBounds.TopLeft();
CSSRect visiblePartOfCompBoundsRelativeToItselfInCssSpace =
(visiblePartOfCompBoundsRelativeToItself / zoom);
// this one is relative to the scrolled frame origin, same as `visible`
CSSRect visiblePartOfCompBoundsInCssSpace =
visiblePartOfCompBoundsRelativeToItselfInCssSpace + visible.TopLeft();
visible = visible.Intersect(visiblePartOfCompBoundsInCssSpace);
}
return visible;
}
uint32_t AsyncPanZoomController::GetCheckerboardMagnitude(
const ParentLayerRect& aClippedCompositionBounds) const {
RecursiveMutexAutoLock lock(mRecursiveMutex);
@ -4505,26 +4433,6 @@ void AsyncPanZoomController::FlushActiveCheckerboardReport() {
UpdateCheckerboardEvent(lock, 0);
}
bool AsyncPanZoomController::IsCurrentlyCheckerboarding() const {
CSSRect painted;
{ // scope lock
RecursiveMutexAutoLock lock(mRecursiveMutex);
painted = mLastContentPaintMetrics.GetDisplayPort() +
mLastContentPaintMetrics.GetScrollOffset();
}
painted.Inflate(CSSMargin::FromAppUnits(
nsMargin(1, 1, 1, 1))); // fuzz for rounding error
CSSRect visible = GetRecursivelyVisibleRect();
if (visible.IsEmpty() || painted.Contains(visible)) {
return false;
}
APZC_LOG_FM(Metrics(),
"%p is currently checkerboarding (painted %s visible %s)", this,
Stringify(painted).c_str(), Stringify(visible).c_str());
return true;
}
void AsyncPanZoomController::NotifyLayersUpdated(
const ScrollMetadata& aScrollMetadata, bool aIsFirstPaint,
bool aThisLayerTreeUpdated) {

View File

@ -333,14 +333,6 @@ class AsyncPanZoomController {
*/
void FlushActiveCheckerboardReport();
/**
* Returns whether or not the APZC is currently in a state of checkerboarding.
* This is a simple computation based on the last-painted content and whether
* the async transform has pushed it so far that it doesn't fully contain the
* composition bounds.
*/
bool IsCurrentlyCheckerboarding() const;
/**
* Recalculates the displayport. Ideally, this should paint an area bigger
* than the composite-to dimensions so that when you scroll down, you don't
@ -1220,25 +1212,6 @@ class AsyncPanZoomController {
* CSS pixels. The caller must have acquired the mRecursiveMutex lock.
*/
CSSRect GetVisibleRect(const RecursiveMutexAutoLock& aProofOfLock) const;
/**
* This returns the composition bounds of this APZC, but accounting for
* ancestor state. It's possible to have a scrollable frame with giant
* composition bounds nested inside a scrollable frame with smaller
* composition bounds, or even scrolled out of view entirely by an
* ancestor scrollable frame. This function accounts for those possibilities,
* by walking up to the root of the tree and clipping the composition bounds
* needed by the state of ancestor scrollframes. The returned value is
* in the same coordinate space as the composition bounds, and is guaranteed
* to be contained by the composition bounds.
*/
ParentLayerRect RecursivelyClipCompBounds(
const ParentLayerRect& aChildCompBounds) const;
/**
* Similar to GetVisibleRect, but this accounts for ancestor APZC's
* composition bounds as well. Conceptually this is the intersection of
* GetVisibleRect() with RecursivelyClipCompBounds().
*/
CSSRect GetRecursivelyVisibleRect() const;
private:
friend class AutoApplyAsyncTestAttributes;