Bug 1372912 - Make the clip id more strongly typed. r=jrmuizel,mrobinson

This patch is not really needed, but it avoids accidental conversion
between FrameMetrics::ViewID (which represents a scrolling clip) and a
uint64_t id for a non-scrolling clip.

MozReview-Commit-ID: BU7p4WNocXa

--HG--
extra : rebase_source : 0cf69ca0a7b716bd9ad5c3cef114a3b99ec00e1b
This commit is contained in:
Kartikaya Gupta 2017-06-15 09:41:46 -04:00
Родитель 9b82918f72
Коммит f910c3f66e
4 изменённых файлов: 19 добавлений и 10 удалений

Просмотреть файл

@ -84,7 +84,7 @@ ScrollingLayersHelper::ScrollingLayersHelper(WebRenderLayer* aLayer,
if (layer->GetIsFixedPosition()) {
FrameMetrics::ViewID fixedFor = layer->GetFixedPositionScrollContainerId();
Maybe<FrameMetrics::ViewID> scrollsWith = mBuilder->ParentScrollIdFor(fixedFor);
Maybe<uint64_t> clipId = mBuilder->TopmostClipId();
Maybe<wr::WrClipId> clipId = mBuilder->TopmostClipId();
// Default to 0 if there is no ancestor, because 0 refers to the root scrollframe.
mBuilder->PushClipAndScrollInfo(scrollsWith.valueOr(0), clipId.ptrOr(nullptr));
}

Просмотреть файл

@ -587,13 +587,13 @@ DisplayListBuilder::PushClip(const WrRect& aClipRect,
WRDL_LOG("PushClip id=%" PRIu64 " r=%s m=%p b=%s\n", clip_id,
Stringify(aClipRect).c_str(), aMask,
aMask ? Stringify(aMask->rect).c_str() : "none");
mClipIdStack.push_back(clip_id);
mClipIdStack.push_back(WrClipId { clip_id });
}
void
DisplayListBuilder::PopClip()
{
WRDL_LOG("PopClip id=%" PRIu64 "\n", mClipIdStack.back());
WRDL_LOG("PopClip id=%" PRIu64 "\n", mClipIdStack.back().id);
mClipIdStack.pop_back();
wr_dp_pop_clip(mWrState);
}
@ -627,11 +627,12 @@ DisplayListBuilder::PopScrollLayer()
void
DisplayListBuilder::PushClipAndScrollInfo(const layers::FrameMetrics::ViewID& aScrollId,
const uint64_t* aClipId)
const WrClipId* aClipId)
{
WRDL_LOG("PushClipAndScroll s=%" PRIu64 " c=%s\n", aScrollId,
aClipId ? Stringify(*aClipId).c_str() : "none");
wr_dp_push_clip_and_scroll_info(mWrState, aScrollId, aClipId);
aClipId ? Stringify(aClipId->id).c_str() : "none");
wr_dp_push_clip_and_scroll_info(mWrState, aScrollId,
aClipId ? &(aClipId->id) : nullptr);
}
void
@ -891,7 +892,7 @@ DisplayListBuilder::PushClipRegion(const WrRect& aMain,
aMask);
}
Maybe<uint64_t>
Maybe<WrClipId>
DisplayListBuilder::TopmostClipId()
{
if (mClipIdStack.empty()) {

Просмотреть файл

@ -168,7 +168,7 @@ public:
void PopScrollLayer();
void PushClipAndScrollInfo(const layers::FrameMetrics::ViewID& aScrollId,
const uint64_t* aClipId);
const WrClipId* aClipId);
void PopClipAndScrollInfo();
void PushRect(const WrRect& aBounds,
@ -292,7 +292,7 @@ public:
// Returns the clip id that was most recently pushed with PushClip and that
// has not yet been popped with PopClip. Return Nothing() if the clip stack
// is empty.
Maybe<uint64_t> TopmostClipId();
Maybe<WrClipId> TopmostClipId();
// Returns the scroll id that was pushed just before the given scroll id.
// If the given scroll id is not in the stack of active scrolled layers, or if
// it is the rootmost scroll id (and therefore has no ancestor), this function
@ -308,7 +308,7 @@ protected:
// (by PushClip and PushScrollLayer, respectively) and are still active.
// This is helpful for knowing e.g. what the ancestor scroll id of a particular
// scroll id is, and doing other "queries" of current state.
std::vector<uint64_t> mClipIdStack;
std::vector<WrClipId> mClipIdStack;
std::vector<layers::FrameMetrics::ViewID> mScrollIdStack;
friend class WebRenderAPI;

Просмотреть файл

@ -584,6 +584,14 @@ static inline WrFilterOp ToWrFilterOp(const layers::CSSFilter& filter) {
};
}
// Corresponds to an "internal" webrender clip id. That is, a
// ClipId::Clip(x,pipeline_id) maps to a WrClipId{x}. We use a struct wrapper
// instead of a typedef so that this is a distinct type from FrameMetrics::ViewID
// and the compiler will catch accidental conversions between the two.
struct WrClipId {
uint64_t id;
};
} // namespace wr
} // namespace mozilla