void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) { if (data->classId() != DirectFBClass) { QPixmapData::copy(data, rect); return; } IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->surface; DFBSurfaceDescription description; description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT); description.width = rect.width(); description.height = rect.height(); src->GetPixelFormat(src, &description.pixelformat); IDirectFB *fb = QDirectFBScreen::instance()->dfb(); DFBResult result = fb->CreateSurface(fb, &description, &surface); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::copy()", result); setSerialNumber(0); return; } #ifndef QT_NO_DIRECTFB_PALETTE IDirectFBPalette *palette; src->GetPalette(src, &palette); surface->SetPalette(surface, palette); #endif surface->SetBlittingFlags(surface, DSBLIT_NOFX); const DFBRectangle blitRect = { rect.x(), rect.y(), rect.width(), rect.height() }; result = surface->Blit(surface, src, &blitRect, 0, 0); if (result != DFB_OK) DirectFBError("QDirectFBPixmapData::copy()", result); setSerialNumber(++global_ser_no); }
//------------------------------------------------------------------------------ // Unit Test main //------------------------------------------------------------------------------ int main (int argc, char **argv) { int i, j; DFBResult rle_build_databuffer_err; // File name to load logo image from char *filename = NULL; // Basic directfb elements IDirectFB *dfb = NULL; IDirectFBSurface *primary = NULL; int screen_width = 0; int screen_height = 0; // The image is to be loaded into a surface that we can blit from. IDirectFBSurface *logo = NULL; // Loading an image is done with an Image Provider. IDirectFBImageProvider *provider = NULL; // An Image provider instance can also be created from a directfb buffer IDirectFBDataBuffer *databuffer = NULL; // Surface description DFBSurfaceDescription surface_dsc; // Initialize directfb first DFBCHECK (DirectFBInit (&argc, &argv)); DFBCHECK (DirectFBCreate (&dfb)); DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)); // Create primary surface surface_dsc.flags = DSDESC_CAPS; surface_dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING; DFBCHECK (dfb->CreateSurface( dfb, &surface_dsc, &primary )); DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height)); if (argc==1) { argv[1] = "./data/directfb.rle"; argc++; } DISPLAY_INFO ("Rendering %d files\n",argc-1); for (j=1; j<argc; j++) { // // --- WE CREATE OUR IMAGE PROVIDER INSTANCE HERE // filename = argv[j]; DISPLAY_INFO ("Rendering : %s\n",filename); // We create a directfb data buffer holding RLE image contents that we // pick up from a file (could get the RLE contents from memory as well). // "rle_build_databuffer" details the process of dealing with a memory // RLE packet as a matter of fact. rle_build_databuffer_err = rle_build_databuffer (dfb, filename, &databuffer); if (rle_build_databuffer_err == DFB_OK) { // We want to create an Image Provider tied to a directfb data buffer. // DirectFB will find (or not) an Image Provider for the data type // depending on Image Providers probe method (sniffing data headers) DFBCHECK (databuffer->CreateImageProvider (databuffer, &provider)); } else { # ifdef USE_PACKET_BUILDER_ONLY DFBFAIL(rle_build_databuffer_err); # else // We could also create an Image Provider by passing a filename. // DirectFB will find (or not) an Image Provider matching the file type. DFBCHECK (dfb->CreateImageProvider (dfb, filename, &provider)); # endif } // Get a surface description from the provider. It will contain the width, // height, bits per pixel and the flag for an alphachannel if the image // has one. If the image has no alphachannel the bits per pixel is set to // the bits per pixel of the primary layer to use simple blitting without // pixel format conversion. DFBCHECK (provider->GetSurfaceDescription (provider, &surface_dsc)); // Create a surface based on the description of the provider. DFBCHECK (dfb->CreateSurface( dfb, &surface_dsc, &logo )); // Let the provider render to our surface. Image providers are supposed // to support every destination pixel format and size. If the size // differs the image will be scaled (bilinear). The last parameter allows // to specify an optional destination rectangle. We use NULL here so that // our image covers the whole logo surface. DFBCHECK (provider->RenderTo (provider, logo, NULL)); // Note: RLE Image Provider allows for direct non-scaled LUT-8 surface // rendering without any attached colormap. #ifdef CLEVER_APPROACH // Let's setup our logo surface palette outside of the RLE Image // Provider if we got a colormap from rle_build_databuffer ... if (color_palette) { IDirectFBPalette *palette; DFBCHECK (logo->GetPalette (logo, &palette)); palette->SetEntries (palette, color_palette, number_of_colors, 0); palette->Release (palette); } #endif // // --- WE GET RID OF OUR IMAGE PROVIDER INSTANCE HERE // // Release the provider, we don't need it anymore. provider->Release (provider); provider = NULL; // Destroy the databuffer as well, we don't need it anymore. rle_destroy_databuffer (databuffer); databuffer = NULL; # ifndef SUBTITLES_MODE // We want to let the logo slide in on the left and slide out on the // right. for (i = -surface_dsc.width; i < screen_width; i++) # else // We want to let the logo slide in on the right and slide out on the // left. for (i = screen_width-1; i >= -surface_dsc.width; i--) # endif { // Clear the screen. DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height)); // Blit the logo vertically centered with "i" as the X coordinate. // NULL means that we want to blit the whole surface. DFBCHECK (primary->Blit (primary, logo, NULL, i, (screen_height - surface_dsc.height) / 2)); // Flip the front and back buffer, but wait for the vertical // retrace to avoid tearing. DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC)); if (argc < 3) { usleep(1000*5); } } // Release the image. if (logo) { logo->Release (logo); } } // Release everything else primary->Release (primary); dfb->Release (dfb); return 0; }