本文整理汇总了C++中InImageBridgeChildThread函数的典型用法代码示例。如果您正苦于以下问题:C++ InImageBridgeChildThread函数的具体用法?C++ InImageBridgeChildThread怎么用?C++ InImageBridgeChildThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InImageBridgeChildThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateImageContainerChildNow
already_AddRefed<ImageContainerChild> ImageBridgeChild::CreateImageContainerChild()
{
if (InImageBridgeChildThread()) {
return ImageBridgeChild::CreateImageContainerChildNow();
}
// ImageContainerChild can only be alocated on the ImageBridgeChild thread, so se
// dispatch a task to the thread and block the current thread until the task has been
// executed.
nsRefPtr<ImageContainerChild> result = nullptr;
ReentrantMonitor barrier("CreateImageContainerChild Lock");
ReentrantMonitorAutoEnter autoMon(barrier);
bool done = false;
GetMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(&CreateContainerChildSync,
&result, &barrier, &done));
// should stop the thread until the ImageContainerChild has been created on
// the other thread
while (!done) {
barrier.Wait();
}
return result.forget();
}
示例2: MOZ_ASSERT
void
AsyncTransactionWaiter::WaitComplete()
{
MOZ_ASSERT(!InImageBridgeChildThread());
MonitorAutoLock mon(mCompletedMonitor);
int count = 0;
const int maxCount = 5;
while (mWaitCount > 0 && (count < maxCount)) {
if (!NS_SUCCEEDED(mCompletedMonitor.Wait(PR_MillisecondsToInterval(10000)))) {
NS_WARNING("Failed to wait Monitor");
return;
}
if (count > 1) {
printf_stderr("Waiting async transaction complete.\n");
}
count++;
}
if (mWaitCount > 0) {
printf_stderr("Timeout of waiting transaction complete.");
}
if (count == maxCount) {
gfxDevCrash(gfx::LogReason::AsyncTransactionTimeout) << "Bug 1244883: AsyncTransactionWaiter timed out.";
}
}
示例3: NS_ABORT_IF_FALSE
void ImageContainerChild::SendImageNow(Image* aImage)
{
NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
"Should be in ImageBridgeChild thread.");
if (mStop) {
return;
}
bool needsCopy = false;
// If the image can be converted to a shared image, no need to do a copy.
SharedImage* img = AsSharedImage(aImage);
if (!img) {
needsCopy = true;
// Try to get a compatible shared image from the pool
img = GetSharedImageFor(aImage);
if (!img && mActiveImageCount < (int)MAX_ACTIVE_SHARED_IMAGES) {
// If no shared image available, allocate a new one
img = AllocateSharedImageFor(aImage);
}
}
if (img && (!needsCopy || CopyDataIntoSharedImage(aImage, img))) {
// Keep a reference to the image we sent to compositor to maintain a
// correct reference count.
mImageQueue.AppendElement(aImage);
SendPublishImage(*img);
} else {
NS_WARNING("Failed to send an image to the compositor");
}
delete img;
return;
}
示例4: SendImageAsync
void ImageContainerChild::SendImageAsync(ImageContainer* aContainer,
Image* aImage)
{
if(!aContainer || !aImage) {
return;
}
if (mStop) {
return;
}
if (InImageBridgeChildThread()) {
SharedImage *img = ImageToSharedImage(aImage);
if (img) {
SendPublishImage(*img);
} else {
NS_WARNING("Failed to create a shared image!");
}
delete img;
return;
}
// Sending images and (potentially) allocating shmems must be done
// on the ImageBridgeChild thread.
Task *t = new ImageBridgeCopyAndSendTask(this, aContainer, aImage);
GetMessageLoop()->PostTask(FROM_HERE, t);
}
示例5: ImageBridgeShutdownStep1
// dispatched function
static void ImageBridgeShutdownStep1(ReentrantMonitor *aBarrier, bool *aDone)
{
ReentrantMonitorAutoEnter autoMon(*aBarrier);
MOZ_ASSERT(InImageBridgeChildThread(),
"Should be in ImageBridgeChild thread.");
MediaSystemResourceManager::Shutdown();
if (sImageBridgeChildSingleton) {
// Force all managed protocols to shut themselves down cleanly
InfallibleTArray<PCompositableChild*> compositables;
sImageBridgeChildSingleton->ManagedPCompositableChild(compositables);
for (int i = compositables.Length() - 1; i >= 0; --i) {
CompositableClient::FromIPDLActor(compositables[i])->Destroy();
}
InfallibleTArray<PTextureChild*> textures;
sImageBridgeChildSingleton->ManagedPTextureChild(textures);
for (int i = textures.Length() - 1; i >= 0; --i) {
TextureClient* client = TextureClient::AsTextureClient(textures[i]);
if (client) {
client->ForceRemove();
}
}
sImageBridgeChildSingleton->SendWillStop();
sImageBridgeChildSingleton->MarkShutDown();
// From now on, no message can be sent through the image bridge from the
// client side except the final Stop message.
}
*aDone = true;
aBarrier->NotifyAll();
}
示例6: NS_ABORT_IF_FALSE
void ImageBridgeChild::DestroyBridge()
{
NS_ABORT_IF_FALSE(!InImageBridgeChildThread(),
"This method must not be called in this thread.");
// ...because we are about to dispatch synchronous messages to the
// ImageBridgeChild thread.
if (!IsCreated()) {
return;
}
ReentrantMonitor barrier("ImageBridgeDestroyTask lock");
ReentrantMonitorAutoEnter autoMon(barrier);
bool done = false;
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(FROM_HERE,
NewRunnableFunction(&StopImageBridgeSync, &barrier, &done));
while (!done) {
barrier.Wait();
}
done = false;
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(FROM_HERE,
NewRunnableFunction(&DeleteImageBridgeSync, &barrier, &done));
while (!done) {
barrier.Wait();
}
}
示例7: MOZ_COUNT_DTOR
SharedRGBImage::~SharedRGBImage()
{
MOZ_COUNT_DTOR(SharedRGBImage);
if (mCompositable->GetAsyncID() != 0 &&
!InImageBridgeChildThread()) {
ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().drop());
ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().drop());
}
}
示例8: DeleteImageBridgeSync
// dispatched function
static void DeleteImageBridgeSync(ReentrantMonitor *aBarrier, bool *aDone)
{
ReentrantMonitorAutoEnter autoMon(*aBarrier);
NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
"Should be in ImageBridgeChild thread.");
delete sImageBridgeChildSingleton;
sImageBridgeChildSingleton = nullptr;
*aDone = true;
aBarrier->NotifyAll();
}
示例9: ReleaseImageClientNow
static void ReleaseImageClientNow(ImageClient* aClient,
PImageContainerChild* aChild)
{
MOZ_ASSERT(InImageBridgeChildThread());
if (aClient) {
aClient->Release();
}
if (aChild) {
aChild->SendAsyncDelete();
}
}
示例10: MOZ_ASSERT
//static
void ImageBridgeChild::FlushAllImages(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront)
{
if (!IsCreated()) {
return;
}
MOZ_ASSERT(aClient);
MOZ_ASSERT(!sImageBridgeChildSingleton->mShuttingDown);
MOZ_ASSERT(!InImageBridgeChildThread());
if (InImageBridgeChildThread()) {
NS_ERROR("ImageBridgeChild::FlushAllImages() is called on ImageBridge thread.");
return;
}
RefPtr<AsyncTransactionTracker> status = aClient->PrepareFlushAllImages();
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&FlushAllImagesSync, aClient, aContainer, aExceptFront, status));
status->WaitComplete();
}
示例11: ImageBridgeShutdownStep2
// dispatched function
static void ImageBridgeShutdownStep2(ReentrantMonitor *aBarrier, bool *aDone)
{
ReentrantMonitorAutoEnter autoMon(*aBarrier);
MOZ_ASSERT(InImageBridgeChildThread(),
"Should be in ImageBridgeChild thread.");
sImageBridgeChildSingleton->SendStop();
*aDone = true;
aBarrier->NotifyAll();
}
示例12: DispatchImageClientUpdate
//static
void ImageBridgeChild::DispatchImageClientUpdate(ImageClient* aClient,
ImageContainer* aContainer)
{
if (InImageBridgeChildThread()) {
UpdateImageClientNow(aClient, aContainer);
return;
}
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction<
void (*)(ImageClient*, ImageContainer*),
ImageClient*,
nsRefPtr<ImageContainer> >(&UpdateImageClientNow, aClient, aContainer));
}
示例13: MOZ_ASSERT
//static
void ImageBridgeChild::FlushAllImages(ImageClient* aClient,
ImageContainer* aContainer)
{
if (!IsCreated()) {
return;
}
MOZ_ASSERT(aClient);
MOZ_ASSERT(!sImageBridgeChildSingleton->mShuttingDown);
MOZ_ASSERT(!InImageBridgeChildThread());
if (InImageBridgeChildThread()) {
NS_ERROR("ImageBridgeChild::FlushAllImages() is called on ImageBridge thread.");
return;
}
RefPtr<AsyncTransactionWaiter> waiter = new AsyncTransactionWaiter();
// This increment is balanced by the decrement in FlushAllImagesSync
waiter->IncrementWaitCount();
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&FlushAllImagesSync, aClient, aContainer, waiter));
waiter->WaitComplete();
}
示例14: SetIdle
void ImageContainerChild::SetIdle()
{
if (mStop) return;
if (InImageBridgeChildThread()) {
return SetIdleNow();
}
Monitor barrier("SetIdle Lock");
MonitorAutoLock autoMon(barrier);
bool done = false;
GetMessageLoop()->PostTask(FROM_HERE,
NewRunnableMethod(this, &ImageContainerChild::SetIdleSync, &barrier, &done));
while (!done) {
barrier.Wait();
}
}
示例15: SendImageAsync
void ImageContainerChild::SendImageAsync(ImageContainer* aContainer,
Image* aImage)
{
if(!aContainer || !aImage) {
return;
}
if (mStop) {
return;
}
if (InImageBridgeChildThread()) {
SendImageNow(aImage);
}
// Sending images and (potentially) allocating shmems must be done
// on the ImageBridgeChild thread.
Task *t = new ImageBridgeCopyAndSendTask(this, aContainer, aImage);
GetMessageLoop()->PostTask(FROM_HERE, t);
}