void SharedBufferManagerParent::DropGrallocBufferImpl(mozilla::layers::SurfaceDescriptor aDesc) { MutexAutoLock lock(mLock); if (mDestroyed) { return; } #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC int64_t key = -1; MaybeMagicGrallocBufferHandle handle; if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc) { handle = aDesc.get_SurfaceDescriptorGralloc().buffer(); } else { return; } if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) { key = handle.get_GrallocBufferRef().mKey; } else if (handle.type() == MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) { key = handle.get_MagicGrallocBufferHandle().mRef.mKey; } NS_ASSERTION(key != -1, "Invalid buffer key"); NS_ASSERTION(mBuffers.count(key) == 1, "No such buffer"); mBuffers.erase(key); mozilla::Unused << SendDropGrallocBuffer(handle); #endif }
/*static*/ void SharedBufferManagerParent::DropGrallocBuffer(ProcessId id, mozilla::layers::SurfaceDescriptor aDesc) { if (aDesc.type() != SurfaceDescriptor::TSurfaceDescriptorGralloc) { return; } MonitorAutoLock lock(*sManagerMonitor.get()); SharedBufferManagerParent* mgr = SharedBufferManagerParent::GetInstance(id); if (!mgr) { return; } MutexAutoLock mgrlock(mgr->mLock); if (mgr->mDestroyed) { return; } if (PlatformThread::CurrentId() == mgr->mThread->thread_id()) { MOZ_CRASH("GFX: SharedBufferManagerParent::DropGrallocBuffer should not be called on SharedBufferManagerParent thread"); } else { mgr->mThread->message_loop()->PostTask( NewRunnableFunction(&DropGrallocBufferSync, mgr, aDesc)); } return; }
void SharedBufferManagerParent::DropGrallocBufferImpl(mozilla::layers::SurfaceDescriptor aDesc) { #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC MutexAutoLock lock(mBuffersMutex); int key = -1; MaybeMagicGrallocBufferHandle handle; if (aDesc.type() == SurfaceDescriptor::TNewSurfaceDescriptorGralloc) handle = aDesc.get_NewSurfaceDescriptorGralloc().buffer(); else return; if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) key = handle.get_GrallocBufferRef().mKey; else if (handle.type() == MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) key = handle.get_MagicGrallocBufferHandle().mRef.mKey; NS_ASSERTION(key != -1, "Invalid buffer key"); NS_ASSERTION(mBuffers.count(key) == 1, "No such buffer"); mBuffers.erase(key); SendDropGrallocBuffer(handle); #endif }
void SharedBufferManagerParent::DropGrallocBuffer(mozilla::layers::SurfaceDescriptor aDesc) { if (aDesc.type() != SurfaceDescriptor::TNewSurfaceDescriptorGralloc) return; if (PlatformThread::CurrentId() == mThread->thread_id()) { DropGrallocBufferImpl(aDesc); } else { mThread->message_loop()->PostTask(FROM_HERE, NewRunnableFunction(&DropGrallocBufferSync, this, aDesc)); } return; }