Commit b3f900ac authored by Kartikaya Gupta's avatar Kartikaya Gupta
Browse files

Bug 1389138 - Introduce a variant type to allow unifying the clip and scroll ids. r=mstange

This allows us to keep a single stack where we track both clip ids and
scroll ids with the correct interleaving order that they were pushed in.

MozReview-Commit-ID: DHHfR8JnnBw

--HG--
extra : rebase_source : 1eff7698ecc724b5457bdf67a6c4a70605038184
parent 1be666ff
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ ScrollingLayersHelper::ScrollingLayersHelper(WebRenderLayer* aLayer,
  : mLayer(aLayer)
  , mBuilder(&aBuilder)
  , mPushedLayerLocalClip(false)
  , mClipsPushed(0)
{
  if (!mLayer->WrManager()->AsyncPanZoomEnabled()) {
    // If APZ is disabled then we don't need to push the scrolling clips. We
@@ -93,7 +92,6 @@ ScrollingLayersHelper::ScrollingLayersHelper(nsDisplayItem* aItem,
  : mLayer(nullptr)
  , mBuilder(&aBuilder)
  , mPushedLayerLocalClip(false)
  , mClipsPushed(0)
{
  DefineAndPushChain(aItem->GetClipChain(), aBuilder, aStackingContext,
      aItem->Frame()->PresContext()->AppUnitsPerDevPixel(), aCache);
@@ -138,7 +136,7 @@ ScrollingLayersHelper::DefineAndPushChain(const DisplayItemClipChain* aChain,
  // Finally, push the clip onto the WR stack
  MOZ_ASSERT(clipId);
  aBuilder.PushClip(clipId.value());
  mClipsPushed++;
  mPushedClips.push_back(wr::ScrollOrClipId(clipId.value()));
}

bool
@@ -213,10 +211,12 @@ ScrollingLayersHelper::PushLayerClip(const LayerClip& aClip,
ScrollingLayersHelper::~ScrollingLayersHelper()
{
  if (!mLayer) {
    // For layers-free mode
    while (mClipsPushed > 0) {
    // For layers-free mode.
    while (!mPushedClips.empty()) {
      wr::ScrollOrClipId id = mPushedClips.back();
      MOZ_ASSERT(id.is<wr::WrClipId>());
      mBuilder->PopClip();
      mClipsPushed--;
      mPushedClips.pop_back();
    }
    return;
  }
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ private:
  WebRenderLayer* mLayer;
  wr::DisplayListBuilder* mBuilder;
  bool mPushedLayerLocalClip;
  int mClipsPushed;
  std::vector<wr::ScrollOrClipId> mPushedClips;
};

} // namespace layers
+4 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#ifndef GFX_WEBRENDERTYPES_H
#define GFX_WEBRENDERTYPES_H

#include "FrameMetrics.h"
#include "mozilla/webrender/webrender_ffi.h"
#include "mozilla/Maybe.h"
#include "mozilla/gfx/Matrix.h"
@@ -14,6 +15,7 @@
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/PodOperations.h"
#include "mozilla/Range.h"
#include "mozilla/Variant.h"
#include "Units.h"
#include "RoundedRect.h"
#include "nsStyleConsts.h"
@@ -662,6 +664,8 @@ struct WrClipId {
  }
};

typedef Variant<layers::FrameMetrics::ViewID, WrClipId> ScrollOrClipId;

} // namespace wr
} // namespace mozilla