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; }
SharedImage* ImageContainerChild::ImageToSharedImage(Image* aImage) { if (mStop) return nsnull; if (mActiveImageCount > MAX_ACTIVE_SHARED_IMAGES) { // Too many active shared images, perhaps the compositor is hanging. // Skipping current image return nsnull; } NS_ABORT_IF_FALSE(InImageBridgeChildThread(), "Should be in ImageBridgeChild thread."); SharedImage* img = PopSharedImageFromPool(); if (img) { CopyDataIntoSharedImage(aImage, img); } else { img = CreateSharedImageFromData(aImage); } mImageQueue.AppendElement(aImage); return img; }
SharedImage* ImageContainerChild::ImageToSharedImage(Image* aImage) { if (mStop) { return nullptr; } if (mActiveImageCount > (int)MAX_ACTIVE_SHARED_IMAGES) { // Too many active shared images, perhaps the compositor is hanging. // Skipping current image return nullptr; } NS_ABORT_IF_FALSE(InImageBridgeChildThread(), "Should be in ImageBridgeChild thread."); SharedImage *img = GetSharedImageFor(aImage); if (img) { CopyDataIntoSharedImage(aImage, img); } else { img = CreateSharedImageFromData(aImage); } // Keep a reference to the image we sent to compositor to maintain a // correct reference count. mImageQueue.AppendElement(aImage); return img; }