Commit efa40c64 authored by Jeff Muizelaar's avatar Jeff Muizelaar
Browse files

Bug 1728246. Calculate opaqueness on demand instead of in ComputeVisibility. r=mattwoodrow

This lets us remove ComputeVisibility()

Differential Revision: https://phabricator.services.mozilla.com/D124106
parent 3401c03f
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -2304,7 +2304,6 @@ bool nsDisplayList::ComputeVisibilityForSublist(
    AppendToBottom(item);
  }

  mIsOpaque = !aVisibleRegion->Intersects(aListVisibleBounds);
  return anyVisible;
}

@@ -3076,21 +3075,9 @@ nsRect nsDisplayContainer::GetComponentAlphaBounds(
static nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
                                nsDisplayList* aList,
                                const nsRect& aListBounds) {
  if (aList->IsOpaque()) {
    // Everything within list bounds that's visible is opaque. This is an
    // optimization to avoid calculating the opaque region.
    return aListBounds;
  }

  if (aBuilder->HitTestIsForVisibility()) {
    // If we care about an accurate opaque region, iterate the display list
    // and build up a region of opaque bounds.
  return aList->GetOpaqueRegion(aBuilder);
}

  return nsRegion();
}

nsRegion nsDisplayContainer::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
                                             bool* aSnap) const {
  return ::mozilla::GetOpaqueRegion(aBuilder, GetChildren(),
+1 −18
Original line number Diff line number Diff line
@@ -3246,7 +3246,7 @@ class nsDisplayList {
   * Create an empty list.
   */
  nsDisplayList()
      : mLength(0), mIsOpaque(false), mForceTransparentSurface(false) {
      : mLength(0), mForceTransparentSurface(false) {
    mTop = &mSentinel;
    mSentinel.mAbove = nullptr;
  }
@@ -3256,7 +3256,6 @@ class nsDisplayList {
  }

  nsDisplayList(nsDisplayList&& aOther) {
    mIsOpaque = aOther.mIsOpaque;
    mForceTransparentSurface = aOther.mForceTransparentSurface;

    if (aOther.mSentinel.mAbove) {
@@ -3278,7 +3277,6 @@ class nsDisplayList {
        mTop = &mSentinel;
        mLength = 0;
      }
      mIsOpaque = aOther.mIsOpaque;
      mForceTransparentSurface = aOther.mForceTransparentSurface;
    }
    return *this;
@@ -3465,8 +3463,6 @@ class nsDisplayList {
   * This is also a good place to put ComputeVisibility-related logic
   * that must be applied to every display item. In particular, this
   * sets mVisibleRect on each display item.
   * This sets mIsOpaque if the entire visible area of this list has
   * been removed from aVisibleRegion when we return.
   * This does not remove any items from the list, so we can recompute
   * visiblity with different regions later (see
   * FrameLayerBuilder::DrawPaintedLayer).
@@ -3493,12 +3489,6 @@ class nsDisplayList {
  bool ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
                                nsRegion* aVisibleRegion);

  /**
   * Returns true if the visible region output from ComputeVisiblity was
   * empty, i.e. everything visible in this list is opaque.
   */
  bool IsOpaque() const { return mIsOpaque; }

  /**
   * Returns true if any display item requires the surface to be transparent.
   */
@@ -3604,12 +3594,9 @@ class nsDisplayList {
   */
  nsRect GetBuildingRect() const;

  void SetIsOpaque() { mIsOpaque = true; }

  void SetNeedsTransparentSurface() { mForceTransparentSurface = true; }

  void RestoreState() {
    mIsOpaque = false;
    mForceTransparentSurface = false;
  }

@@ -3619,10 +3606,6 @@ class nsDisplayList {

  uint32_t mLength;

  // This is set to true by FrameLayerBuilder if the final visible region
  // is empty (i.e. everything that was visible is covered by some
  // opaque content in this list).
  bool mIsOpaque;
  // This is set to true by FrameLayerBuilder if any display item in this
  // list needs to force the surface containing this list to be transparent.
  bool mForceTransparentSurface;