Ejemplo n.º 1
0
void ImageContainerChild::DestroySharedImage(const SharedImage& aImage)
{
  NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
                    "Should be in ImageBridgeChild thread.");

  --mActiveImageCount;
  DeallocSharedImageData(this, aImage);
}
Ejemplo n.º 2
0
void ImageContainerChild::ClearSharedImagePool()
{
  NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
                    "Should be in ImageBridgeChild thread.");
  for(unsigned int i = 0; i < mSharedImagePool.Length(); ++i) {
    DeallocSharedImageData(this, *mSharedImagePool[i]);
  }
  mSharedImagePool.Clear();
}
bool ImageContainerParent::RecvFlush()
{
  SharedImage *img = RemoveSharedImage(mID);
  if (img) {
    DeallocSharedImageData(this, *img);
    delete img;
  }
  return true;
}
bool ImageContainerParent::Recv__delete__()
{
  NS_ABORT_IF_FALSE(mStop, "Should be in a stopped state when __delete__");
  SharedImage* removed = RemoveSharedImage(mID);
  if (removed) {
    DeallocSharedImageData(this, *removed);
    delete removed;
  }

  return true;
}
SharedImage*
ImageContainerChild::GetSharedImageFor(Image* aImage)
{
  while (mSharedImagePool.Length() > 0) {
    // i.e., img = mPool.pop()
    nsAutoPtr<SharedImage> img(mSharedImagePool.LastElement());
    mSharedImagePool.RemoveElementAt(mSharedImagePool.Length() - 1);

    if (SharedImageCompatibleWith(img, aImage)) {
      return img.forget();
    }
    // The cached image is stale, throw it out.
    DeallocSharedImageData(this, *img);
  }

  return nullptr;
}