The gfx module has these two functions:
NS_IMETHODIMP nsRenderingContextImpl::DrawImage(imgIContainer *aContainer,
.....)
NS_IMETHODIMP nsRenderingContextImpl::DrawImage(nsIImage *aImage, .....)

The aContainer function causes a dependency from gfx to libpr0n. libpr0n
depends and necko and a bunch of other things. I would like to break the
dependency of gfx on libpr0n by removing the aContainer function from gfx.

To convert aContainer to aImage you need to do the following since
containers hold animated images which need to have a snapshot taken.

  nsCOMPtr<gfxIImageFrame> iframe;
  aContainer->GetCurrentFrame(getter_AddRefs(iframe));
  if (!iframe) return NS_ERROR_FAILURE;

  nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
  if (!img) return NS_ERROR_FAILURE;

At the point where an image is drawn, the code looks like this:
context->DrawImage(aContainer, ....);

Now if I remove the DrawImage(aContainer, ...) function, could imgIContainer
be modified automatically cast to the current nsIImage and use the
DrawImage(aImage, ...) function? What about ref counts?

Would it be better to do something like this?
context->DrawImage(aContainer->GetImage(),....);

Jon Smirl
[EMAIL PROTECTED]





Reply via email to