summaryrefslogtreecommitdiffstats
path: root/gfx/layers/RemoteTextureMap.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /gfx/layers/RemoteTextureMap.cpp
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/RemoteTextureMap.cpp')
-rw-r--r--gfx/layers/RemoteTextureMap.cpp100
1 files changed, 53 insertions, 47 deletions
diff --git a/gfx/layers/RemoteTextureMap.cpp b/gfx/layers/RemoteTextureMap.cpp
index fa0cfd33f5..3fe3b13deb 100644
--- a/gfx/layers/RemoteTextureMap.cpp
+++ b/gfx/layers/RemoteTextureMap.cpp
@@ -369,7 +369,11 @@ void RemoteTextureMap::PushTexture(
aTextureId, aTextureHost, std::move(aTextureData),
std::move(aResourceWrapper));
- MOZ_ASSERT(owner->mLatestTextureId < aTextureId);
+ MOZ_ASSERT(owner->mLatestPushedTextureId < aTextureId);
+ if (owner->mLatestPushedTextureId < aTextureId) {
+ owner->mLatestPushedTextureId = aTextureId;
+ }
+ MOZ_ASSERT(owner->mLatestUsingTextureId < aTextureId);
owner->mWaitingTextureDataHolders.push_back(std::move(textureData));
@@ -898,9 +902,9 @@ void RemoteTextureMap::UpdateTexture(const MonitorAutoLock& aProofOfLock,
const RemoteTextureId aTextureId) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MOZ_ASSERT(aOwner);
- MOZ_ASSERT(aTextureId >= aOwner->mLatestTextureId);
+ MOZ_ASSERT(aTextureId >= aOwner->mLatestUsingTextureId);
- if (aTextureId == aOwner->mLatestTextureId) {
+ if (aTextureId == aOwner->mLatestUsingTextureId) {
// No need to update texture.
return;
}
@@ -913,7 +917,7 @@ void RemoteTextureMap::UpdateTexture(const MonitorAutoLock& aProofOfLock,
}
MOZ_RELEASE_ASSERT(front->mTextureHost);
aOwner->mLatestTextureHost = front->mTextureHost;
- aOwner->mLatestTextureId = front->mTextureId;
+ aOwner->mLatestUsingTextureId = front->mTextureId;
UniquePtr<TextureDataHolder> holder = std::move(front);
aOwner->mWaitingTextureDataHolders.pop_front();
@@ -962,10 +966,42 @@ void RemoteTextureMap::GetAllRenderingReadyCallbacks(
MOZ_ASSERT(aOwner->mRenderingReadyCallbackHolders.empty());
}
+bool RemoteTextureMap::WaitForRemoteTextureOwner(
+ RemoteTextureHostWrapper* aTextureHostWrapper) {
+ MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
+ MOZ_ASSERT(aTextureHostWrapper);
+
+ const auto& ownerId = aTextureHostWrapper->mOwnerId;
+ const auto& forPid = aTextureHostWrapper->mForPid;
+
+ MonitorAutoLock lock(mMonitor);
+
+ auto* owner = GetTextureOwner(lock, ownerId, forPid);
+ // If there is no texture owner yet, then we might need to wait for one to
+ // be created, if allowed. If so, we must also wait for an initial texture
+ // host to be created so we can use it.
+ if (!owner || (!owner->mLatestTextureHost &&
+ owner->mWaitingTextureDataHolders.empty())) {
+ const TimeDuration timeout = TimeDuration::FromMilliseconds(10000);
+ while (!owner || (!owner->mLatestTextureHost &&
+ owner->mWaitingTextureDataHolders.empty())) {
+ if (owner && (owner->mIsContextLost || owner->mDeferUnregister)) {
+ // If the context was lost, no further updates are expected.
+ return false;
+ }
+ CVStatus status = mMonitor.Wait(timeout);
+ if (status == CVStatus::Timeout) {
+ return false;
+ }
+ owner = GetTextureOwner(lock, ownerId, forPid);
+ }
+ }
+ return true;
+}
+
bool RemoteTextureMap::GetRemoteTexture(
RemoteTextureHostWrapper* aTextureHostWrapper,
- std::function<void(const RemoteTextureInfo&)>&& aReadyCallback,
- bool aWaitForRemoteTextureOwner) {
+ std::function<void(const RemoteTextureInfo&)>&& aReadyCallback) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MOZ_ASSERT(aTextureHostWrapper);
@@ -983,27 +1019,8 @@ bool RemoteTextureMap::GetRemoteTexture(
MonitorAutoLock lock(mMonitor);
auto* owner = GetTextureOwner(lock, ownerId, forPid);
- // If there is no texture owner yet, then we might need to wait for one to
- // be created, if allowed. If so, we must also wait for an initial texture
- // host to be created so we can use it.
- if (!owner || (aWaitForRemoteTextureOwner && !owner->mLatestTextureHost &&
- owner->mWaitingTextureDataHolders.empty())) {
- if (!aWaitForRemoteTextureOwner) {
- return false;
- }
- const TimeDuration timeout = TimeDuration::FromMilliseconds(10000);
- while (!owner || (!owner->mLatestTextureHost &&
- owner->mWaitingTextureDataHolders.empty())) {
- if (owner && (owner->mIsContextLost || owner->mDeferUnregister)) {
- // If the context was lost, no further updates are expected.
- return false;
- }
- CVStatus status = mMonitor.Wait(timeout);
- if (status == CVStatus::Timeout) {
- return false;
- }
- owner = GetTextureOwner(lock, ownerId, forPid);
- }
+ if (!owner) {
+ return false;
}
UpdateTexture(lock, owner, textureId);
@@ -1014,7 +1031,7 @@ bool RemoteTextureMap::GetRemoteTexture(
return false;
}
- if (textureId == owner->mLatestTextureId) {
+ if (textureId == owner->mLatestUsingTextureId) {
MOZ_ASSERT(owner->mLatestTextureHost);
MOZ_ASSERT(owner->mLatestTextureHost->GetSize() == size);
if (owner->mLatestTextureHost->GetSize() != size) {
@@ -1034,7 +1051,7 @@ bool RemoteTextureMap::GetRemoteTexture(
}
// Update mRemoteTextureHost
- if (textureId == owner->mLatestTextureId) {
+ if (textureId == owner->mLatestUsingTextureId) {
const auto key = std::pair(forPid, textureId);
auto it = mRemoteTextureHostWrapperHolders.find(key);
if (it != mRemoteTextureHostWrapperHolders.end() &&
@@ -1195,16 +1212,9 @@ bool RemoteTextureMap::CheckRemoteTextureReady(
return true;
}
- if (it->second->mRemoteTextureHost) {
+ if (owner->mLatestPushedTextureId >= aInfo.mTextureId) {
return true;
}
- MOZ_ASSERT(!it->second->mRemoteTextureHost);
-
- // Check if RemoteTextureId is as expected.
- if (!owner->mRenderingReadyCallbackHolders.empty()) {
- auto& front = owner->mRenderingReadyCallbackHolders.front();
- MOZ_RELEASE_ASSERT(aInfo.mTextureId >= front->mTextureId);
- }
auto callbackHolder = MakeUnique<RenderingReadyCallbackHolder>(
aInfo.mTextureId, std::move(aCallback));
@@ -1234,9 +1244,8 @@ bool RemoteTextureMap::WaitRemoteTextureReady(const RemoteTextureInfo& aInfo) {
}
const TimeDuration timeout = TimeDuration::FromMilliseconds(1000);
- TextureHost* remoteTexture = it->second->mRemoteTextureHost;
- while (!remoteTexture) {
+ while (owner->mLatestPushedTextureId < aInfo.mTextureId) {
CVStatus status = mMonitor.Wait(timeout);
if (status == CVStatus::Timeout) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
@@ -1251,14 +1260,11 @@ bool RemoteTextureMap::WaitRemoteTextureReady(const RemoteTextureInfo& aInfo) {
return false;
}
- remoteTexture = it->second->mRemoteTextureHost;
- if (!remoteTexture) {
- auto* owner = GetTextureOwner(lock, aInfo.mOwnerId, aInfo.mForPid);
- // When owner is alreay unregistered, remote texture will not be pushed.
- if (!owner || owner->mIsContextLost) {
- // This could happen with IPC abnormal shutdown
- return false;
- }
+ auto* owner = GetTextureOwner(lock, aInfo.mOwnerId, aInfo.mForPid);
+ // When owner is alreay unregistered, remote texture will not be pushed.
+ if (!owner || owner->mIsContextLost) {
+ // This could happen with IPC abnormal shutdown
+ return false;
}
}