mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in gfx. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D104216
This commit is contained in:
parent
010633d2d1
commit
8df74b1582
@ -868,8 +868,10 @@ EGLSurface GLContextEGL::CreateWaylandBufferSurface(
|
||||
if (surface) {
|
||||
#ifdef MOZ_GTK_WAYLAND
|
||||
WaylandGLSurface* waylandData = new WaylandGLSurface(wlsurface, eglwindow);
|
||||
auto entry = sWaylandGLSurface.LookupForAdd(surface);
|
||||
entry.OrInsert([&waylandData]() { return waylandData; });
|
||||
// XXX This looks as if this should unconditionally insert. Otherwise,
|
||||
// waylandData would be leaked.
|
||||
sWaylandGLSurface.WithEntryHandle(
|
||||
surface, [&](auto&& entry) { entry.OrInsert(waylandData); });
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -835,29 +835,28 @@ TextureClient* SourceSurfaceImage::GetTextureClient(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto entry = mTextureClients.LookupForAdd(aKnowsCompositor->GetSerial());
|
||||
if (entry) {
|
||||
return entry.Data();
|
||||
}
|
||||
return mTextureClients.WithEntryHandle(
|
||||
aKnowsCompositor->GetSerial(), [&](auto&& entry) -> TextureClient* {
|
||||
if (entry) {
|
||||
return entry.Data().get();
|
||||
}
|
||||
|
||||
RefPtr<TextureClient> textureClient;
|
||||
RefPtr<SourceSurface> surface = GetAsSourceSurface();
|
||||
MOZ_ASSERT(surface);
|
||||
if (surface) {
|
||||
// gfx::BackendType::NONE means default to content backend
|
||||
textureClient = TextureClient::CreateFromSurface(
|
||||
aKnowsCompositor, surface, BackendSelector::Content, mTextureFlags,
|
||||
ALLOC_DEFAULT);
|
||||
}
|
||||
if (textureClient) {
|
||||
textureClient->SyncWithObject(aKnowsCompositor->GetSyncObject());
|
||||
entry.OrInsert([&textureClient]() { return textureClient; });
|
||||
return textureClient;
|
||||
}
|
||||
RefPtr<TextureClient> textureClient;
|
||||
RefPtr<SourceSurface> surface = GetAsSourceSurface();
|
||||
MOZ_ASSERT(surface);
|
||||
if (surface) {
|
||||
// gfx::BackendType::NONE means default to content backend
|
||||
textureClient = TextureClient::CreateFromSurface(
|
||||
aKnowsCompositor, surface, BackendSelector::Content,
|
||||
mTextureFlags, ALLOC_DEFAULT);
|
||||
}
|
||||
if (textureClient) {
|
||||
textureClient->SyncWithObject(aKnowsCompositor->GetSyncObject());
|
||||
return entry.Insert(std::move(textureClient)).get();
|
||||
}
|
||||
|
||||
// Remove the speculatively added entry.
|
||||
entry.OrRemove();
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
ImageContainer::ProducerID ImageContainer::AllocateProducerID() {
|
||||
|
@ -951,12 +951,13 @@ bool LayerTransactionParent::BindLayerToHandle(RefPtr<Layer> aLayer,
|
||||
if (!aHandle || !aLayer) {
|
||||
return false;
|
||||
}
|
||||
auto entry = mLayerMap.LookupForAdd(aHandle.Value());
|
||||
if (entry) {
|
||||
return false;
|
||||
}
|
||||
entry.OrInsert([&aLayer]() { return aLayer; });
|
||||
return true;
|
||||
return mLayerMap.WithEntryHandle(aHandle.Value(), [&](auto&& entry) {
|
||||
if (entry) {
|
||||
return false;
|
||||
}
|
||||
entry.Insert(std::move(aLayer));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
Layer* LayerTransactionParent::AsLayer(const LayerHandle& aHandle) {
|
||||
|
Loading…
Reference in New Issue
Block a user