Skip to content

Commit

Permalink
Bug 1882358 Part 2: Make WebRenderLayerManager track widget size to d…
Browse files Browse the repository at this point in the history
…etect resizes. r=nical

This changes the resize check to an objective standard of whether or not
the widget has resized, rather than asking the widget if it is in the
process of resizing.

Differential Revision: https://phabricator.services.mozilla.com/D202869
  • Loading branch information
bradwerth committed Mar 28, 2024
1 parent 413dfbd commit 3904945
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
25 changes: 16 additions & 9 deletions gfx/layers/wr/WebRenderLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ bool WebRenderLayerManager::Initialize(
}

mWrChild = static_cast<WebRenderBridgeChild*>(bridge);
mHasFlushedThisChild = false;

TextureFactoryIdentifier textureFactoryIdentifier;
wr::MaybeIdNamespace idNamespace;
Expand Down Expand Up @@ -694,24 +695,30 @@ void WebRenderLayerManager::FlushRendering(wr::RenderReasons aReasons) {
}
MOZ_ASSERT(mWidget);

// If value of IsResizingNativeWidget() is nothing, we assume that resizing
// might happen.
bool resizing = mWidget && mWidget->IsResizingNativeWidget().valueOr(true);
// If widget bounds size is different from the last flush, consider
// this to be a resize. It's important to use GetClientSize here,
// because that has extra plumbing to support initial display cases
// where the widget doesn't yet have real bounds.
LayoutDeviceIntSize widgetSize = mWidget->GetClientSize();
bool resizing = widgetSize != mFlushWidgetSize;
mFlushWidgetSize = widgetSize;

if (resizing) {
aReasons = aReasons | wr::RenderReasons::RESIZE;
}

// Limit async FlushRendering to !resizing and Win DComp.
// XXX relax the limitation
if (WrBridge()->GetCompositorUseDComp() && !resizing) {
cBridge->SendFlushRenderingAsync(aReasons);
} else if (mWidget->SynchronouslyRepaintOnResize() ||
StaticPrefs::layers_force_synchronous_resize()) {
// Check for the conditions where we we force a sync flush. The first
// flush for this child should always be sync. Resizes should be
// sometimes be sync. Everything else can be async.
if (!mHasFlushedThisChild ||
(resizing && (mWidget->SynchronouslyRepaintOnResize() ||
StaticPrefs::layers_force_synchronous_resize()))) {
cBridge->SendFlushRendering(aReasons);
} else {
cBridge->SendFlushRenderingAsync(aReasons);
}

mHasFlushedThisChild = true;
}

void WebRenderLayerManager::WaitOnTransactionProcessed() {
Expand Down
3 changes: 3 additions & 0 deletions gfx/layers/wr/WebRenderLayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class WebRenderLayerManager final : public WindowRenderer {
nsIWidget* MOZ_NON_OWNING_REF mWidget;

RefPtr<WebRenderBridgeChild> mWrChild;
bool mHasFlushedThisChild;

RefPtr<TransactionIdAllocator> mTransactionIdAllocator;
TransactionId mLatestTransactionId;
Expand Down Expand Up @@ -273,6 +274,8 @@ class WebRenderLayerManager final : public WindowRenderer {
UniquePtr<wr::DisplayListBuilder> mDLBuilder;

ScrollUpdatesMap mPendingScrollUpdates;

LayoutDeviceIntSize mFlushWidgetSize;
};

} // namespace layers
Expand Down

0 comments on commit 3904945

Please sign in to comment.