bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescription &dataBufferDescription) { IDirectFB *dfb = screen->dfb(); Q_ASSERT(dfb); DFBResult result = DFB_OK; IDirectFBDataBuffer *dataBufferPtr; if ((result = dfb->CreateDataBuffer(dfb, &dataBufferDescription, &dataBufferPtr)) != DFB_OK) { DirectFBError("QDirectFBPixmapData::fromDataBufferDescription()", result); return false; } QDirectFBPointer<IDirectFBDataBuffer> dataBuffer(dataBufferPtr); IDirectFBImageProvider *providerPtr; if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK) return false; QDirectFBPointer<IDirectFBImageProvider> provider(providerPtr); DFBImageDescription imageDescription; result = provider->GetImageDescription(provider.data(), &imageDescription); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't get image description", result); return false; } if (imageDescription.caps & DICAPS_COLORKEY) { return false; } DFBSurfaceDescription surfaceDescription; if ((result = provider->GetSurfaceDescription(provider.data(), &surfaceDescription)) != DFB_OK) { DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't get surface description", result); return false; } alpha = imageDescription.caps & DICAPS_ALPHACHANNEL; imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat(); dfbSurface = screen->createDFBSurface(QSize(surfaceDescription.width, surfaceDescription.height), imageFormat, QDirectFBScreen::TrackSurface); result = provider->RenderTo(provider.data(), dfbSurface, 0); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't render to surface", result); return false; } w = surfaceDescription.width; h = surfaceDescription.height; is_null = (w <= 0 || h <= 0); d = QDirectFBScreen::depth(imageFormat); setSerialNumber(++global_ser_no); #if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE screen->setDirectFBImageProvider(providerPtr); provider.take(); #endif return true; }
bool QDirectFbBlitterPlatformPixmap::fromDataBufferDescription(const DFBDataBufferDescription &dataBufferDescription) { DFBResult result; IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); // Create a data buffer QDirectFBPointer<IDirectFBDataBuffer> dataBuffer; result = dfb->CreateDataBuffer(dfb, &dataBufferDescription, dataBuffer.outPtr()); if (result != DFB_OK) { DirectFBError(QDFB_PRETTY, result); return false; } // Create the image provider QDirectFBPointer<IDirectFBImageProvider> provider; result = dataBuffer->CreateImageProvider(dataBuffer.data(), provider.outPtr()); if (result != DFB_OK) { DirectFBError(QDFB_PRETTY, result); return false; } // Extract image information DFBImageDescription imageDescription; result = provider->GetImageDescription(provider.data(), &imageDescription); if (result != DFB_OK) { DirectFBError(QDFB_PRETTY, result); return false; } // Can we handle this directlu? if (imageDescription.caps & DICAPS_COLORKEY) return false; DFBSurfaceDescription surfaceDescription; result = provider->GetSurfaceDescription(provider.data(), &surfaceDescription); if (result != DFB_OK) { DirectFBError(QDFB_PRETTY, result); return false; } m_alpha = imageDescription.caps & DICAPS_ALPHACHANNEL; resize(surfaceDescription.width, surfaceDescription.height); // TODO: FIXME; update d result = provider->RenderTo(provider.data(), dfbBlitter()->dfbSurface(), 0); if (result != DFB_OK) { DirectFBError(QDFB_PRETTY, result); return false; } return true; }
DFBDataBuffer::DFBDataBuffer(void* data, unsigned int dataSize) : Thread() { IDirectFB* dfb = NULL; deviceUri = NULL; deviceFd = -1; this->dataSize = dataSize; this->data = new char[dataSize]; desc.file = NULL; desc.memory.data = data; desc.memory.length = dataSize; desc.flags = (DFBDataBufferDescriptionFlags)DBDESC_MEMORY; dfb = (IDirectFB*)(LocalDeviceManager::getInstance()->getGfxRoot()); dfb->CreateDataBuffer(dfb, &desc, &dataBuffer); }