Bug 1776530 - Rename APZUpdater::UsingWebRenderUpdaterThread() to IsConnectedToWebRender(). r=tnikkel

The earlier name dates back to a time when we could use WebRender
but not necessarily use a WebRender thread as the updater thread.

Also add a comment to list the remaining situatins in which this
function can return false.

Differential Revision: https://phabricator.services.mozilla.com/D150308
This commit is contained in:
Botond Ballo 2022-06-25 04:33:51 +00:00
parent 2e44c5c642
commit 0fcaeddf43
3 changed files with 17 additions and 12 deletions

View File

@ -39,7 +39,7 @@ class APZUpdater {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZUpdater)
public:
APZUpdater(const RefPtr<APZCTreeManager>& aApz, bool aIsUsingWebRender);
APZUpdater(const RefPtr<APZCTreeManager>& aApz, bool aConnectedToWebRender);
bool HasTreeManager(const RefPtr<APZCTreeManager>& aApz);
void SetWebRenderWindowId(const wr::WindowId& aWindowId);
@ -141,7 +141,12 @@ class APZUpdater {
protected:
virtual ~APZUpdater();
bool UsingWebRenderUpdaterThread() const;
// Return true if the APZUpdater is connected to WebRender and is
// using a WebRender scene builder thread as its updater thread.
// This is only false during GTests, and a shutdown codepath during
// which we create a dummy APZUpdater.
bool IsConnectedToWebRender() const;
static already_AddRefed<APZUpdater> GetUpdater(
const wr::WrWindowId& aWindowId);
@ -150,7 +155,7 @@ class APZUpdater {
private:
RefPtr<APZCTreeManager> mApz;
bool mDestroyed;
bool mIsUsingWebRender;
bool mConnectedToWebRender;
// Map from layers id to WebRenderScrollData. This can only be touched on
// the updater thread.

View File

@ -24,10 +24,10 @@ StaticAutoPtr<std::unordered_map<uint64_t, APZUpdater*>>
APZUpdater::sWindowIdMap;
APZUpdater::APZUpdater(const RefPtr<APZCTreeManager>& aApz,
bool aIsUsingWebRender)
bool aConnectedToWebRender)
: mApz(aApz),
mDestroyed(false),
mIsUsingWebRender(aIsUsingWebRender),
mConnectedToWebRender(aConnectedToWebRender),
mThreadIdLock("APZUpdater::ThreadIdLock"),
mQueueLock("APZUpdater::QueueLock") {
MOZ_ASSERT(aApz);
@ -317,7 +317,7 @@ void APZUpdater::RunOnUpdaterThread(LayersId aLayersId,
already_AddRefed<Runnable> aTask) {
RefPtr<Runnable> task = aTask;
// In the scenario where UsingWebRenderUpdaterThread() is true, this function
// In the scenario where IsConnectedToWebRender() is true, this function
// might get called early (before mUpdaterThreadId is set). In that case
// IsUpdaterThread() will return false and we'll queue the task onto
// mUpdaterQueue. This is fine; the task is still guaranteed to run (barring
@ -329,7 +329,7 @@ void APZUpdater::RunOnUpdaterThread(LayersId aLayersId,
return;
}
if (UsingWebRenderUpdaterThread()) {
if (IsConnectedToWebRender()) {
// If the updater thread is a WebRender thread, and we're not on it
// right now, save the task in the queue. We will run tasks from the queue
// during the callback from the updater thread, which we trigger by the
@ -377,7 +377,7 @@ void APZUpdater::RunOnUpdaterThread(LayersId aLayersId,
}
bool APZUpdater::IsUpdaterThread() const {
if (UsingWebRenderUpdaterThread()) {
if (IsConnectedToWebRender()) {
// If the updater thread id isn't set yet then we cannot be running on the
// updater thread (because we will have the thread id before we run any
// C++ code on it, and this function is only ever invoked from C++ code),
@ -401,8 +401,8 @@ void APZUpdater::RunOnControllerThread(LayersId aLayersId,
std::move(task), nsIThread::DISPATCH_NORMAL));
}
bool APZUpdater::UsingWebRenderUpdaterThread() const {
return mIsUsingWebRender;
bool APZUpdater::IsConnectedToWebRender() const {
return mConnectedToWebRender;
}
/*static*/

View File

@ -76,9 +76,9 @@ ContentCompositorBridgeParent::AllocPAPZCTreeManagerParent(
// Note: we immediately call ClearTree since otherwise the APZCTM will
// retain a reference to itself, through the checkerboard observer.
LayersId dummyId{0};
const bool useWebRender = false;
const bool connectedToWebRender = false;
RefPtr<APZCTreeManager> temp = new APZCTreeManager(dummyId);
RefPtr<APZUpdater> tempUpdater = new APZUpdater(temp, useWebRender);
RefPtr<APZUpdater> tempUpdater = new APZUpdater(temp, connectedToWebRender);
tempUpdater->ClearTree(dummyId);
return new APZCTreeManagerParent(aLayersId, temp, tempUpdater);
}