bool ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize, gfxContentType aContent, uint32_t aCaps, SurfaceDescriptor* aBuffer) { if (!UsingXCompositing()) { // If we're not using X compositing, we're probably compositing on // the client side, in which case X surfaces would just slow // things down. Use Shmem instead. return false; } if (MAP_AS_IMAGE_SURFACE & aCaps) { // We can't efficiently map pixmaps as gfxImageSurface, in // general. Fall back on Shmem. return false; } gfxPlatform* platform = gfxPlatform::GetPlatform(); nsRefPtr<gfxASurface> buffer = platform->CreateOffscreenSurface(gfx::ThebesIntSize(aSize), aContent); if (!buffer || buffer->GetType() != gfxSurfaceType::Xlib) { NS_ERROR("creating Xlib front/back surfaces failed!"); return false; } gfxXlibSurface* bufferX = static_cast<gfxXlibSurface*>(buffer.get()); // Release Pixmap ownership to the layers model bufferX->ReleasePixmap(); *aBuffer = SurfaceDescriptorX11(bufferX); return true; }
bool ShadowLayerForwarder::PlatformAllocBuffer(const gfxIntSize& aSize, gfxASurface::gfxContentType aContent, SurfaceDescriptor* aBuffer) { if (!UsingXCompositing()) { // If we're not using X compositing, we're probably compositing on // the client side, in which case X surfaces would just slow // things down. Use Shmem instead. return PR_FALSE; } gfxPlatform* platform = gfxPlatform::GetPlatform(); nsRefPtr<gfxASurface> buffer = platform->CreateOffscreenSurface(aSize, aContent); if (!buffer || buffer->GetType() != gfxASurface::SurfaceTypeXlib) { NS_ERROR("creating Xlib front/back surfaces failed!"); return PR_FALSE; } gfxXlibSurface* bufferX = static_cast<gfxXlibSurface*>(buffer.get()); // Release Pixmap ownership to the layers model bufferX->ReleasePixmap(); *aBuffer = SurfaceDescriptorX11(bufferX); return PR_TRUE; }
bool X11TextureData::Serialize(SurfaceDescriptor& aOutDescriptor) { MOZ_ASSERT(mSurface); if (!mSurface) { return false; } if (!mClientDeallocation) { // Pass to the host the responsibility of freeing the pixmap. ReleasePixmap // means the underlying pixmap will not be deallocated in mSurface's // destructor. ToSurfaceDescriptor is at most called once per TextureClient. mSurface->ReleasePixmap(); } aOutDescriptor = SurfaceDescriptorX11(mSurface); return true; }