static gint gdk_directfb_get_depth (GdkDrawable *drawable) { GdkDrawableImplDirectFB *impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable); return DFB_BITS_PER_PIXEL (impl->format); }
static DFBResult dfb_sdl_set_video_mode_handler( CoreSurfaceConfig *config ) { int depth = get_pixelformat_target_depth( config->format ); Uint32 flags = SDL_HWSURFACE | SDL_RESIZABLE;// | SDL_ASYNCBLIT | SDL_FULLSCREEN; SDL_Surface *screen; if (config->caps & DSCAPS_FLIPPING) flags |= SDL_DOUBLEBUF; fusion_skirmish_prevail( &dfb_sdl->lock ); D_DEBUG_AT( SDL_Screen, " -> SDL_SetVideoMode( %dx%d, %d, 0x%08x )\n", config->size.w, config->size.h, DFB_BITS_PER_PIXEL(config->format), flags ); /* Set video mode */ screen = SDL_SetVideoMode( config->size.w, config->size.h, depth, flags ); if (!screen) { D_ERROR( "DirectFB/SDL: Couldn't set %dx%dx%d video mode: %s\n", config->size.w, config->size.h, depth, SDL_GetError()); fusion_skirmish_dismiss( &dfb_sdl->lock ); return DFB_FAILURE; } dfb_sdl->screen = screen; /* Hide SDL's cursor */ SDL_ShowCursor( SDL_DISABLE ); fusion_skirmish_dismiss( &dfb_sdl->lock ); return DFB_OK; }
static void print_usage (const char *prg_name) { int i = 0; fprintf (stderr, "\nDirectFB Layer Configuration (version %s)\n\n", DIRECTFB_VERSION); fprintf (stderr, "Usage: %s [options]\n\n", prg_name); fprintf (stderr, "Options:\n"); fprintf (stderr, " -l, --layer <id> Use the specified layer, default is primary\n"); fprintf (stderr, " -m, --mode <width>x<height> Change the resolution (pixels)\n"); fprintf (stderr, " -f, --format <pixelformat> Change the pixel format\n"); fprintf (stderr, " -b, --buffer <buffermode> Change the buffer mode (single/video/system)\n"); fprintf (stderr, " -o, --opacity <opacity> Change the layer's opacity (0-255)\n"); fprintf (stderr, " -L, --level <level> Change the layer's level\n"); fprintf (stderr, " -R, --rotate <degree> Change the layer rotation\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_HAS_ALPHA(format)) fprintf (stderr, " ALPHA"); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); ++i; } fprintf (stderr, "\n"); fprintf (stderr, "Valid buffer modes:\n"); fprintf (stderr, " FRONTONLY or 'single'\n"); fprintf (stderr, " BACKVIDEO or 'video'\n"); fprintf (stderr, " BACKSYSTEM or 'system'\n"); fprintf (stderr, " TRIPLE\n"); fprintf (stderr, " WINDOWS\n"); fprintf (stderr, "\n"); fprintf (stderr, "Specifying neither mode nor format just displays the current configuration.\n"); fprintf (stderr, "\n"); }
int wxIDirectFBSurface::GetDepth() { DFBSurfacePixelFormat format = DSPF_UNKNOWN; if ( !GetPixelFormat(&format) ) return -1; return DFB_BITS_PER_PIXEL(format); }
static DFBResult dfb_rtd_set_video_mode_handler( CoreLayerRegionConfig *config ) { #if 0 int argc = 0; char** argv = NULL; D_DEBUG( "DirectFB/RTD: layer config properties\n"); if(rfb_screen) /*!!! FIXME*/ return DFB_OK; fusion_skirmish_prevail( &dfb_rtd->lock ); /* Set video mode */ rfb_screen = rfbGetScreen(&argc, argv, config->width, config->height, DFB_BITS_PER_PIXEL(config->format)/3, 3, 4); D_DEBUG( "DirectFB/RTD: rfbGetScreen parameters: width %d height %d bitspersample %d samplesperpixel %d bytesperpixel %d\n", config->width, config->height, DFB_BITS_PER_PIXEL(config->format)/3, 3, 4); /*screen = rfbGetScreen(&argc, argv, config->width, config->height, 8, 3, 4);*/ if ( rfb_screen == NULL ) { D_ERROR( "DirectFB/RTD: Couldn't set %dx%dx%d video mode\n", config->width, config->height, DFB_COLOR_BITS_PER_PIXEL(config->format) ); fusion_skirmish_dismiss( &dfb_rtd->lock ); return DFB_FAILURE; } if(DFB_COLOR_BITS_PER_PIXEL(config->format) == DSPF_RGB16) { rfb_screen->serverFormat.redShift = 11; rfb_screen->serverFormat.greenShift = 5; rfb_screen->serverFormat.blueShift = 0; rfb_screen->serverFormat.redMax = 31; rfb_screen->serverFormat.greenMax = 63; rfb_screen->serverFormat.blueMax = 31; } /* screen->serverFormat.trueColour=FALSE; */ rfb_screen->frameBuffer = malloc(rfb_screen->width * rfb_screen->height * rfb_screen->depth / 8) ; if ( ! rfb_screen->frameBuffer ) { fusion_skirmish_dismiss( &dfb_rtd->lock ); return DFB_NOSYSTEMMEMORY; } fusion_skirmish_dismiss( &dfb_rtd->lock ); #endif return DFB_OK; }
static u32 dspfToCmdBpp(DFBSurfacePixelFormat pf) { switch (DFB_BITS_PER_PIXEL(pf)) { case 16: return SIS315_2D_CMD_CFB_16; case 32: return SIS315_2D_CMD_CFB_32; default: return SIS315_2D_CMD_CFB_8; } }
static u16 dspfToSrcColor(DFBSurfacePixelFormat pf) { switch (DFB_BITS_PER_PIXEL(pf)) { case 16: return 0x8000; case 32: return 0xc000; default: return 0x0000; } }
static inline int get_pixelformat_target_depth( DFBSurfacePixelFormat format ) { switch (format) { case DSPF_NV16: return 16; default: break; } return DFB_BITS_PER_PIXEL( format ); }
static int print_usage( const char *prg ) { int i = 0; fprintf (stderr, "\n"); fprintf (stderr, "== DirectFB Blitting Test (version %s) ==\n", DIRECTFB_VERSION); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_HAS_ALPHA(format)) fprintf (stderr, " ALPHA"); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); ++i; } fprintf (stderr, "\n"); fprintf (stderr, "\n"); fprintf (stderr, "Usage: %s [options]\n", prg); fprintf (stderr, "\n"); fprintf (stderr, "Options:\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, " -s, --source <pixelformat> Source pixel format\n"); fprintf (stderr, " -d, --dest <pixelformat> Destination pixel format\n"); fprintf (stderr, " -r, --resize Set destination from source size\n"); fprintf (stderr, " -b, --benchmark Enable benchmarking mode\n"); fprintf (stderr, " -R, --rerender Rerender before every blit (benchmark)\n"); return -1; }
static int print_usage( const char *prg ) { int i = 0; fprintf (stderr, "\n"); fprintf (stderr, "== DirectFB Font Test (version %s) ==\n", DIRECTFB_VERSION); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_HAS_ALPHA(format)) fprintf (stderr, " ALPHA"); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); ++i; } fprintf (stderr, "\n"); fprintf (stderr, "\n"); fprintf (stderr, "Usage: %s [options] <file>\n", prg); fprintf (stderr, "\n"); fprintf (stderr, "Options:\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, " -o, --outline Render outlined fonts\n"); fprintf (stderr, " -ow, --outline-width <width> Change outline width (default 1)\n"); fprintf (stderr, " -oo, --outline-opacity <opacity> Change outline opacity (default 255)\n"); return -1; }
static int print_usage( const char *prg ) { int i = 0; fprintf (stderr, "\n"); fprintf (stderr, "== DirectFB Fill Rectangle Test (version %s) ==\n", DIRECTFB_VERSION); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_HAS_ALPHA(format)) fprintf (stderr, " ALPHA"); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); ++i; } fprintf (stderr, "\n"); fprintf (stderr, "\n"); fprintf (stderr, "Usage: %s [options]\n", prg); fprintf (stderr, "\n"); fprintf (stderr, "Options:\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, " -d, --dest <pixelformat> Destination pixel format\n"); fprintf (stderr, " -s, --static Use DSCAPS_STATIC_ALLOC\n"); return -1; }
wxVideoMode wxIDirectFBDisplayLayer::GetVideoMode() { DFBDisplayLayerConfig cfg; if ( !GetConfiguration(&cfg) ) return wxVideoMode(); // invalid if ( !((cfg.flags & DLCONF_WIDTH) && (cfg.flags & DLCONF_HEIGHT) && (cfg.flags & DLCONF_PIXELFORMAT)) ) return wxVideoMode(); // invalid return wxVideoMode ( cfg.width, cfg.height, DFB_BITS_PER_PIXEL(cfg.pixelformat) ); }
static unsigned char * directfb_fb_init_driver (unsigned char *param, unsigned char *display) { DFBDisplayLayerConfig config; DFBResult ret; /*if (dfb) return NULL; DirectFBInit (&g_argc, (char ***) &g_argv); ret = DirectFBCreate (&dfb); if (ret) { char message[128]; snprintf (message, sizeof (message), "%s\n", DirectFBErrorString (ret)); return stracpy (message); }*/ dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer); layer->GetConfiguration (layer, &config); pixelformat = config.pixelformat; directfb_driver.depth = (((DFB_BYTES_PER_PIXEL (pixelformat) & 0x7)) | ((DFB_BITS_PER_PIXEL (pixelformat) & 0x1F) << 3)); /* endian test */ if (htons (0x1234) == 0x1234) directfb_driver.depth |= 0x100; directfb_driver.x = config.width; directfb_driver.y = config.height; memset (directfb_hash_table, 0, sizeof (directfb_hash_table)); arrow = NULL; return NULL; }
static void print_usage (const char *prg_name) { int i = 0; fprintf (stderr, "\nDirectFB Render Test (version %s)\n\n", DIRECTFB_VERSION); fprintf (stderr, "Usage: %s [options]\n\n", prg_name); fprintf (stderr, "Options:\n"); fprintf (stderr, " -m, --mode <width>x<height> Set test surface size (default 800x600)\n"); fprintf (stderr, " -f, --format <pixelformat> Change the pixel format\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_HAS_ALPHA(format)) fprintf (stderr, " ALPHA"); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); ++i; } fprintf (stderr, "\n"); }
static void print_usage (const char *prg_name) { int i = 0; fprintf (stderr, "\nDirectFB Glyph Image File Format Tool (version %s)\n\n", DIRECTFB_VERSION); fprintf (stderr, "Usage: %s [options]\n\n", prg_name); fprintf (stderr, "Options:\n"); fprintf (stderr, " -f, --format <pixelformat> Choose the pixel format (default ARGB)\n"); fprintf (stderr, " -s, --sizes <s1>[,s2...] Choose sizes to generate glyph images for\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats with alpha:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; if (DFB_PIXELFORMAT_HAS_ALPHA(format)) { fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); } ++i; } fprintf (stderr, "\n"); }
static DFBResult sh_du_set_region( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags updated, CoreSurface *surface, CorePalette *palette, CoreSurfaceBufferLock *left_lock, CoreSurfaceBufferLock *right_lock ) { DFBResult ret; SHGfxDriverData *drv; SHDuLayerData *lyr; u32 *pal, dirty; D_DEBUG_AT( SH_DU_LAYER, "%s( %u, 0x%x, 0x%lx )\n", __FUNCTION__, dfb_layer_id( layer ), updated, D_FLAGS_IS_SET( updated, CLRCF_SURFACE ) ? left_lock->phys : 0 ); D_UNUSED_P( region_data ); D_UNUSED_P( surface ); D_UNUSED_P( right_lock ); drv = (SHGfxDriverData *)driver_data; lyr = (SHDuLayerData *)layer_data; pal = NULL; dirty = 0u; /* color palette */ if (D_FLAGS_IS_SET( updated, CLRCF_PALETTE ) && palette) { unsigned int i; if (palette->num_entries > 256) return DFB_UNSUPPORTED; pal = malloc(256 * sizeof(u32)); if (!pal) return DFB_NOSYSTEMMEMORY; for (i = 0; i < palette->num_entries; i++) pal[i] = SH_DU_COLOR_TO_PALETTE(palette->entries[i]); while (i < 256) pal[i++] = 0u; } /* buffer address and stride */ if (D_FLAGS_IS_SET( updated, CLRCF_SURFACE )) { u32 stride; stride = (u32)(left_lock->pitch * 8); stride /= DFB_BITS_PER_PIXEL( left_lock->buffer->format ); if (lyr->plane.stride != stride) { lyr->plane.stride = stride; SH_DU_PLANE_SET_DIRTY( dirty, STRIDE ); } if (lyr->plane.pa0 != left_lock->phys) { lyr->plane.pa0 = left_lock->phys; SH_DU_PLANE_SET_DIRTY( dirty, PA0 ); } } /* area */ if (D_FLAGS_IS_SET( updated, CLRCF_WIDTH | CLRCF_HEIGHT | CLRCF_SOURCE | CLRCF_DEST )) { u32 sx, sy, dx, dy, w, h; if (D_FLAGS_IS_SET( updated, CLRCF_WIDTH )) { D_ASSERT( config->width > 0 ); lyr->width = config->width; } if (D_FLAGS_IS_SET( updated, CLRCF_HEIGHT )) { D_ASSERT( config->height > 0 ); lyr->height = config->height; } if (D_FLAGS_IS_SET( updated, CLRCF_SOURCE )) { D_ASSERT( config->source.x >= 0 ); D_ASSERT( config->source.y >= 0 ); lyr->sx = config->source.x; lyr->sy = config->source.y; } if (D_FLAGS_IS_SET( updated, CLRCF_DEST )) { lyr->dx = config->dest.x; lyr->dy = config->dest.y; } if (lyr->dx >= 0) { w = (u32)lyr->width; sx = (u32)lyr->sx; dx = (u32)lyr->dx; } else { w = (lyr->width + lyr->dx) <= 0 ? 0u : (u32)(lyr->width + lyr->dx); sx = (u32)(lyr->sx - lyr->dx); dx = 0u; } if (lyr->dy >= 0) { h = (u32)lyr->height; sy = (u32)lyr->sy; dy = (u32)lyr->dy; } else { h = (lyr->height + lyr->dy) <= 0 ? 0u : (u32)(lyr->height + lyr->dy); sy = (u32)(lyr->sy - lyr->dy); dy = 0u; } if (lyr->plane.width != w) { lyr->plane.width = w; SH_DU_PLANE_SET_DIRTY( dirty, WIDTH ); } if (lyr->plane.height != h) { lyr->plane.height = h; SH_DU_PLANE_SET_DIRTY( dirty, HEIGHT ); } if (lyr->plane.sx != sx) { lyr->plane.sx = sx; SH_DU_PLANE_SET_DIRTY( dirty, SX ); } if (lyr->plane.sy != sy) { lyr->plane.sy = sy; SH_DU_PLANE_SET_DIRTY( dirty, SY ); } if (lyr->plane.dx != dx) { lyr->plane.dx = dx; SH_DU_PLANE_SET_DIRTY( dirty, DX ); } if (lyr->plane.dy != dy) { lyr->plane.dy = dy; SH_DU_PLANE_SET_DIRTY( dirty, DY ); } } /* mode and opacity */ if (D_FLAGS_IS_SET( updated, CLRCF_FORMAT | CLRCF_OPTIONS | CLRCF_OPACITY )) { u32 mode, opacity; mode = lyr->plane.mode; opacity = lyr->plane.opacity; if (D_FLAGS_IS_SET( updated, CLRCF_OPACITY )) lyr->opacity = config->opacity; if (D_FLAGS_IS_SET( updated, CLRCF_OPTIONS )) { if (D_FLAGS_IS_SET( config->options, DLOP_ALPHACHANNEL )) { D_FLAGS_SET( mode, SH_DU_PMR_BLEND ); D_FLAGS_CLEAR( opacity, SH_DU_PALPHAR_ABIT_IGNORE ); D_FLAGS_SET( opacity, SH_DU_PALPHAR_PALETTE ); } else if (D_FLAGS_IS_SET( config->options, DLOP_OPACITY )) { D_FLAGS_SET( mode, SH_DU_PMR_BLEND ); D_FLAGS_SET( opacity, SH_DU_PALPHAR_ABIT_IGNORE ); D_FLAGS_CLEAR( opacity, SH_DU_PALPHAR_PALETTE ); } else { D_FLAGS_CLEAR( mode, SH_DU_PMR_BLEND ); } if (D_FLAGS_IS_SET( config->options, DLOP_SRC_COLORKEY )) D_FLAGS_CLEAR( mode, SH_DU_PMR_NOSRCKEY ); else D_FLAGS_SET( mode, SH_DU_PMR_NOSRCKEY ); } if (D_FLAGS_IS_SET( updated, CLRCF_FORMAT )) { mode &= ~SH_DU_PMR_DDF_MASK; switch (config->format) { case DSPF_RGB16: mode |= SH_DU_PMR_DDF565; break; case DSPF_ARGB1555: mode |= SH_DU_PMR_DDF1555; break; default: D_ASSERT( config->format == DSPF_LUT8 ); mode |= SH_DU_PMR_DDF8; break; } } if (D_FLAGS_IS_SET( mode, SH_DU_PMR_BLEND )) { if (D_FLAGS_IS_SET( opacity, SH_DU_PALPHAR_PALETTE )) /* pixel alpha blending */ opacity |= SH_DU_PALPHAR_ALPHA_MASK; else /* const alpha blending */ opacity = (opacity & ~SH_DU_PALPHAR_ALPHA_MASK) | (u32)lyr->opacity; } if (lyr->plane.opacity != opacity) { lyr->plane.opacity = opacity; SH_DU_PLANE_SET_DIRTY( dirty, OPACITY ); } if (lyr->plane.mode != mode) { lyr->plane.mode = mode; SH_DU_PLANE_SET_DIRTY( dirty, MODE ); } } /* src color key */ if (D_FLAGS_IS_SET( updated, CLRCF_SRCKEY )) lyr->ckey = config->src_key; if (D_FLAGS_IS_SET( updated, CLRCF_SRCKEY | CLRCF_FORMAT )) { u32 ddf, ckey; ddf = lyr->plane.mode & SH_DU_PMR_DDF_MASK; if (ddf == SH_DU_PMR_DDF8) { ckey = (u32)lyr->ckey.index; if (lyr->plane.ckey8 != ckey) { lyr->plane.ckey8 = ckey; SH_DU_PLANE_SET_DIRTY( dirty, CKEY8 ); } } else { ckey = (ddf == SH_DU_PMR_DDF565) ? SH_DU_COLORKEY_TO_RGB565( lyr->ckey ) : SH_DU_COLORKEY_TO_ARGB1555( lyr->ckey ); if (lyr->plane.ckey16 != ckey) { lyr->plane.ckey16 = ckey; SH_DU_PLANE_SET_DIRTY( dirty, CKEY16 ); } } } ret = (dirty || pal) ? update_layer( drv, lyr, dirty, pal ) : DFB_OK; if (pal) free( pal ); return ret; }
static DFBResult sdlAllocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { DFBResult ret; CoreSurface *surface; SDLAllocationData *alloc = alloc_data; D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); surface = buffer->surface; D_MAGIC_ASSERT( surface, CoreSurface ); if (surface->type & CSTF_LAYER) { dfb_sdl->screen = NULL; /* clear? */ ret = dfb_sdl_set_video_mode( dfb_sdl_core, &surface->config ); if (ret) { D_DERROR( ret, "SDL/Surface: dfb_sdl_set_video_mode() failed!\n" ); return ret; } D_ASSERT( dfb_sdl->screen != NULL ); if (!dfb_sdl->screen) { D_ERROR( "SDL/Surface: No screen surface!?\n" ); return DFB_BUG; } alloc->sdl_surf = dfb_sdl->screen; D_DEBUG_AT( SDL_Pool, " -> screen surface %dx%d, %d, 0x%08x, pitch %d\n", dfb_sdl->screen->w, dfb_sdl->screen->h, dfb_sdl->screen->format->BitsPerPixel, dfb_sdl->screen->flags, dfb_sdl->screen->pitch ); allocation->flags |= CSALF_ONEFORALL; } else { DFBSurfacePixelFormat format = surface->config.format; Uint32 flags = SDL_HWSURFACE;// | SDL_ASYNCBLIT | SDL_FULLSCREEN; Uint32 rmask; Uint32 gmask; Uint32 bmask; Uint32 amask; if (surface->config.caps & DSCAPS_FLIPPING) flags |= SDL_DOUBLEBUF; switch (format) { case DSPF_A8: rmask = 0x00; gmask = 0x00; bmask = 0x00; amask = 0xff; break; case DSPF_RGB16: rmask = 0xf800; gmask = 0x07e0; bmask = 0x001f; amask = 0x0000; break; case DSPF_RGB32: rmask = 0x00ff0000; gmask = 0x0000ff00; bmask = 0x000000ff; amask = 0x00000000; break; case DSPF_ARGB: rmask = 0x00ff0000; gmask = 0x0000ff00; bmask = 0x000000ff; amask = 0xff000000; break; default: D_ERROR( "SDL/Surface: %s() has no support for %s!\n", __FUNCTION__, dfb_pixelformat_name(format) ); return DFB_UNSUPPORTED; } D_DEBUG_AT( SDL_Pool, " -> SDL_CreateRGBSurface( 0x%08x, " "%dx%d, %d, 0x%08x, 0x%08x, 0x%08x, 0x%08x )\n", flags, surface->config.size.w, surface->config.size.h, DFB_BITS_PER_PIXEL(format), rmask, gmask, bmask, amask ); alloc->sdl_surf = SDL_CreateRGBSurface( flags, surface->config.size.w, surface->config.size.h, DFB_BITS_PER_PIXEL(format), rmask, gmask, bmask, amask ); if (!alloc->sdl_surf) { D_ERROR( "SDL/Surface: SDL_CreateRGBSurface( 0x%08x, " "%dx%d, %d, 0x%08x, 0x%08x, 0x%08x, 0x%08x ) failed!\n", flags, surface->config.size.w, surface->config.size.h, DFB_BITS_PER_PIXEL(format), rmask, gmask, bmask, amask ); return DFB_FAILURE; } } D_MAGIC_SET( alloc, SDLAllocationData ); return DFB_OK; }
static void print_usage (const char *prg_name) { int i = 0; fprintf (stderr, "\n"); fprintf (stderr, "== DirectFB Window Test (version %s) ==\n", DIRECTFB_VERSION); fprintf (stderr, "\n"); fprintf (stderr, "Known pixel formats:\n"); while (format_names[i].format != DSPF_UNKNOWN) { DFBSurfacePixelFormat format = format_names[i].format; fprintf (stderr, " %-10s %2d bits, %d bytes", format_names[i].name, DFB_BITS_PER_PIXEL(format), DFB_BYTES_PER_PIXEL(format)); if (DFB_PIXELFORMAT_HAS_ALPHA(format)) fprintf (stderr, " ALPHA"); if (DFB_PIXELFORMAT_IS_INDEXED(format)) fprintf (stderr, " INDEXED"); if (DFB_PLANAR_PIXELFORMAT(format)) { int planes = DFB_PLANE_MULTIPLY(format, 1000); fprintf (stderr, " PLANAR (x%d.%03d)", planes / 1000, planes % 1000); } fprintf (stderr, "\n"); ++i; } fprintf (stderr, "\n"); fprintf (stderr, "Known window capabilities:\n"); for (i=0; caps_names[i].capability != DWCAPS_NONE; i++) fprintf (stderr, " %s\n", caps_names[i].name); fprintf (stderr, "\n"); fprintf (stderr, "Known window options:\n"); for (i=0; options_names[i].option != DWOP_NONE; i++) fprintf (stderr, " %s\n", options_names[i].name); fprintf (stderr, "\n"); fprintf (stderr, "\n"); fprintf (stderr, "Usage: %s [options]\n", prg_name); fprintf (stderr, "\n"); fprintf (stderr, "Options:\n"); fprintf (stderr, " -h, --help Show this help message\n"); fprintf (stderr, " -v, --version Print version information\n"); fprintf (stderr, " -T, --top-level <toplevel_id> WindowID (skips top creation)\n"); fprintf (stderr, " -W, --wait-at-end Wait at the end (don't exit)\n"); fprintf (stderr, "\n"); fprintf (stderr, "Top window:\n"); fprintf (stderr, " -r, --run <test> Run test (see list below)\n"); fprintf (stderr, " -p, --pos <posx>,<posy> Position (%d,%d)\n", m_desc_top.posx, m_desc_top.posy); fprintf (stderr, " -s, --size <width>x<height> Size (%dx%d)\n", m_desc_top.width, m_desc_top.height); fprintf (stderr, " -f, --format <pixelformat> Pixel Format (%s)\n", dfb_pixelformat_name(m_desc_top.pixelformat)); fprintf (stderr, " -c, --caps <window_caps> Capabilities (NONE)\n"); fprintf (stderr, " -l, --color <aarrggbb> Fixed Color (NONE)\n"); fprintf (stderr, " -o, --option <window_option> Options (NONE)\n"); fprintf (stderr, " -a, --associate <parent_id> Association (N/A)\n"); fprintf (stderr, "\n"); fprintf (stderr, "Sub window:\n"); fprintf (stderr, " -R, --sub-run <test> Run test (see list below)\n"); fprintf (stderr, " -P, --sub-pos <posx>,<posy> Position (%d,%d)\n", m_desc_sub.posx, m_desc_sub.posy); fprintf (stderr, " -S, --sub-size <width>x<height> Size (%dx%d)\n", m_desc_sub.width, m_desc_sub.height); fprintf (stderr, " -F, --sub-format <pixelformat> Format (%s)\n", dfb_pixelformat_name(m_desc_sub.pixelformat)); fprintf (stderr, " -C, --sub-caps <window_caps> Capabilities (NONE)\n"); fprintf (stderr, " -L, --sub-color <aarrggbb> Fixed Color (NONE)\n"); fprintf (stderr, " -O, --sub-option <window_option> Options (NONE)\n"); fprintf (stderr, " -A, --sub-associate <parent_id> Association (N/A)\n"); fprintf (stderr, "\n"); fprintf (stderr, "Available tests:\n"); for (i=0; i<D_ARRAY_SIZE(m_tests); i++) fprintf (stderr, " %s\n", m_tests[i].name); fprintf (stderr, "\n"); }