diff --git a/gfx/layers/BufferTexture.cpp b/gfx/layers/BufferTexture.cpp index 231a6450293b..b95141d7a277 100644 --- a/gfx/layers/BufferTexture.cpp +++ b/gfx/layers/BufferTexture.cpp @@ -100,12 +100,7 @@ class ShmemTextureData : public BufferTextureData { }; bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat, - LayersBackend aLayersBackend, - bool aSupportsTextureDirectMapping) { - if (aSupportsTextureDirectMapping) { - return false; - } - + LayersBackend aLayersBackend) { return aFormat == gfx::SurfaceFormat::UNKNOWN; } @@ -167,18 +162,10 @@ BufferTextureData* BufferTextureData::CreateForYCbCr( aCbCrSize.height, yOffset, cbOffset, crOffset); - bool supportsTextureDirectMapping = - aAllocator->SupportsTextureDirectMapping() && - aAllocator->GetMaxTextureSize() > - std::max(aYSize.width, - std::max(aYSize.height, - std::max(aCbCrSize.width, aCbCrSize.height))); - bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV, - aAllocator->GetCompositorBackendType(), - supportsTextureDirectMapping) + aAllocator->GetCompositorBackendType()) : true; YCbCrDescriptor descriptor = @@ -463,8 +450,8 @@ MemoryTextureData* MemoryTextureData::Create(gfx::IntSize aSize, return nullptr; } - bool hasIntermediateBuffer = ComputeHasIntermediateBuffer( - aFormat, aLayersBackend, aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING); + bool hasIntermediateBuffer = + ComputeHasIntermediateBuffer(aFormat, aLayersBackend); GfxMemoryImageReporter::DidAlloc(buf); @@ -537,8 +524,8 @@ ShmemTextureData* ShmemTextureData::Create(gfx::IntSize aSize, return nullptr; } - bool hasIntermediateBuffer = ComputeHasIntermediateBuffer( - aFormat, aLayersBackend, aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING); + bool hasIntermediateBuffer = + ComputeHasIntermediateBuffer(aFormat, aLayersBackend); BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer); diff --git a/gfx/layers/BufferTexture.h b/gfx/layers/BufferTexture.h index 4bd3f3675732..6b71fbe10bd6 100644 --- a/gfx/layers/BufferTexture.h +++ b/gfx/layers/BufferTexture.h @@ -17,8 +17,7 @@ namespace mozilla { namespace layers { bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat, - LayersBackend aLayersBackend, - bool aSupportsTextureDirectMapping); + LayersBackend aLayersBackend); class BufferTextureData : public TextureData { public: diff --git a/gfx/layers/CompositorTypes.h b/gfx/layers/CompositorTypes.h index 2ca02ce3c62d..94760227bdbb 100644 --- a/gfx/layers/CompositorTypes.h +++ b/gfx/layers/CompositorTypes.h @@ -149,7 +149,6 @@ struct TextureFactoryIdentifier { WebRenderCompositor mWebRenderCompositor; GeckoProcessType mParentProcessType; int32_t mMaxTextureSize; - bool mSupportsTextureDirectMapping; bool mCompositorUseANGLE; bool mCompositorUseDComp; bool mUseCompositorWnd; @@ -161,10 +160,9 @@ struct TextureFactoryIdentifier { explicit TextureFactoryIdentifier( LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE, GeckoProcessType aParentProcessType = GeckoProcessType_Default, - int32_t aMaxTextureSize = 4096, - bool aSupportsTextureDirectMapping = false, - bool aCompositorUseANGLE = false, bool aCompositorUseDComp = false, - bool aUseCompositorWnd = false, bool aSupportsTextureBlitting = false, + int32_t aMaxTextureSize = 4096, bool aCompositorUseANGLE = false, + bool aCompositorUseDComp = false, bool aUseCompositorWnd = false, + bool aSupportsTextureBlitting = false, bool aSupportsPartialUploads = false, bool aSupportsComponentAlpha = true, SyncHandle aSyncHandle = 0) : mParentBackend(aLayersBackend), @@ -172,7 +170,6 @@ struct TextureFactoryIdentifier { mWebRenderCompositor(WebRenderCompositor::DRAW), mParentProcessType(aParentProcessType), mMaxTextureSize(aMaxTextureSize), - mSupportsTextureDirectMapping(aSupportsTextureDirectMapping), mCompositorUseANGLE(aCompositorUseANGLE), mCompositorUseDComp(aCompositorUseDComp), mUseCompositorWnd(aUseCompositorWnd), @@ -185,10 +182,9 @@ struct TextureFactoryIdentifier { WebRenderBackend aWebRenderBackend, WebRenderCompositor aWebRenderCompositor, GeckoProcessType aParentProcessType = GeckoProcessType_Default, - int32_t aMaxTextureSize = 4096, - bool aSupportsTextureDirectMapping = false, - bool aCompositorUseANGLE = false, bool aCompositorUseDComp = false, - bool aUseCompositorWnd = false, bool aSupportsTextureBlitting = false, + int32_t aMaxTextureSize = 4096, bool aCompositorUseANGLE = false, + bool aCompositorUseDComp = false, bool aUseCompositorWnd = false, + bool aSupportsTextureBlitting = false, bool aSupportsPartialUploads = false, bool aSupportsComponentAlpha = true, SyncHandle aSyncHandle = 0) : mParentBackend(LayersBackend::LAYERS_WR), @@ -196,7 +192,6 @@ struct TextureFactoryIdentifier { mWebRenderCompositor(aWebRenderCompositor), mParentProcessType(aParentProcessType), mMaxTextureSize(aMaxTextureSize), - mSupportsTextureDirectMapping(aSupportsTextureDirectMapping), mCompositorUseANGLE(aCompositorUseANGLE), mCompositorUseDComp(aCompositorUseDComp), mUseCompositorWnd(aUseCompositorWnd), @@ -211,8 +206,6 @@ struct TextureFactoryIdentifier { mWebRenderCompositor == aOther.mWebRenderCompositor && mParentProcessType == aOther.mParentProcessType && mMaxTextureSize == aOther.mMaxTextureSize && - mSupportsTextureDirectMapping == - aOther.mSupportsTextureDirectMapping && mCompositorUseANGLE == aOther.mCompositorUseANGLE && mCompositorUseDComp == aOther.mCompositorUseDComp && mUseCompositorWnd == aOther.mUseCompositorWnd && diff --git a/gfx/layers/PersistentBufferProvider.cpp b/gfx/layers/PersistentBufferProvider.cpp index b260d3379dd7..dd7ab34e14b0 100644 --- a/gfx/layers/PersistentBufferProvider.cpp +++ b/gfx/layers/PersistentBufferProvider.cpp @@ -117,10 +117,7 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, KnowsCompositor* aKnowsCompositor) { if (!aKnowsCompositor || !aKnowsCompositor->GetTextureForwarder() || - !aKnowsCompositor->GetTextureForwarder()->IPCOpen() || - // Bug 1556433 - shared buffer provider and direct texture mapping do not - // synchronize properly - aKnowsCompositor->SupportsTextureDirectMapping()) { + !aKnowsCompositor->GetTextureForwarder()->IPCOpen()) { return nullptr; } diff --git a/gfx/layers/TextureSourceProvider.cpp b/gfx/layers/TextureSourceProvider.cpp index d5e3cd033784..78b9931167fc 100644 --- a/gfx/layers/TextureSourceProvider.cpp +++ b/gfx/layers/TextureSourceProvider.cpp @@ -7,10 +7,6 @@ #include "mozilla/layers/TextureSourceProvider.h" #include "mozilla/layers/TextureHost.h" #include "mozilla/layers/PTextureParent.h" -#ifdef XP_DARWIN -# include "mozilla/layers/TextureSync.h" -# include "nsClassHashtable.h" -#endif namespace mozilla { namespace layers { diff --git a/gfx/layers/TextureSync.cpp b/gfx/layers/TextureSync.cpp deleted file mode 100644 index c58739489def..000000000000 --- a/gfx/layers/TextureSync.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "TextureSync.h" - -#include - -#include "base/process_util.h" -#include "chrome/common/mach_ipc_mac.h" -#include "mozilla/ipc/SharedMemoryBasic.h" -#include "mozilla/layers/CompositorThread.h" -#include "mozilla/StaticMonitor.h" -#include "mozilla/StaticPtr.h" -#include "nsThreadUtils.h" - -#ifdef DEBUG -# define LOG_ERROR(str, args...) \ - PR_BEGIN_MACRO \ - mozilla::SmprintfPointer msg = mozilla::Smprintf(str, ##args); \ - NS_WARNING(msg.get()); \ - PR_END_MACRO -#else -# define LOG_ERROR(str, args...) \ - do { /* nothing */ \ - } while (0) -#endif - -namespace mozilla { - -namespace layers { - -// Hold raw pointers and trust that TextureSourceProviders will be -// unregistered in their destructors - we don't want to keep these -// alive, and destroying them from the main thread will be an -// error anyway. -StaticAutoPtr> gTextureSourceProviders; - -static std::map> gProcessTextureIds; -static StaticMonitor gTextureLockMonitor; - -const int kSendMessageTimeout = 1000; -const int kTextureLockTimeout = 32; // We really don't want to wait more than - // two frames for a texture to unlock. This - // will in any case be very uncommon. - -struct WaitForTexturesReply { - bool success; -}; - -struct WaitForTexturesRequest { - pid_t pid; -}; - -static std::unordered_set* GetLockedTextureIdsForProcess(pid_t pid) { - gTextureLockMonitor.AssertCurrentThreadOwns(); - - if (gProcessTextureIds.find(pid) == gProcessTextureIds.end()) { - gProcessTextureIds[pid] = std::unordered_set(); - } - - return &gProcessTextureIds.at(pid); -} - -static bool WaitForTextureIdsToUnlock(pid_t pid, - const Span& textureIds) { - { - StaticMonitorAutoLock lock(gTextureLockMonitor); - std::unordered_set* freedTextureIds = - GetLockedTextureIdsForProcess(pid); - - TimeStamp start = TimeStamp::Now(); - while (true) { - bool allCleared = true; - for (uint64_t textureId : textureIds) { - if (freedTextureIds->find(textureId) != freedTextureIds->end()) { - allCleared = false; - } - } - - if (allCleared) { - return true; - } - - if (lock.Wait(TimeDuration::FromMilliseconds(kTextureLockTimeout)) == - CVStatus::Timeout) { - return false; - } - - // In case the monitor gets signaled multiple times, each less than - // kTextureLockTimeout. This ensures that the total time we wait is - // < 2 * kTextureLockTimeout - if ((TimeStamp::Now() - start).ToMilliseconds() > - (double)kTextureLockTimeout) { - return false; - } - } - } -} - -static void CheckTexturesForUnlock() { - if (gTextureSourceProviders) { - for (auto it = gTextureSourceProviders->begin(); - it != gTextureSourceProviders->end(); ++it) { - (*it)->TryUnlockTextures(); - } - } -} - -void TextureSync::DispatchCheckTexturesForUnlock() { - RefPtr task = - NS_NewRunnableFunction("CheckTexturesForUnlock", &CheckTexturesForUnlock); - CompositorThread()->Dispatch(task.forget()); -} - -void TextureSync::HandleWaitForTexturesMessage(MachReceiveMessage* rmsg, - ipc::MemoryPorts* ports) { - WaitForTexturesRequest* req = - reinterpret_cast(rmsg->GetData()); - uint64_t* textureIds = (uint64_t*)(req + 1); - uint32_t textureIdsLength = - (rmsg->GetDataLength() - sizeof(WaitForTexturesRequest)) / - sizeof(uint64_t); - - bool success = - WaitForTextureIdsToUnlock(req->pid, Span(textureIds, textureIdsLength)); - - if (!success) { - LOG_ERROR("Waiting for textures to unlock failed.\n"); - } - - MachSendMessage msg(ipc::kReturnWaitForTexturesMsg); - WaitForTexturesReply replydata; - replydata.success = success; - msg.SetData(&replydata, sizeof(WaitForTexturesReply)); - kern_return_t err = ports->mSender->SendMessage(msg, kSendMessageTimeout); - if (KERN_SUCCESS != err) { - LOG_ERROR("SendMessage failed 0x%x %s\n", err, mach_error_string(err)); - } -} - -void TextureSync::RegisterTextureSourceProvider( - TextureSourceProvider* textureSourceProvider) { - if (!gTextureSourceProviders) { - gTextureSourceProviders = new nsTArray(); - } - MOZ_RELEASE_ASSERT(!gTextureSourceProviders->Contains(textureSourceProvider)); - gTextureSourceProviders->AppendElement(textureSourceProvider); -} - -void TextureSync::UnregisterTextureSourceProvider( - TextureSourceProvider* textureSourceProvider) { - if (gTextureSourceProviders) { - MOZ_ASSERT(gTextureSourceProviders->Contains(textureSourceProvider)); - gTextureSourceProviders->RemoveElement(textureSourceProvider); - if (gTextureSourceProviders->Length() == 0) { - gTextureSourceProviders = nullptr; - } - } -} - -void TextureSync::SetTexturesLocked(pid_t pid, - const nsTArray& textureIds) { - StaticMonitorAutoLock mal(gTextureLockMonitor); - std::unordered_set* lockedTextureIds = - GetLockedTextureIdsForProcess(pid); - for (uint64_t textureId : textureIds) { - lockedTextureIds->insert(textureId); - } -} - -void TextureSync::SetTexturesUnlocked(pid_t pid, - const nsTArray& textureIds) { - bool oneErased = false; - { - StaticMonitorAutoLock mal(gTextureLockMonitor); - std::unordered_set* lockedTextureIds = - GetLockedTextureIdsForProcess(pid); - for (uint64_t textureId : textureIds) { - if (lockedTextureIds->erase(textureId)) { - oneErased = true; - } - } - } - if (oneErased) { - gTextureLockMonitor.NotifyAll(); - } -} - -void TextureSync::Shutdown() { - { - StaticMonitorAutoLock lock(gTextureLockMonitor); - - for (auto& lockedTextureIds : gProcessTextureIds) { - lockedTextureIds.second.clear(); - } - } - - gTextureLockMonitor.NotifyAll(); - - { - StaticMonitorAutoLock lock(gTextureLockMonitor); - gProcessTextureIds.clear(); - } -} - -void TextureSync::UpdateTextureLocks(base::ProcessId aProcessId) { - if (aProcessId == base::GetCurrentProcId()) { - DispatchCheckTexturesForUnlock(); - return; - } - - MachSendMessage smsg(ipc::kUpdateTextureLocksMsg); - smsg.SetData(&aProcessId, sizeof(aProcessId)); - ipc::SharedMemoryBasic::SendMachMessage(aProcessId, smsg, NULL); -} - -bool TextureSync::WaitForTextures(base::ProcessId aProcessId, - const nsTArray& textureIds) { - if (aProcessId == base::GetCurrentProcId()) { - bool success = WaitForTextureIdsToUnlock(aProcessId, Span(textureIds)); - if (!success) { - LOG_ERROR("Failed waiting for textures to unlock.\n"); - } - - return success; - } - - MachSendMessage smsg(ipc::kWaitForTexturesMsg); - size_t messageSize = - sizeof(WaitForTexturesRequest) + textureIds.Length() * sizeof(uint64_t); - UniquePtr messageData = MakeUnique(messageSize); - WaitForTexturesRequest* req = (WaitForTexturesRequest*)messageData.get(); - uint64_t* reqTextureIds = (uint64_t*)(req + 1); - - for (uint32_t i = 0; i < textureIds.Length(); ++i) { - reqTextureIds[i] = textureIds[i]; - } - - req->pid = base::GetCurrentProcId(); - bool dataWasSet = smsg.SetData(req, messageSize); - - if (!dataWasSet) { - LOG_ERROR("Data was too large: %zu\n", messageSize); - return false; - } - - MachReceiveMessage msg; - bool success = - ipc::SharedMemoryBasic::SendMachMessage(aProcessId, smsg, &msg); - if (!success) { - return false; - } - - if (msg.GetDataLength() != sizeof(WaitForTexturesReply)) { - LOG_ERROR("Improperly formatted reply\n"); - return false; - } - - WaitForTexturesReply* msg_data = - reinterpret_cast(msg.GetData()); - if (!msg_data->success) { - LOG_ERROR("Failed waiting for textures to unlock.\n"); - return false; - } - - return true; -} - -void TextureSync::CleanupForPid(base::ProcessId aProcessId) { - { - StaticMonitorAutoLock lock(gTextureLockMonitor); - std::unordered_set* lockedTextureIds = - GetLockedTextureIdsForProcess(aProcessId); - lockedTextureIds->clear(); - } - gTextureLockMonitor.NotifyAll(); -} - -} // namespace layers - -} // namespace mozilla diff --git a/gfx/layers/TextureSync.h b/gfx/layers/TextureSync.h deleted file mode 100644 index 24ba058bd417..000000000000 --- a/gfx/layers/TextureSync.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef MOZILLA_LAYERS_TEXTURESYNC_H -#define MOZILLA_LAYERS_TEXTURESYNC_H - -#include "base/process.h" - -#include "nsTArray.h" -#include "mozilla/layers/TextureSourceProvider.h" - -#include "mozilla/ipc/SharedMemory.h" - -class MachReceiveMessage; - -namespace mozilla { -namespace ipc { -struct MemoryPorts; -} // namespace ipc - -namespace layers { - -class TextureSync { - public: - static void RegisterTextureSourceProvider( - layers::TextureSourceProvider* aTextureSourceProvider); - static void UnregisterTextureSourceProvider( - layers::TextureSourceProvider* aTextureSourceProvider); - static void DispatchCheckTexturesForUnlock(); - static void HandleWaitForTexturesMessage(MachReceiveMessage* rmsg, - ipc::MemoryPorts* ports); - static void UpdateTextureLocks(base::ProcessId aProcessId); - static bool WaitForTextures(base::ProcessId aProcessId, - const nsTArray& aTextureIds); - static void SetTexturesLocked(base::ProcessId aProcessId, - const nsTArray& aTextureIds); - static void SetTexturesUnlocked(base::ProcessId aProcessId, - const nsTArray& aTextureIds); - static void Shutdown(); - static void CleanupForPid(base::ProcessId aProcessId); -}; - -} // namespace layers -} // namespace mozilla - -#endif diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 73937820fbf4..b8fbe3e30a9d 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -1137,11 +1137,6 @@ already_AddRefed TextureClient::CreateForDrawing( KnowsCompositor* aAllocator, gfx::SurfaceFormat aFormat, gfx::IntSize aSize, BackendSelector aSelector, TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags) { - if (aAllocator->SupportsTextureDirectMapping() && - std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize()) { - aAllocFlags = - TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING); - } return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(), aFormat, aSize, aAllocator, aSelector, aTextureFlags, aAllocFlags); @@ -1244,19 +1239,6 @@ already_AddRefed TextureClient::CreateForRawBufferAccess( KnowsCompositor* aAllocator, gfx::SurfaceFormat aFormat, gfx::IntSize aSize, gfx::BackendType aMoz2DBackend, TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags) { - // If we exceed the max texture size for the GPU, then just fall back to no - // texture direct mapping. If it becomes a problem we can implement tiling - // logic inside DirectMapTextureSource to allow this. - bool supportsTextureDirectMapping = - aAllocator->SupportsTextureDirectMapping() && - std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize(); - if (supportsTextureDirectMapping) { - aAllocFlags = - TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING); - } else { - aAllocFlags = - TextureAllocationFlags(aAllocFlags & ~ALLOC_ALLOW_DIRECT_MAPPING); - } return CreateForRawBufferAccess( aAllocator->GetTextureForwarder(), aFormat, aSize, aMoz2DBackend, aAllocator->GetCompositorBackendType(), aTextureFlags, aAllocFlags); diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index cbe17c0e8532..47c99aa1cf24 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -97,10 +97,6 @@ enum TextureAllocationFlags { // The texture is going to be updated using UpdateFromSurface and needs to // support that call. ALLOC_UPDATE_FROM_SURFACE = 1 << 7, - - // In practice, this means we support the APPLE_client_storage extension, - // meaning the buffer will not be internally copied by the graphics driver. - ALLOC_ALLOW_DIRECT_MAPPING = 1 << 8, }; /** diff --git a/gfx/layers/client/TextureClientPool.cpp b/gfx/layers/client/TextureClientPool.cpp index 368f7e540fd8..2ca0ce20e837 100644 --- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -130,12 +130,6 @@ void TextureClientPool::AllocateTextureClient() { TextureAllocationFlags allocFlags = ALLOC_DEFAULT; - if (mKnowsCompositor->SupportsTextureDirectMapping() && - std::max(mSize.width, mSize.height) <= GetMaxTextureSize()) { - allocFlags = - TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING); - } - RefPtr newClient; if (StaticPrefs::layers_force_shmem_tiles_AtStartup()) { // gfx::BackendType::NONE means use the content backend diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index d4fb014a8045..2122fa0b9929 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -21,9 +21,6 @@ #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL #include "mozilla/layers/ImageDataSerializer.h" #include "mozilla/layers/TextureClient.h" -#ifdef XP_DARWIN -# include "mozilla/layers/TextureSync.h" -#endif #include "mozilla/layers/GPUVideoTextureHost.h" #include "mozilla/layers/WebRenderTextureHost.h" #include "mozilla/StaticPrefs_layers.h" @@ -629,16 +626,7 @@ bool TextureHost::NeedsYFlip() const { return bool(mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT); } -void BufferTextureHost::MaybeNotifyUnlocked() { -#ifdef XP_DARWIN - auto actor = GetIPDLActor(); - if (actor) { - AutoTArray serials; - serials.AppendElement(TextureHost::GetTextureSerial(actor)); - TextureSync::SetTexturesUnlocked(actor->OtherPid(), serials); - } -#endif -} +void BufferTextureHost::MaybeNotifyUnlocked() {} gfx::SurfaceFormat BufferTextureHost::GetFormat() const { return mFormat; } diff --git a/gfx/layers/ipc/KnowsCompositor.h b/gfx/layers/ipc/KnowsCompositor.h index c98e6199f65e..8cb786a5026c 100644 --- a/gfx/layers/ipc/KnowsCompositor.h +++ b/gfx/layers/ipc/KnowsCompositor.h @@ -113,11 +113,6 @@ class KnowsCompositor { return lock.ref().mTextureFactoryIdentifier.mSupportsComponentAlpha; } - bool SupportsTextureDirectMapping() const { - auto lock = mData.Lock(); - return lock.ref().mTextureFactoryIdentifier.mSupportsTextureDirectMapping; - } - bool SupportsD3D11() const { auto lock = mData.Lock(); return lock.ref().mTextureFactoryIdentifier.mParentBackend == diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index 47c089339c0a..48ac9a9d9b6b 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -492,7 +492,6 @@ struct ParamTraits { WriteParam(aMsg, aParam.mWebRenderCompositor); WriteParam(aMsg, aParam.mParentProcessType); WriteParam(aMsg, aParam.mMaxTextureSize); - WriteParam(aMsg, aParam.mSupportsTextureDirectMapping); WriteParam(aMsg, aParam.mCompositorUseANGLE); WriteParam(aMsg, aParam.mCompositorUseDComp); WriteParam(aMsg, aParam.mUseCompositorWnd); @@ -504,20 +503,18 @@ struct ParamTraits { static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - bool result = - ReadParam(aMsg, aIter, &aResult->mParentBackend) && - ReadParam(aMsg, aIter, &aResult->mWebRenderBackend) && - ReadParam(aMsg, aIter, &aResult->mWebRenderCompositor) && - ReadParam(aMsg, aIter, &aResult->mParentProcessType) && - ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && - ReadParam(aMsg, aIter, &aResult->mSupportsTextureDirectMapping) && - ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) && - ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) && - ReadParam(aMsg, aIter, &aResult->mUseCompositorWnd) && - ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) && - ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) && - ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) && - ReadParam(aMsg, aIter, &aResult->mSyncHandle); + bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) && + ReadParam(aMsg, aIter, &aResult->mWebRenderBackend) && + ReadParam(aMsg, aIter, &aResult->mWebRenderCompositor) && + ReadParam(aMsg, aIter, &aResult->mParentProcessType) && + ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && + ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) && + ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) && + ReadParam(aMsg, aIter, &aResult->mUseCompositorWnd) && + ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) && + ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) && + ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) && + ReadParam(aMsg, aIter, &aResult->mSyncHandle); return result; } }; diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index cc3da181368d..1734ab2eed6c 100755 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -249,7 +249,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": EXPORTS.mozilla.layers += [ "NativeLayerCA.h", "SurfacePoolCA.h", - "TextureSync.h", ] EXPORTS += [ "MacIOSurfaceHelpers.h", @@ -258,7 +257,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": UNIFIED_SOURCES += [ "NativeLayerCA.mm", "SurfacePoolCA.mm", - "TextureSync.cpp", ] SOURCES += [ "MacIOSurfaceHelpers.cpp", diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 886882e83fe2..299737ca5638 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -34,10 +34,7 @@ #include "mozilla/layers/TextureHost.h" // for TextureSource, etc #include "mozilla/layers/TextureHostOGL.h" // for TextureSourceOGL, etc #include "mozilla/layers/PTextureParent.h" // for OtherPid() on PTextureParent -#ifdef XP_DARWIN -# include "mozilla/layers/TextureSync.h" // for TextureSync::etc. -#endif -#include "mozilla/mozalloc.h" // for operator delete, etc +#include "mozilla/mozalloc.h" // for operator delete, etc #include "nsAppRunner.h" #include "nsAString.h" #include "nsClassHashtable.h" @@ -185,18 +182,10 @@ CompositorOGL::CompositorOGL(widget::CompositorWidget* aWidget, // default framebuffer. mCanRenderToDefaultFramebuffer = false; } -#ifdef XP_DARWIN - TextureSync::RegisterTextureSourceProvider(this); -#endif MOZ_COUNT_CTOR(CompositorOGL); } -CompositorOGL::~CompositorOGL() { -#ifdef XP_DARWIN - TextureSync::UnregisterTextureSourceProvider(this); -#endif - MOZ_COUNT_DTOR(CompositorOGL); -} +CompositorOGL::~CompositorOGL() { MOZ_COUNT_DTOR(CompositorOGL); } already_AddRefed CompositorOGL::CreateContext() { RefPtr context; @@ -1650,21 +1639,6 @@ GLuint CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit) { return mTexturePool->GetTexture(aTarget, aUnit); } -bool CompositorOGL::SupportsTextureDirectMapping() { - if (!StaticPrefs::gfx_allow_texture_direct_mapping_AtStartup()) { - return false; - } - - if (mGLContext) { - mGLContext->MakeCurrent(); - return mGLContext->IsExtensionSupported( - gl::GLContext::APPLE_client_storage) && - mGLContext->IsExtensionSupported(gl::GLContext::APPLE_texture_range); - } - - return false; -} - GLuint PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit) { if (mTextureTarget == 0) { mTextureTarget = aTarget; diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 6138a9129c37..878372aa6451 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -230,8 +230,6 @@ class CompositorOGL final : public Compositor { void PrepareViewport(CompositingRenderTargetOGL* aRenderTarget); - bool SupportsTextureDirectMapping(); - void InsertFrameDoneSync(); bool NeedToRecreateFullWindowRenderTarget() const; diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index 988db8951bae..a82ceb0bf3f4 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -2735,9 +2735,9 @@ TextureFactoryIdentifier WebRenderBridgeParent::GetTextureFactoryIdentifier() { TextureFactoryIdentifier ident( mApi->GetBackendType(), mApi->GetCompositorType(), XRE_GetProcessType(), - mApi->GetMaxTextureSize(), false, mApi->GetUseANGLE(), - mApi->GetUseDComp(), mAsyncImageManager->UseCompositorWnd(), false, false, - false, mApi->GetSyncHandle()); + mApi->GetMaxTextureSize(), mApi->GetUseANGLE(), mApi->GetUseDComp(), + mAsyncImageManager->UseCompositorWnd(), false, false, false, + mApi->GetSyncHandle()); return ident; } diff --git a/ipc/glue/SharedMemoryBasic_mach.h b/ipc/glue/SharedMemoryBasic_mach.h index 5c41ccc9372d..e77e5ef4cff6 100644 --- a/ipc/glue/SharedMemoryBasic_mach.h +++ b/ipc/glue/SharedMemoryBasic_mach.h @@ -31,10 +31,7 @@ namespace ipc { enum { kGetPortsMsg = 1, - kWaitForTexturesMsg, - kUpdateTextureLocksMsg, kReturnIdMsg, - kReturnWaitForTexturesMsg, kReturnPortsMsg, kShutdownMsg, kCleanupMsg, @@ -62,9 +59,6 @@ class SharedMemoryBasic final static void Shutdown(); - static bool SendMachMessage(pid_t pid, MachSendMessage& message, - MachReceiveMessage* response); - SharedMemoryBasic(); virtual bool SetHandle(Handle aHandle, OpenRights aRights) override; diff --git a/ipc/glue/SharedMemoryBasic_mach.mm b/ipc/glue/SharedMemoryBasic_mach.mm index 6f2b9b1a6609..0ea2ba228226 100644 --- a/ipc/glue/SharedMemoryBasic_mach.mm +++ b/ipc/glue/SharedMemoryBasic_mach.mm @@ -26,7 +26,6 @@ #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/Printf.h" #include "mozilla/StaticMutex.h" -#include "mozilla/layers/TextureSync.h" #ifdef DEBUG # define LOG_ERROR(str, args...) \ @@ -330,37 +329,31 @@ static void* PortServerThread(void* argument) { delete ports; return nullptr; } - if (rmsg.GetMessageID() == kWaitForTexturesMsg) { - layers::TextureSync::HandleWaitForTexturesMessage(&rmsg, ports); - } else if (rmsg.GetMessageID() == kUpdateTextureLocksMsg) { - layers::TextureSync::DispatchCheckTexturesForUnlock(); - } else { - switch (rmsg.GetMessageID()) { - case kGetPortsMsg: { - StaticMutexAutoLock smal(gMutex); - HandleGetPortsMessage(&rmsg, ports); - break; + switch (rmsg.GetMessageID()) { + case kGetPortsMsg: { + StaticMutexAutoLock smal(gMutex); + HandleGetPortsMessage(&rmsg, ports); + break; + } + case kCleanupMsg: { + StaticMutexAutoLock smal(gMutex); + if (gParentPid == 0) { + LOG_ERROR("Cleanup message not valid for parent process"); + continue; } - case kCleanupMsg: { - StaticMutexAutoLock smal(gMutex); - if (gParentPid == 0) { - LOG_ERROR("Cleanup message not valid for parent process"); - continue; - } - pid_t* pid; - if (rmsg.GetDataLength() != sizeof(pid_t)) { - LOG_ERROR("Improperly formatted message\n"); - continue; - } - pid = reinterpret_cast(rmsg.GetData()); - SharedMemoryBasic::CleanupForPid(*pid); - break; - } - default: { - // gMutex not required - LOG_ERROR("Unknown message\n"); + pid_t* pid; + if (rmsg.GetDataLength() != sizeof(pid_t)) { + LOG_ERROR("Improperly formatted message\n"); + continue; } + pid = reinterpret_cast(rmsg.GetData()); + SharedMemoryBasic::CleanupForPid(*pid); + break; + } + default: { + // gMutex not required + LOG_ERROR("Unknown message\n"); } } } @@ -377,8 +370,6 @@ void SharedMemoryBasic::SetupMachMemory(pid_t pid, ReceivePort* listen_port, void SharedMemoryBasic::Shutdown() { StaticMutexAutoLock smal(gMutex); - layers::TextureSync::Shutdown(); - for (auto& thread : gThreads) { MachSendMessage shutdownMsg(kShutdownMsg); thread.second.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout); @@ -404,8 +395,6 @@ void SharedMemoryBasic::CleanupForPid(pid_t pid) { return; } - layers::TextureSync::CleanupForPid(pid); - const ListeningThread& listeningThread = gThreads[pid]; MachSendMessage shutdownMsg(kShutdownMsg); kern_return_t ret = listeningThread.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout); @@ -430,37 +419,6 @@ void SharedMemoryBasic::CleanupForPid(pid_t pid) { gMemoryCommPorts.erase(pid); } -bool SharedMemoryBasic::SendMachMessage(pid_t pid, MachSendMessage& message, - MachReceiveMessage* response) { - StaticMutexAutoLock smal(gMutex); - ipc::MemoryPorts* ports = GetMemoryPortsForPid(pid); - if (!ports) { - LOG_ERROR("Unable to get ports for process.\n"); - return false; - } - - kern_return_t err = ports->mSender->SendMessage(message, kTimeout); - if (err != KERN_SUCCESS) { - LOG_ERROR("Failed updating texture locks.\n"); - return false; - } - - if (response) { - err = ports->mReceiver->WaitForMessage(response, kTimeout); - if (err != KERN_SUCCESS) { - LOG_ERROR("short timeout didn't get an id %s %x\n", mach_error_string(err), err); - err = ports->mReceiver->WaitForMessage(response, kLongTimeout); - - if (err != KERN_SUCCESS) { - LOG_ERROR("long timeout didn't get an id %s %x\n", mach_error_string(err), err); - return false; - } - } - } - - return true; -} - SharedMemoryBasic::SharedMemoryBasic() : mPort(MACH_PORT_NULL), mMemory(nullptr), mOpenRights(RightsReadWrite) {}