Bug 1678136 - Lazily initialize SyncObject r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D97946
This commit is contained in:
sotaro
2020-11-26 04:59:52 +00:00
parent 1d883bd681
commit 29b76c8344
6 changed files with 25 additions and 12 deletions

View File

@@ -42,8 +42,6 @@ SyncObjectClient::CreateSyncObjectClientForContentDevice(SyncHandle aHandle) {
return nullptr;
}
MOZ_ASSERT(XRE_IsContentProcess() || !mozilla::BrowserTabsRemoteAutostart());
return MakeAndAddRef<SyncObjectD3D11ClientContentDevice>(aHandle);
#endif
}

View File

@@ -63,6 +63,8 @@ class SyncObjectClient : public external::AtomicRefCounted<SyncObjectClient> {
virtual bool IsSyncObjectValid() = 0;
virtual void EnsureInitialized() = 0;
protected:
SyncObjectClient() = default;
};

View File

@@ -1794,11 +1794,7 @@ AutoLockD3D11Texture::~AutoLockD3D11Texture() {
SyncObjectD3D11ClientContentDevice::SyncObjectD3D11ClientContentDevice(
SyncHandle aSyncHandle)
: SyncObjectD3D11Client(aSyncHandle) {
if (!XRE_IsGPUProcess() && gfxPlatform::GetPlatform()->DevicesInitialized()) {
mContentDevice = DeviceManagerDx::Get()->GetContentDevice();
}
}
: SyncObjectD3D11Client(aSyncHandle) {}
bool SyncObjectD3D11ClientContentDevice::Synchronize(bool aFallible) {
// Since this can be called from either the Paint or Main thread.
@@ -1851,5 +1847,17 @@ bool SyncObjectD3D11ClientContentDevice::IsSyncObjectValid() {
return true;
}
void SyncObjectD3D11ClientContentDevice::EnsureInitialized() {
if (mContentDevice) {
return;
}
if (XRE_IsGPUProcess() || !gfxPlatform::GetPlatform()->DevicesInitialized()) {
return;
}
mContentDevice = DeviceManagerDx::Get()->GetContentDevice();
}
} // namespace layers
} // namespace mozilla

View File

@@ -505,6 +505,8 @@ class SyncObjectD3D11Client : public SyncObjectClient {
bool IsSyncObjectValid() override;
void EnsureInitialized() override {}
SyncType GetSyncType() override { return SyncType::D3D11; }
void RegisterTexture(ID3D11Texture2D* aTexture);
@@ -531,6 +533,8 @@ class SyncObjectD3D11ClientContentDevice : public SyncObjectD3D11Client {
bool IsSyncObjectValid() override;
void EnsureInitialized() override;
private:
RefPtr<ID3D11Device> mContentDevice;
};

View File

@@ -64,6 +64,9 @@ class KnowsCompositor {
// The sync object for the global content device.
RefPtr<SyncObjectClient> GetSyncObject() {
auto lock = mData.Lock();
if (lock.ref().mSyncObject) {
lock.ref().mSyncObject->EnsureInitialized();
}
return lock.ref().mSyncObject;
}

View File

@@ -148,11 +148,9 @@ void KnowsCompositor::IdentifyTextureHost(
auto lock = mData.Lock();
lock.ref().mTextureFactoryIdentifier = aIdentifier;
if (XRE_IsContentProcess() || !mozilla::BrowserTabsRemoteAutostart()) {
lock.ref().mSyncObject =
SyncObjectClient::CreateSyncObjectClientForContentDevice(
aIdentifier.mSyncHandle);
}
lock.ref().mSyncObject =
SyncObjectClient::CreateSyncObjectClientForContentDevice(
aIdentifier.mSyncHandle);
}
KnowsCompositor::KnowsCompositor()