Commit fbef6fe2 authored by Matt Woodrow's avatar Matt Woodrow
Browse files

Bug 1728050 - Move opacity flattening to be part of WR DL serialization. r=miko

parent 10e5da36
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -180,6 +180,12 @@ Maybe<uint16_t> DisplayItemCache::CanReuseItem(
    return Nothing();
  }

  if (mSuppressed) {
    slot.mOccupied = false;
    slotIndex = Nothing();
    return Nothing();
  }

  if (!(aSpaceAndClip == slot.mSpaceAndClip)) {
    // Spatial id and clip id can change between display lists, if items that
    // generate them change their order.
+3 −3
Original line number Diff line number Diff line
@@ -100,9 +100,9 @@ class DisplayItemCache final {
  /**
   * Suppress display item caching. This doesn't clear any existing cached
   * items or change the underlying capacity, it just makes IsEnabled() return
   * false. It is not meant to be flipped in the middle of a display list build,
   * but rather set before the display list build starts to suppress use of the
   * cache for that display list build.
   * false.
   * It will also make CanReuseItem return false for the duration of the
   * suppression.
   */
  bool SetSuppressed(bool aSuppressed) {
    if (aSuppressed == mSuppressed) {
+14 −7
Original line number Diff line number Diff line
@@ -1694,7 +1694,8 @@ void WebRenderCommandBuilder::CreateWebRenderCommands(
void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(
    nsDisplayList* aDisplayList, nsDisplayItem* aWrappingItem,
    nsDisplayListBuilder* aDisplayListBuilder, const StackingContextHelper& aSc,
    wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources) {
    wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources,
    bool aNewClipList) {
  if (mDoGrouping) {
    MOZ_RELEASE_ASSERT(
        aWrappingItem,
@@ -1715,7 +1716,9 @@ void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(
  }

  mDumpIndent++;
  if (aNewClipList) {
    mClipManager.BeginList(aSc);
  }

  bool apzEnabled = mManager->AsyncPanZoomEnabled();

@@ -1912,8 +1915,10 @@ void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(
  }

  mDumpIndent--;
  if (aNewClipList) {
    mClipManager.EndList(aSc);
  }
}

void WebRenderCommandBuilder::PushOverrideForASR(
    const ActiveScrolledRoot* aASR, const wr::WrSpatialId& aSpatialId) {
@@ -2484,6 +2489,8 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(

  nsPoint maskOffset = aMaskItem->ToReferenceFrame() - bounds.TopLeft();

  bool shouldHandleOpacity = aBuilder.GetInheritedOpacity() != 1.0f;

  nsRect dirtyRect;
  // If this mask item is being painted for the first time, some members of
  // WebRenderMaskData are still default initialized. This is intentional.
@@ -2491,7 +2498,7 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
      !itemRect.IsEqualInterior(maskData->mItemRect) ||
      !(aMaskItem->Frame()->StyleSVGReset()->mMask == maskData->mMaskStyle) ||
      maskOffset != maskData->mMaskOffset || !sameScale ||
      aMaskItem->ShouldHandleOpacity() != maskData->mShouldHandleOpacity) {
      shouldHandleOpacity != maskData->mShouldHandleOpacity) {
    IntSize size = itemRect.Size().ToUnknownSize();

    if (!Factory::AllowedSurfaceSize(size)) {
@@ -2535,8 +2542,8 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
                           .PreScale(scale.width, scale.height));

    bool maskPainted = false;
    bool maskIsComplete =
        aMaskItem->PaintMask(aDisplayListBuilder, context, &maskPainted);
    bool maskIsComplete = aMaskItem->PaintMask(
        aDisplayListBuilder, context, shouldHandleOpacity, &maskPainted);
    if (!maskPainted) {
      return Nothing();
    }
@@ -2587,7 +2594,7 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
      maskData->mMaskOffset = maskOffset;
      maskData->mScale = scale;
      maskData->mMaskStyle = aMaskItem->Frame()->StyleSVGReset()->mMask;
      maskData->mShouldHandleOpacity = aMaskItem->ShouldHandleOpacity();
      maskData->mShouldHandleOpacity = shouldHandleOpacity;
    }
  }

+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class WebRenderCommandBuilder final {
      nsDisplayList* aDisplayList, nsDisplayItem* aWrappingItem,
      nsDisplayListBuilder* aDisplayListBuilder,
      const StackingContextHelper& aSc, wr::DisplayListBuilder& aBuilder,
      wr::IpcResourceUpdateQueue& aResources);
      wr::IpcResourceUpdateQueue& aResources, bool aNewClipList = true);

  // aWrappingItem has to be non-null.
  void DoGroupingForDisplayList(nsDisplayList* aDisplayList,
+12 −0
Original line number Diff line number Diff line
@@ -684,6 +684,17 @@ class DisplayListBuilder final {
    mClipChainLeaf = aClipRect;
  }

  // Used for opacity flattening. When we flatten away an opacity item,
  // we push the opacity value onto the builder.
  // Descendant items should pull the inherited opacity during
  // their CreateWebRenderCommands implementation. This can only happen if all
  // descendant items reported supporting this functionality, via
  // nsDisplayItem::CanApplyOpacity.
  float GetInheritedOpacity() { return mInheritedOpacity; }
  void SetInheritedOpacity(float aOpacity) { mInheritedOpacity = aOpacity; }

  layers::DisplayItemCache* GetDisplayItemCache() { return mDisplayItemCache; }

  // A chain of RAII objects, each holding a (ASR, ViewID, SideBits) tuple of
  // data. The topmost object is pointed to by the mActiveFixedPosTracker
  // pointer in the wr::DisplayListBuilder.
@@ -750,6 +761,7 @@ class DisplayListBuilder final {

  layers::DisplayItemCache* mDisplayItemCache;
  Maybe<uint16_t> mCurrentCacheSlot;
  float mInheritedOpacity = 1.0f;

  friend class WebRenderAPI;
  friend class SpaceAndClipChainHelper;
Loading