本文整理汇总了C++中IDirectFB::SetCooperativeLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFB::SetCooperativeLevel方法的具体用法?C++ IDirectFB::SetCooperativeLevel怎么用?C++ IDirectFB::SetCooperativeLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectFB
的用法示例。
在下文中一共展示了IDirectFB::SetCooperativeLevel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testing_multicore
int testing_multicore() {
IDirectFB *dfb = NULL;
IDirectFBSurface *surface = NULL;
DFBSurfaceDescription dsc;
pid_t n_pid = fork();
if (n_pid) {
sleep(1);
}
DFBCHECK(DirectFBInit(NULL, NULL));
DFBCHECK(DirectFBCreate(&dfb));
push_release(dfb, dfb->Release);
DFBCHECK(dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &surface ));
push_release(surface, surface->Release);
if (!n_pid) {
sleep(1);
}
sleep(2);
//DFBCHECK(surface->Release(surface));
//DFBCHECK(dfb->Release(dfb));
release_all();
if (n_pid) {
wait(NULL);
}
return 0;
}
示例2: DirectFBInit
int
main( int argc, char *argv[] )
{
DFBResult ret;
IDirectFB *dfb;
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/Resize: DirectFBInit() failed!\n" );
return ret;
}
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/Resize: DirectFBCreate() failed!\n" );
return ret;
}
/* Required for keyboard access */
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
TestResize( dfb );
/* Shutdown DirectFB. */
dfb->Release( dfb );
return ret;
}
示例3: DirectFBInit
int
main( int argc, char *argv[] )
{
DFBResult ret;
DFBSurfaceDescription desc;
IDirectFB *dfb;
IDirectFBSurface *surface;
IWater *water;
D_INFO( "Tests/Water: Starting up...\n" );
/* Initialize DirectFB including command line parsing. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
DirectFBError( "DirectFBInit() failed", ret );
return -1;
}
/* Parse the command line. */
if (!parse_command_line( argc, argv ))
return -2;
/* Create the super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
DirectFBError( "DirectFBCreate() failed", ret );
return -3;
}
/* Fill surface description, flipping primary. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
/* Set width or height? */
if (m_width > 0) {
desc.flags |= DSDESC_WIDTH;
desc.width = m_width;
}
if (m_height > 0) {
desc.flags |= DSDESC_HEIGHT;
desc.height = m_height;
}
/* Set pixel format? */
if (m_format != DSPF_UNKNOWN) {
desc.flags |= DSDESC_PIXELFORMAT;
desc.pixelformat = m_format;
}
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &surface );
if (ret) {
D_DERROR( ret, "IDirectFB::CreateSurface() failed!\n" );
dfb->Release( dfb );
return -4;
}
/* Get the extended rendering interface. */
ret = dfb->GetInterface( dfb, "IWater", NULL, dfb, (void**) &water );
if (ret) {
DirectFBError( "IDirectFB::GetInterface( 'IWater' ) failed", ret );
surface->Release( surface );
dfb->Release( dfb );
return -5;
}
D_INFO( "Tests/Water: Got render interface, running tests...\n" );
RunTest( Test_Simple, water, surface );
RunTest( Test_RenderElement, water, surface );
RunTest( Test_RenderElements, water, surface );
RunTest( Test_RenderShape, water, surface );
RunTest( Test_RenderShapes, water, surface );
D_INFO( "Tests/Water: Dumping surface...\n" );
unlink( "dfbrender.pgm" );
unlink( "dfbrender.ppm" );
surface->Dump( surface, "dfbrender", NULL );
D_INFO( "Tests/Water: Shutting down...\n" );
/* Release the render interface. */
water->Release( water );
/* Release the surface. */
surface->Release( surface );
/* Release the super interface. */
dfb->Release( dfb );
//.........这里部分代码省略.........
示例4: print_usage
int
main( int argc, char *argv[] )
{
int i;
DFBResult ret;
DFBSurfaceDescription desc;
IDirectFB *dfb;
IDirectFBSurface *dest = NULL;
const char *url = NULL;
DFBFontAttributes attributes = DFFA_NONE;
DFBSurfaceTextFlags text_flags = DSTF_TOPLEFT;
int outline_width = 0x10000;
int outline_opacity = 255;
const DFBColorID color_ids[2] = { DCID_PRIMARY, DCID_OUTLINE };
const DFBColor colors[2] = { { 0xff, 0xff, 0xff, 0xff },
{ 0xff, 0x00, 0x80, 0xff } };
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/Font: DirectFBInit() failed!\n" );
return ret;
}
/* Parse arguments. */
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
return print_usage( argv[0] );
else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
return false;
}
else if (strcmp (arg, "-o") == 0 || strcmp (arg, "--outline") == 0) {
attributes |= DFFA_OUTLINED;
text_flags |= DSTF_OUTLINE;
}
else if (strcmp (arg, "-ow") == 0 || strcmp (arg, "--outline-width") == 0) {
if (++i == argc)
return print_usage( argv[0] );
if (sscanf( argv[i], "%d", &outline_width ) != 1)
return print_usage( argv[0] );
outline_width <<= 16;
}
else if (strcmp (arg, "-oo") == 0 || strcmp (arg, "--outline-opacity") == 0) {
if (++i == argc)
return print_usage( argv[0] );
if (sscanf( argv[i], "%d", &outline_opacity ) != 1)
return print_usage( argv[0] );
}
else if (!url)
url = arg;
else
return print_usage( argv[0] );
}
/* Check if we got an URL. */
if (!url)
return print_usage( argv[0] );
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/Font: DirectFBCreate() failed!\n" );
return ret;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/Font: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/Font: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
for (i=10; i<50; i++) {
IDirectFBFont *font;
font = CreateFont( dfb, url, i, attributes, outline_width, outline_opacity );
RenderChecker( dest, 64, 64 );
dest->SetColors( dest, color_ids, colors, 2 );
dest->SetFont( dest, font );
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
nsCOMPtr<IConsole> console;
session->GetConsole(getter_AddRefs(console));
if (!console)
{
printf("Error: cannot get console!\n");
exit(-1);
}
nsCOMPtr<IDisplay> display;
console->GetDisplay(getter_AddRefs(display));
if (!display)
{
printf("Error: could not get display object!\n");
exit(-1);
}
nsCOMPtr<IKeyboard> keyboard;
nsCOMPtr<IMouse> mouse;
VBoxDirectFB *frameBuffer = NULL;
/**
* Init DirectFB
*/
IDirectFB *dfb = NULL;
IDirectFBSurface *surface = NULL;
IDirectFBInputDevice *dfbKeyboard = NULL;
IDirectFBInputDevice *dfbMouse = NULL;
IDirectFBEventBuffer *dfbEventBuffer = NULL;
DFBSurfaceDescription dsc;
int screen_width, screen_height;
DFBCHECK(DirectFBInit(&argc, &argv));
DFBCHECK(DirectFBCreate(&dfb));
DFBCHECK(dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN));
// populate our structure of supported video modes
DFBCHECK(dfb->EnumVideoModes(dfb, enumVideoModesHandler, NULL));
if (listHostModes)
{
printf("*****************************************************\n");
printf("Number of available host video modes: %u\n", numVideoModes);
for (uint32_t i = 0; i < numVideoModes; i++)
{
printf("Mode %u: xres = %u, yres = %u, bpp = %u\n", i,
videoModes[i].width, videoModes[i].height, videoModes[i].bpp);
}
printf("Note: display modes with bpp < have been filtered out\n");
printf("*****************************************************\n");
goto Leave;
}
if (useFixedVideoMode)
{
int32_t bestVideoMode = getBestVideoMode(fixedVideoMode.width,
fixedVideoMode.height,
fixedVideoMode.bpp);
// validate the fixed mode
if ((bestVideoMode == -1) ||
((fixedVideoMode.width != videoModes[bestVideoMode].width) ||
(fixedVideoMode.height != videoModes[bestVideoMode].height) ||
(fixedVideoMode.bpp != videoModes[bestVideoMode].bpp)))
{
printf("Error: the specified fixed video mode is not available!\n");
exit(-1);
}
} else
示例6: print_usage
int
main( int argc, char *argv[] )
{
DFBResult ret;
int i;
DFBSurfaceDescription desc;
IDirectFB *dfb;
IDirectFBSurface *dest = NULL;
DFBSurfacePixelFormat dest_format = DSPF_UNKNOWN;
char pixel_buffer[100*100*4];
IDirectFBSurface *source = NULL;
IDirectFBEventBuffer *keybuffer;
DFBInputEvent evt;
bool quit = false;
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: DirectFBInit() failed!\n" );
return ret;
}
/* Parse arguments. */
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
return print_usage( argv[0] );
else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
return false;
}
else if (strcmp (arg, "-d") == 0 || strcmp (arg, "--dest") == 0) {
if (++i == argc) {
print_usage (argv[0]);
return false;
}
if (!parse_format( argv[i], &dest_format ))
return false;
}
else if (strcmp (arg, "-s") == 0 || strcmp (arg, "--static") == 0) {
static_caps = DSCAPS_STATIC_ALLOC;
}
else
return print_usage( argv[0] );
}
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: DirectFBCreate() failed!\n" );
return ret;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
if (dest_format != DSPF_UNKNOWN) {
desc.flags |= DSDESC_PIXELFORMAT;
desc.pixelformat = dest_format;
}
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create an input buffer for key events */
dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS,
DFB_TRUE, &keybuffer);
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: IDirectFB::CreateSurface() for the destination failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/PreAlloc: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
/* Create a preallocated surface. */
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS | DSDESC_PREALLOCATED;
desc.width = 100;
desc.height = 100;
desc.pixelformat = DSPF_ARGB;
desc.caps = static_caps;
desc.preallocated[0].data = pixel_buffer;
desc.preallocated[0].pitch = 100 * 4;
ret = dfb->CreateSurface( dfb, &desc, &source );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: IDirectFB::CreateSurface() for the preallocated source failed!\n" );
goto out;
}
/* Before any other operation the pixel data can be written to without locking */
gen_pixels( pixel_buffer, 100 * 4, 100 );
//.........这里部分代码省略.........
示例7: main
//------------------------------------------------------------------------------
// 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.
//.........这里部分代码省略.........
示例8: print_usage
//.........这里部分代码省略.........
ret = provider->GetSurfaceDescription( provider, &desc );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
goto out;
}
if (source_format != DSPF_UNKNOWN)
desc.pixelformat = source_format;
D_INFO( "DFBTest/Blit: Source is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
/* Create a surface for the image. */
ret = dfb->CreateSurface( dfb, &desc, &source );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
ret = provider->RenderTo( provider, source, NULL );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::RenderTo() failed!\n" );
goto out;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
if (dest_format != DSPF_UNKNOWN) {
desc.flags |= DSDESC_PIXELFORMAT;
desc.pixelformat = dest_format;
}
if (dest_resize)
desc.flags |= DSDESC_WIDTH | DSDESC_HEIGHT;
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/Blit: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
for (i=0; i<100000; i++) {
int j,n = rand()%100;
for (j=0; j<n; j++) {
switch (rand()%3) {
case 0:
dest->SetDrawingFlags( dest, rand() & (DSDRAW_BLEND) );
dest->FillRectangle( dest, rand()%100, rand()%100, rand()%100, rand()%100 );
break;
case 1:
dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
DSBLIT_BLEND_COLORALPHA |
DSBLIT_COLORIZE |
DSBLIT_ROTATE90) );
dest->Blit( dest, source, NULL, rand()%100, rand()%100 );
break;
case 2:
dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
DSBLIT_BLEND_COLORALPHA |
DSBLIT_COLORIZE |
DSBLIT_ROTATE90) );
dest->StretchBlit( dest, source, NULL, NULL );
break;
}
}
dfb->WaitIdle( dfb );
dest->Flip( dest, NULL, DSFLIP_NONE );
}
out:
if (dest)
dest->Release( dest );
if (source)
source->Release( source );
if (provider)
provider->Release( provider );
/* Shutdown DirectFB. */
dfb->Release( dfb );
return ret;
}
示例9: testing_singlecore
int testing_singlecore() {
IDirectFB *dfb = NULL;
IDirectFBSurface *surface = NULL;
DFBSurfaceDescription dsc;
DFBSurfaceCapabilities caps;
int width, height;
DFBSurfacePixelFormat p_format;
int i;
DFBCHECK(DirectFBInit(NULL, NULL));
DFBCHECK(DirectFBCreate(&dfb));
push_release(dfb, dfb->Release);
DFBCHECK(dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &surface ));
push_release(surface, surface->Release);
DFBCHECK(surface->GetCapabilities(surface, &caps));
if (caps & DSCAPS_PRIMARY) {
printf("Surface Primary\n");
}
if (caps & DSCAPS_SYSTEMONLY) {
printf("Surface SystemOnly\n");
}
if (caps & DSCAPS_VIDEOONLY) {
printf("Surface VideoOnly\n");
}
if (caps & DSCAPS_DOUBLE) {
printf("Surface Double buffered\n");
}
if (caps & DSCAPS_SUBSURFACE) {
printf("Surface is a sub surface\n");
}
if (caps & DSCAPS_INTERLACED) {
printf("Surface is Interlaced\n");
}
if (caps & DSCAPS_SEPARATED) {
printf("Surface is separated\n");
}
if (caps & DSCAPS_STATIC_ALLOC) {
printf("Surface is static alloc\n");
}
if (caps & DSCAPS_TRIPLE) {
printf("Surface is triple buffered\n");
}
if (caps & DSCAPS_PREMULTIPLIED) {
printf("Surface stores premiltiplied alpha\n");
}
if (caps & DSCAPS_DEPTH) {
printf("Surface has a depth buffer\n");
}
DFBCHECK(surface->GetSize(surface, &width, &height));
printf("Surface size: %dx%d\n", width, height);
DFBCHECK(surface->GetPixelFormat(surface, &p_format));
for(i = 0; pformat_names[i].format; i++) {
if (pformat_names[i].format == p_format) {
printf("Surface pixelformat: %s\n", pformat_names[i].name);
}
}
release_all();
return 0;
}