예제 #1
0
static VALUE
cr_quartz_image_surface_get_image (VALUE self)
{
  cairo_surface_t *surface;

  surface = cairo_quartz_image_surface_get_image (_SELF);
  if (!surface)
    return Qnil;
  cr_surface_check_status (surface);
  return CRSURFACE2RVAL (surface);
}
already_AddRefed<gfxImageSurface>
gfxQuartzImageSurface::GetAsImageSurface()
{
    if (!mSurfaceValid)
        return nullptr;

    cairo_surface_t *isurf = cairo_quartz_image_surface_get_image (CairoSurface());
    if (!isurf) {
        NS_WARNING ("Couldn't obtain an image surface from a QuartzImageSurface?!");
        return nullptr;
    }

    return gfxASurface::Wrap(isurf).downcast<gfxImageSurface>();
}
gfxIntSize
gfxQuartzImageSurface::ComputeSize()
{
  if (mSurfaceValid) {
    cairo_surface_t* isurf = cairo_quartz_image_surface_get_image(mSurface);
    if (isurf) {
      return gfxIntSize(cairo_image_surface_get_width(isurf),
                        cairo_image_surface_get_height(isurf));
    }
  }

  // If we reach here then something went wrong. Just use the same default
  // value as gfxASurface::GetSize.
  return gfxIntSize(-1, -1);
}
already_AddRefed<gfxImageSurface>
gfxQuartzImageSurface::GetImageSurface()
{
    if (!mSurfaceValid)
        return nsnull;

    cairo_surface_t *isurf = cairo_quartz_image_surface_get_image (CairoSurface());
    if (!isurf) {
        NS_WARNING ("Couldn't obtain an image surface from a QuartzImageSurface?!");
        return nsnull;
    }

    nsRefPtr<gfxASurface> asurf = gfxASurface::Wrap(isurf);
    gfxImageSurface *imgsurf = (gfxImageSurface*) asurf.get();
    NS_ADDREF(imgsurf);
    return imgsurf;
}