void LayerTransactionChild::Destroy() { if (!IPCOpen()) { return; } // mDestroyed is used to prevent calling Send__delete__() twice. // When this function is called from CompositorChild::Destroy(), // under Send__delete__() call, this function is called from // ShadowLayerForwarder's destructor. // When it happens, IPCOpen() is still true. // See bug 1004191. mDestroyed = true; MOZ_ASSERT(0 == ManagedPLayerChild().Length(), "layers should have been cleaned up by now"); for (size_t i = 0; i < ManagedPTextureChild().Length(); ++i) { TextureClient* texture = TextureClient::AsTextureClient(ManagedPTextureChild()[i]); if (texture) { texture->ForceRemove(); } } SendShutdown(); }
void FixedSizeSmallShmemSectionAllocator::ShrinkShmemSectionHeap() { if (!IPCOpen()) { mUsedShmems.clear(); return; } // The loop will terminate as we either increase i, or decrease size // every time through. size_t i = 0; while (i < mUsedShmems.size()) { ShmemSectionHeapHeader* header = mUsedShmems[i].get<ShmemSectionHeapHeader>(); if (header->mAllocatedBlocks == 0) { GetShmAllocator()->DeallocShmem(mUsedShmems[i]); // We don't particularly care about order, move the last one in the array // to this position. if (i < mUsedShmems.size() - 1) { mUsedShmems[i] = mUsedShmems[mUsedShmems.size() - 1]; } mUsedShmems.pop_back(); } else { i++; } } }
void LayerTransactionChild::Destroy() { if (!IPCOpen()) { return; } // mDestroyed is used to prevent calling Send__delete__() twice. // When this function is called from CompositorChild::Destroy(), // under Send__delete__() call, this function is called from // ShadowLayerForwarder's destructor. // When it happens, IPCOpen() is still true. // See bug 1004191. mDestroyed = true; MOZ_ASSERT(0 == ManagedPLayerChild().Count(), "layers should have been cleaned up by now"); const ManagedContainer<PTextureChild>& textures = ManagedPTextureChild(); for (auto iter = textures.ConstIter(); !iter.Done(); iter.Next()) { TextureClient* texture = TextureClient::AsTextureClient(iter.Get()->GetKey()); if (texture) { texture->Destroy(); } } SendShutdown(); }
void FixedSizeSmallShmemSectionAllocator::DeallocShmemSection(mozilla::layers::ShmemSection& aShmemSection) { if (!IPCOpen()) { gfxCriticalNote << "Attempt to dealloc a ShmemSections after shutdown."; return; } FreeShmemSection(aShmemSection); ShrinkShmemSectionHeap(); }
void LayerTransactionChild::Destroy() { if (!IPCOpen()) { return; } // mDestroyed is used to prevent calling Send__delete__() twice. // When this function is called from CompositorBridgeChild::Destroy(), // under Send__delete__() call, this function is called from // ShadowLayerForwarder's destructor. // When it happens, IPCOpen() is still true. // See bug 1004191. mDestroyed = true; SendShutdown(); }
void LayerTransactionChild::Destroy() { if (!IPCOpen() || mDestroyed) { return; } // mDestroyed is used to prevent calling Send__delete__() twice. // When this function is called from CompositorChild::Destroy(), // under Send__delete__() call, this function is called from // ShadowLayerForwarder's destructor. // When it happens, IPCOpen() is still true. // See bug 1004191. mDestroyed = true; NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(), "layers should have been cleaned up by now"); PLayerTransactionChild::Send__delete__(this); }
void LayerTransactionChild::Destroy() { if (!IPCOpen()) { return; } // mDestroyed is used to prevent calling Send__delete__() twice. // When this function is called from CompositorBridgeChild::Destroy(), // under Send__delete__() call, this function is called from // ShadowLayerForwarder's destructor. // When it happens, IPCOpen() is still true. // See bug 1004191. mDestroyed = true; MOZ_ASSERT(0 == ManagedPLayerChild().Count(), "layers should have been cleaned up by now"); SendShutdown(); }
bool FixedSizeSmallShmemSectionAllocator::AllocShmemSection(uint32_t aSize, ShmemSection* aShmemSection) { // For now we only support sizes of 4. If we want to support different sizes // some more complicated bookkeeping should be added. MOZ_ASSERT(aSize == sSupportedBlockSize); MOZ_ASSERT(aShmemSection); if (!IPCOpen()) { gfxCriticalError() << "Attempt to allocate a ShmemSection after shutdown."; return false; } uint32_t allocationSize = (aSize + sizeof(ShmemSectionHeapAllocation)); for (size_t i = 0; i < mUsedShmems.size(); i++) { ShmemSectionHeapHeader* header = mUsedShmems[i].get<ShmemSectionHeapHeader>(); if ((header->mAllocatedBlocks + 1) * allocationSize + sizeof(ShmemSectionHeapHeader) < sShmemPageSize) { aShmemSection->shmem() = mUsedShmems[i]; MOZ_ASSERT(mUsedShmems[i].IsWritable()); break; } } if (!aShmemSection->shmem().IsWritable()) { ipc::Shmem tmp; if (!GetShmAllocator()->AllocUnsafeShmem(sShmemPageSize, OptimalShmemType(), &tmp)) { return false; } ShmemSectionHeapHeader* header = tmp.get<ShmemSectionHeapHeader>(); header->mTotalBlocks = 0; header->mAllocatedBlocks = 0; mUsedShmems.push_back(tmp); aShmemSection->shmem() = tmp; } MOZ_ASSERT(aShmemSection->shmem().IsWritable()); ShmemSectionHeapHeader* header = aShmemSection->shmem().get<ShmemSectionHeapHeader>(); uint8_t* heap = aShmemSection->shmem().get<uint8_t>() + sizeof(ShmemSectionHeapHeader); ShmemSectionHeapAllocation* allocHeader = nullptr; if (header->mTotalBlocks > header->mAllocatedBlocks) { // Search for the first available block. for (size_t i = 0; i < header->mTotalBlocks; i++) { allocHeader = reinterpret_cast<ShmemSectionHeapAllocation*>(heap); if (allocHeader->mStatus == STATUS_FREED) { break; } heap += allocationSize; } MOZ_ASSERT(allocHeader && allocHeader->mStatus == STATUS_FREED); MOZ_ASSERT(allocHeader->mSize == sSupportedBlockSize); } else { heap += header->mTotalBlocks * allocationSize; header->mTotalBlocks++; allocHeader = reinterpret_cast<ShmemSectionHeapAllocation*>(heap); allocHeader->mSize = aSize; } MOZ_ASSERT(allocHeader); header->mAllocatedBlocks++; allocHeader->mStatus = STATUS_ALLOCATED; aShmemSection->size() = aSize; aShmemSection->offset() = (heap + sizeof(ShmemSectionHeapAllocation)) - aShmemSection->shmem().get<uint8_t>(); ShrinkShmemSectionHeap(); return true; }