/*static*/ already_AddRefed<gfxASurface> ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode aMode, const SurfaceDescriptor& aSurface) { if (SurfaceDescriptor::TShmem != aSurface.type()) { return nullptr; } return gfxSharedQuartzSurface::Open(aSurface.get_Shmem()); }
/*static*/ already_AddRefed<gfxASurface> ShadowLayerForwarder::OpenDescriptor(const SurfaceDescriptor& aSurface) { nsRefPtr<gfxASurface> surf = PlatformOpenDescriptor(aSurface); if (surf) { return surf.forget(); } switch (aSurface.type()) { case SurfaceDescriptor::TShmem: { surf = gfxSharedImageSurface::Open(aSurface.get_Shmem()); return surf.forget(); } default: NS_RUNTIMEABORT("unexpected SurfaceDescriptor type!"); return nsnull; } }
/*static*/ already_AddRefed<gfxASurface> ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode aMode, const SurfaceDescriptor& aSurface) { if (aSurface.type() == SurfaceDescriptor::TShmem) { return gfxSharedQuartzSurface::Open(aSurface.get_Shmem()); } else if (aSurface.type() == SurfaceDescriptor::TMemoryImage) { const MemoryImage& image = aSurface.get_MemoryImage(); gfxASurface::gfxImageFormat format = static_cast<gfxASurface::gfxImageFormat>(image.format()); nsRefPtr<gfxASurface> surf = new gfxQuartzSurface((unsigned char*)image.data(), image.size(), image.stride(), format); return surf.forget(); } return nullptr; }