Commit 39dd5091 authored by Ryan Hunt's avatar Ryan Hunt
Browse files

Bug 1519546, part 7 - Gather EffectsInfo for remote browsers in a paint and...

Bug 1519546, part 7 - Gather EffectsInfo for remote browsers in a paint and apply them. r=mattwoodrow

WebRender support will be finished in the following commit.

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

--HG--
extra : rebase_source : d4a36a8ff2d2477cbf22e8cb624142709e931b9c
extra : source : 79be6c27e0f9e262b75723c120786e2256ee4700
parent f18f865d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -3541,6 +3541,17 @@ void PrintHitTestInfoStats(nsDisplayList& aList) {
}
#endif

// Apply a batch of effects updates generated during a paint to their
// respective remote browsers.
static void ApplyEffectsUpdates(
    const nsDataHashtable<nsPtrHashKey<RemoteBrowser>, EffectsInfo>& aUpdates) {
  for (auto iter = aUpdates.ConstIter(); !iter.Done(); iter.Next()) {
    auto browser = iter.Key();
    auto update = iter.Data();
    browser->UpdateEffects(update);
  }
}

nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext,
                                   nsIFrame* aFrame,
                                   const nsRegion& aDirtyRegion,
@@ -4089,6 +4100,13 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext,
    builder.SetDisablePartialUpdates(true);
  }

  // Apply effects updates if we were actually painting
  if (isForPainting) {
    if (nsIWidget* widget = aFrame->GetNearestWidget()) {
      ApplyEffectsUpdates(builder.GetEffectUpdates());
    }
  }

  builder.Check();

  {
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderScrollData.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/dom/EffectsInfo.h"

using namespace mozilla::dom;
using namespace mozilla::gfx;
@@ -217,6 +218,14 @@ already_AddRefed<Layer> nsDisplayRemote::BuildLayer(
    return nullptr;
  }

  if (RefPtr<RemoteBrowser> remoteBrowser =
          GetFrameLoader()->GetRemoteBrowser()) {
    // Generate an effects update notifying the browser it is visible
    aBuilder->AddEffectUpdate(remoteBrowser, EffectsInfo::FullyVisible());
    // FrameLayerBuilder will take care of notifying the browser when it is no
    // longer visible
  }

  RefPtr<Layer> layer =
      aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this);

+35 −2
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
#include "mozilla/LookAndFeel.h"
#include "mozilla/Maybe.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/EffectsInfo.h"
#include "mozilla/dom/RemoteBrowser.h"
#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
#include "mozilla/gfx/Matrix.h"
#include "ActiveLayerTracker.h"
@@ -34,6 +36,7 @@
#include "nsDocShell.h"
#include "nsIScrollableFrame.h"
#include "nsImageFrame.h"
#include "nsSubDocumentFrame.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsPrintfCString.h"
@@ -387,7 +390,7 @@ DisplayItemData::~DisplayItemData() {
  }
}

void DisplayItemData::ClearAnimationCompositorState() {
void DisplayItemData::NotifyRemoved() {
  if (mDisplayItemKey > static_cast<uint8_t>(DisplayItemType::TYPE_MAX)) {
    // This is sort of a hack. The display item key has higher bits set, which
    // means that it is not the only display item for the frame.
@@ -397,6 +400,24 @@ void DisplayItemData::ClearAnimationCompositorState() {

  const DisplayItemType type = GetDisplayItemTypeFromKey(mDisplayItemKey);

  if (type == DisplayItemType::TYPE_REMOTE) {
    // TYPE_REMOTE doesn't support merging, so access it directly
    MOZ_ASSERT(mFrameList.Length() == 1);
    if (mFrameList.Length() != 1) {
      return;
    }

    // This is a remote browser that is going away, notify it that it is now
    // hidden
    nsIFrame* frame = mFrameList[0];
    nsSubDocumentFrame* subdoc = static_cast<nsSubDocumentFrame*>(frame);
    nsFrameLoader* frameLoader = subdoc->FrameLoader();
    if (frameLoader && frameLoader->GetRemoteBrowser()) {
      frameLoader->GetRemoteBrowser()->UpdateEffects(
          mozilla::dom::EffectsInfo::FullyHidden());
    }
  }

  // FIXME: Bug 1530857: Add background_color.
  if (type != DisplayItemType::TYPE_TRANSFORM &&
      type != DisplayItemType::TYPE_OPACITY) {
@@ -2238,6 +2259,18 @@ void FrameLayerBuilder::RemoveFrameFromLayerManager(
    data->mParent->mDisplayItems.pop_back();
  }

  if (aFrame->IsSubDocumentFrame()) {
    const nsSubDocumentFrame* subdoc =
        static_cast<const nsSubDocumentFrame*>(aFrame);
    nsFrameLoader* frameLoader = subdoc->FrameLoader();
    if (frameLoader && frameLoader->GetRemoteBrowser()) {
      // This is a remote browser that is going away, notify it that it is now
      // hidden
      frameLoader->GetRemoteBrowser()->UpdateEffects(
          mozilla::dom::EffectsInfo::FullyHidden());
    }
  }

  arrayCopy.Clear();
  sDestroyedFrame = nullptr;
}
@@ -2290,7 +2323,7 @@ void FrameLayerBuilder::WillEndTransaction() {
            GetLastPaintOffset(t), did->mTransform);
      }

      did->ClearAnimationCompositorState();
      did->NotifyRemoved();

      // Remove this item. Swapping it with the last element first is
      // quicker than erasing from the middle.
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ class DisplayItemData final {
  nsDisplayItemGeometry* GetGeometry() const { return mGeometry.get(); }
  const DisplayItemClip& GetClip() const { return mClip; }
  void Invalidate() { mIsInvalid = true; }
  void ClearAnimationCompositorState();
  void NotifyRemoved();
  void SetItem(nsPaintedDisplayItem* aItem) { mItem = aItem; }
  nsPaintedDisplayItem* GetItem() const { return mItem; }
  nsIFrame* FirstFrame() const { return mFrameList[0]; }
+1 −0
Original line number Diff line number Diff line
@@ -1231,6 +1231,7 @@ void nsDisplayListBuilder::EndFrame() {
  mFrameToAnimatedGeometryRootMap.Clear();
  mAGRBudgetSet.Clear();
  mActiveScrolledRoots.Clear();
  mEffectsUpdates.Clear();
  FreeClipChains();
  FreeTemporaryItems();
  nsCSSRendering::EndFrameTreesLocked();
Loading