当前位置: 首页>>代码示例>>C++>>正文


C++ IDirectFBSurface::GetSize方法代码示例

本文整理汇总了C++中IDirectFBSurface::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFBSurface::GetSize方法的具体用法?C++ IDirectFBSurface::GetSize怎么用?C++ IDirectFBSurface::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirectFBSurface的用法示例。


在下文中一共展示了IDirectFBSurface::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OpenDisplay

static int OpenDisplay(vout_display_t *vd)
{
    vout_display_sys_t *sys = vd->sys;

    DFBSurfaceDescription dsc;
    /*dsc.flags = DSDESC_CAPS | DSDESC_HEIGHT | DSDESC_WIDTH;*/
    dsc.flags = DSDESC_CAPS;
    dsc.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
    /*dsc.width = 352;*/
    /*dsc.height = 240;*/

    IDirectFB *directfb = NULL;
    if (DirectFBCreate(&directfb) != DFB_OK || !directfb)
        return VLC_EGENERIC;
    sys->directfb = directfb;

    IDirectFBSurface *primary = NULL;
    if (directfb->CreateSurface(directfb, &dsc, &primary) || !primary)
        return VLC_EGENERIC;
    sys->primary = primary;

    primary->GetSize(primary, &sys->width, &sys->height);
    primary->GetPixelFormat(primary, &sys->pixel_format);
    primary->FillRectangle(primary, 0, 0, sys->width, sys->height);
    primary->Flip(primary, NULL, 0);

    return VLC_SUCCESS;
}
开发者ID:shanewfx,项目名称:vlc-arib,代码行数:28,代码来源:directfb.c

示例2: Initialise

     void Initialise( IDirectFB        dfb,
                      IDirectFBSurface surface,
                      bool             depth )
     {
          EGLint major, minor, nconfigs;

          EGLint attribs[] = {
               EGL_BUFFER_SIZE,     EGL_DONT_CARE,
               EGL_ALPHA_SIZE,      0,
               EGL_RED_SIZE,        0,
               EGL_GREEN_SIZE,      0,
               EGL_BLUE_SIZE,       0,
               EGL_DEPTH_SIZE,      depth ? 16 : 0,
               EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
               EGL_SURFACE_TYPE,    0,
               EGL_NONE
          };

          EGLint context_attrs[] = {
               EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE
          };

          EGLint surface_attrs[] = {
               EGL_RENDER_BUFFER, EGL_BACK_BUFFER, EGL_NONE
          };


          // get display
          EGL_CHECK((egl_display = eglGetDisplay( (EGLNativeDisplayType) dfb.iface )) == EGL_NO_DISPLAY)

          CreateImageKHR             = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress( "eglCreateImageKHR" );
          DestroyImageKHR            = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress( "eglDestroyImageKHR" );
          GetConfigAttribsDIRECTFB   = (PFNEGLGETCONFIGATTRIBSDIRECTFB) eglGetProcAddress( "eglGetConfigAttribsDIRECTFB" );
          EGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress( "glEGLImageTargetTexture2DOES" );

          // init
          EGL_CHECK(!eglInitialize( egl_display, &major, &minor ))

          GetConfigAttribsDIRECTFB( egl_display, (EGLNativePixmapType) surface.iface, attribs, 0 );

          // choose config
          EGL_CHECK(!eglChooseConfig( egl_display, attribs, &egl_config, 1, &nconfigs ))

          // create a surface
          EGL_CHECK((egl_surface = eglCreateWindowSurface( egl_display, egl_config, (EGLNativeWindowType) surface.iface, surface_attrs )) == EGL_NO_SURFACE)

          EGL_CHECK(eglBindAPI( EGL_OPENGL_ES_API ) != EGL_TRUE)

          // create context
          EGL_CHECK((egl_context = eglCreateContext( egl_display, egl_config, EGL_NO_CONTEXT, context_attrs )) == EGL_NO_CONTEXT)

          EGL_CHECK(eglMakeCurrent( egl_display, egl_surface, egl_surface, egl_context ) != EGL_TRUE)

          eglSwapInterval( egl_display, 1 );

          size = surface.GetSize();

          /* Setup the viewport */
          glViewport( 0, 0, size.w, size.h );
     }
开发者ID:Distrotech,项目名称:DirectFB,代码行数:60,代码来源:dfbtest_egl_utils.cpp

示例3: l_GetSize

static int l_GetSize (lua_State* L)
{
	// [ sfc ]
	int width, height;
	IDirectFBSurface* sfc = * (IDirectFBSurface**) luaL_checkudata(L, 1, "ldirectfb.IDirectFBSurface");
	DFBCHECK (sfc->GetSize (sfc, &width, &height));
	lua_pushnumber(L, width);   // [ sfc | width ]
	lua_pushnumber(L, height);  // [ sfc | width | height ]
	return 2;
}
开发者ID:fsantanna,项目名称:ldirectfb,代码行数:10,代码来源:IDirectFBSurface.c

示例4: main

int main( int argc, char *argv[] )
{
     int                   quit = 0;
     pthread_t             render_loop_thread = -1;

     IDirectFBSurface     *primary;
     IDirectFBEventBuffer *buffer;

     DFBSurfaceDescription dsc;


     srand((long)time(0));

     DFBCHECK(DirectFBInit( &argc, &argv ));

     /* create the super interface */
     DFBCHECK(DirectFBCreate( &dfb ));

     /* get an interface to the primary keyboard and create an
        input buffer for it */
     DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &buffer ));

     /* set our cooperative level to DFSCL_FULLSCREEN for exclusive access to
        the primary layer */
     dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );

     /* get the primary surface, i.e. the surface of the primary layer we have
        exclusive access to */
     dsc.flags = DSDESC_CAPS;
     dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE;

     DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ));

     DFBCHECK(primary->GetSize( primary, &xres, &yres ));

     /* load font */
     {
          DFBFontDescription desc;

          desc.flags = DFDESC_HEIGHT;
          desc.height = yres/10;

          DFBCHECK(dfb->CreateFont( dfb, FONT, &desc, &font ));
          DFBCHECK(primary->SetFont( primary, font ));
     }

     projection = matrix_new_perspective( 400 );
     camera = matrix_new_identity();

     load_stars();

     generate_starfield();

     pthread_mutex_lock( &render_start );
     pthread_mutex_lock( &render_finish );
     pthread_create( &render_loop_thread, NULL, render_loop, (void*)primary );

     /* main loop */
     while (!quit) {
          static float  translation[3] = { 0, 0, 0 };
          DFBInputEvent evt;

          /* transform world to screen coordinates */
          transform_starfield();

          /* start rendering before waiting for events */
          start_rendering();


          buffer->WaitForEvent( buffer );

          /* process event buffer */
          while (buffer->GetEvent( buffer, DFB_EVENT(&evt)) == DFB_OK) {
               if (evt.type == DIET_KEYPRESS) {
                    switch (evt.key_id) {
                         case DIKI_ESCAPE:
                              /* quit main loop */
                              quit = 1;
                              break;

                         case DIKI_LEFT:
                              translation[0] =  10;
                              break;

                         case DIKI_RIGHT:
                              translation[0] = -10;
                              break;

                         case DIKI_UP:
                              translation[2] = -10;
                              break;

                         case DIKI_DOWN:
                              translation[2] =  10;
                              break;

                         default:
                              break;
                    }
               } else
//.........这里部分代码省略.........
开发者ID:geekmaster,项目名称:buildroot-kindle,代码行数:101,代码来源:main.c

示例5: 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 );
//.........这里部分代码省略.........
开发者ID:lelou6666,项目名称:DirectFB-1.6.3-ab,代码行数:101,代码来源:dfbtest_font.c

示例6:

static void *handle_record_button(DirectThread *thread, void *arg)
{
	IDirectFBSurface *surface = arg;
	IDirectFBFont 		*font, *font_s;
	DFBFontDescription 	font_desc;
	bool local_flg = false;
	int width, height;
	int font_big_height, font_little_height;
	
	char font_file[50] = "/misc/font/wqy-zenhei.ttc";
	
	DFBCHECK(surface->GetSize(surface, &width, &height));
	
	font_big_height = 48;
	while(font_big_height > (height / 2))
	{
		font_big_height -= 4;
	}
	font_desc.flags = DFDESC_HEIGHT;
	font_desc.height = font_big_height;
	DFBCHECK(dfb->CreateFont( dfb, font_file,  &font_desc, &font));
	
	font_little_height = 32;
	while(font_little_height > (height / 4))
	{
		font_little_height -= 4;
	}
	font_desc.height = font_little_height;
	DFBCHECK(dfb->CreateFont( dfb, font_file,  &font_desc, &font_s));
	
	printf("font size is %d %d\n", font_big_height, font_little_height);
	
	DFBCHECK(surface->SetFont(surface, font_s));
	
	DFBCHECK(surface->SetColor(surface, 0x8C, 0x8C, 0x8C, 0xff));
	DFBCHECK(surface->DrawString(surface, "点击录音", -1, width / 2, 0, DSTF_TOPCENTER));
	
	DFBCHECK(surface->SetColor(surface, 0x41, 0x41, 0x41, 0xff));
	DFBCHECK(surface->DrawString(surface, "测试TP请避开此区域", -1, width / 2, height / 4, DSTF_TOPCENTER));
	
	DFBCHECK(surface->SetFont(surface, font));
	DFBCHECK(surface->SetColor(surface, 0xE3, 0x6C, 0x4C, 0xff));
	DFBCHECK(surface->DrawString(surface, "状态:停止录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
	DFBCHECK(surface->Flip(surface, NULL, 0));
	while(true)
	{
		if(record_flg != local_flg)
		{
			local_flg = record_flg;
			DFBCHECK(surface->SetColor(surface, 0xff, 0xff, 0xff, 0xff));
			DFBCHECK(surface->FillRectangle(surface, 0 , height / 2, width, font_big_height + 4));  //need fix
			DFBCHECK(surface->SetColor(surface, 0xE3, 0x6C, 0x4C, 0xff));
			if(local_flg)
			{
				DFBCHECK(surface->DrawString(surface, "状态:正在录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
			}
			else
			{
				DFBCHECK(surface->DrawString(surface, "状态:停止录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
			}
			DFBCHECK(surface->Flip(surface, NULL, 0));
		}
		direct_thread_sleep(100000);
	}
	
	font->Release(font);
	font_s->Release(font_s);
}
开发者ID:vonfritz,项目名称:owl,代码行数:68,代码来源:test_pcba.c

示例7: render

void render()
{
    IDirectFBImageProvider *provider;
	IDirectFBSurface *logoSurface;
	IDirectFBFont *fontInterface;
	DFBFontDescription fontDesc;
	char imageName[15];
	int32_t logoHeight;
	int32_t logoWidth;
	char prog[32];
	char date[32];
	char telxt[32];
	char audio[32];
	char video[32];
	
    // Fetch the screen size and clear screen.    
    DFBCHECK(primary->SetColor(primary, 0x00, 0x00, 0x00, 0x00));                               
	DFBCHECK(primary->FillRectangle(primary, 0, 0, screenWidth, screenHeight));
	
	if (volumeBar.visible)	
	{
	    // Make a new name.
	    sprintf(imageName, "volume_%hu.png", volumeBar.volume);
	
        // Read image, prepare surface descriptor and render image to given surface.
	    DFBCHECK(dfbInterface->CreateImageProvider(dfbInterface, imageName, &provider));
	    DFBCHECK(provider->GetSurfaceDescription(provider, &surfaceDesc));
	    DFBCHECK(dfbInterface->CreateSurface(dfbInterface, &surfaceDesc, &logoSurface));
	    DFBCHECK(provider->RenderTo(provider, logoSurface, NULL));
	    provider->Release(provider);
	
        // Fetch the logo size and add it to the screen buffer. 
	    DFBCHECK(logoSurface->GetSize(logoSurface, &logoWidth, &logoHeight));
	    DFBCHECK(primary->Blit(primary, logoSurface,
	        NULL, VOLUME_X_COOR, VOLUME_Y_COOR));   
    } 
    
    if (infoBar.visible)
    {
        // Prepare strings for info bar.
	    sprintf(prog, "Program %hu", infoBar.channelNumber);
	    sprintf(date, "Naziv dana u nedelji %s", infoBar.date);
	    sprintf(audio, "Audio PID %hu", infoBar.audioPID);
	    sprintf(video, "Video PID %hu", infoBar.videoPID);
	    if (infoBar.teletextExist)
        {
            sprintf(telxt, "Teletekst postoji");    
        }
        else
        {
            sprintf(telxt, "Teletekst ne postoji");    
        }
        
        // Prepare text font, color and size. Then create font and draw it.
	    fontDesc.flags = DFDESC_HEIGHT;
	    fontDesc.height = 40;
	    DFBCHECK(dfbInterface->CreateFont(dfbInterface, 
	        "/home/galois/fonts/DejaVuSans.ttf", &fontDesc, &fontInterface));
	    DFBCHECK(primary->SetFont(primary, fontInterface));    
	
	    // Draw a rectangle representing info bar.    
        DFBCHECK(primary->SetColor(primary, INFO_BAR_RED, 
            INFO_BAR_GREEN, INFO_BAR_BLUE, 0xff));
        DFBCHECK(primary->FillRectangle(primary, screenWidth/6, 4*screenHeight/5,
            4*screenWidth/6, screenHeight/6));

        // Write program number, date and teletext to info bar.
        DFBCHECK(primary->SetColor(primary, TEXT_RED, TEXT_GREEN, TEXT_BLUE, 0xff));
        DFBCHECK(primary->DrawString(primary, prog, -1, screenWidth/5, 
	        17*screenHeight/20, DSTF_LEFT));
	    DFBCHECK(primary->DrawString(primary, audio, -1, screenWidth/5, 
	        18*screenHeight/20, DSTF_LEFT));
	    DFBCHECK(primary->DrawString(primary, video, -1, screenWidth/5, 
	        19*screenHeight/20, DSTF_LEFT));
	    DFBCHECK(primary->DrawString(primary, date, -1, 4*screenWidth/9, 
	        19*screenHeight/20, DSTF_LEFT));  
	    DFBCHECK(primary->DrawString(primary, telxt, -1, 4*screenWidth/9, 
	    	17*screenHeight/20, DSTF_LEFT));    
    }
    
    // Switch buffers.
	DFBCHECK(primary->Flip(primary, NULL, 0));
}
开发者ID:ALojdl,项目名称:Zapper,代码行数:83,代码来源:graphics.c

示例8: main


//.........这里部分代码省略.........
            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
        {
            initialVideoMode = getBestVideoMode(640, 480, 16);
            if (initialVideoMode == -1)
            {
                printf("Error: initial video mode 640x480x16 is not available!\n");
                exit(-1);
            }
        }

        dsc.flags = DSDESC_CAPS;
        dsc.caps = DSCAPS_PRIMARY;
        DFBCHECK(dfb->CreateSurface(dfb, &dsc, &surface));
        DFBCHECK(surface->Clear(surface, 0, 0, 0, 0));
        DFBCHECK(surface->GetSize(surface, &screen_width, &screen_height));
        DFBCHECK(dfb->GetInputDevice(dfb, DIDID_KEYBOARD, &dfbKeyboard));
        DFBCHECK(dfbKeyboard->CreateEventBuffer(dfbKeyboard, &dfbEventBuffer));
        DFBCHECK(dfb->GetInputDevice(dfb, DIDID_MOUSE, &dfbMouse));
        DFBCHECK(dfbMouse->AttachEventBuffer(dfbMouse, dfbEventBuffer));


        if (useFixedVideoMode)
        {
            printf("Information: setting video mode to %ux%ux%u\n", fixedVideoMode.width,
                   fixedVideoMode.height, fixedVideoMode.bpp);
            DFBCHECK(dfb->SetVideoMode(dfb, fixedVideoMode.width,
                                       fixedVideoMode.height, fixedVideoMode.bpp));
        } else
        {
            printf("Information: starting with default video mode %ux%ux%u\n",
                   videoModes[initialVideoMode].width, videoModes[initialVideoMode].height,
                   videoModes[initialVideoMode].bpp);
            DFBCHECK(dfb->SetVideoMode(dfb, videoModes[initialVideoMode].width,
                                            videoModes[initialVideoMode].height,
                                            videoModes[initialVideoMode].bpp));
        }

        // register our framebuffer
        frameBuffer = new VBoxDirectFB(dfb, surface);
        display->SetFramebuffer(0, frameBuffer);

        /**
         * Start the VM execution thread
         */
        console->PowerUp(NULL);

        console->GetKeyboard(getter_AddRefs(keyboard));
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:67,代码来源:VBoxFB.cpp

示例9: 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 );
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:DirectFB,代码行数:101,代码来源:dfbtest_prealloc.c

示例10: 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.
//.........这里部分代码省略.........
开发者ID:canalplus,项目名称:r7oss,代码行数:101,代码来源:unit_test_rle.c

示例11: 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;
}
开发者ID:Distrotech,项目名称:DirectFB,代码行数:101,代码来源:dfbtest_sync.c

示例12: 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;

}
开发者ID:iuridiniz,项目名称:eitv-lots,代码行数:70,代码来源:main.c

示例13: get_display_layer_surface

int get_display_layer_surface() {
    int i;
    IDirectFB *dfb = NULL;
    IDirectFBSurface *surface = NULL;
    DFBSurfaceCapabilities  caps;
    IDirectFBDisplayLayer   *layer   = NULL;
    int width, height;
  	DFBSurfacePixelFormat p_format;

    DFBCHECK(DirectFBInit(NULL, NULL));

    DFBCHECK(DirectFBCreate(&dfb));
    push_release(dfb, dfb->Release);

    DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer));
    push_release(layer, layer->Release);

    DFBCHECK(layer->SetCooperativeLevel(layer, DLSCL_EXCLUSIVE));
    DFBCHECK(layer->GetSurface(layer, &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;


}
开发者ID:iuridiniz,项目名称:eitv-lots,代码行数:72,代码来源:main.c

示例14: max

DFBResult
GetConfigAttribs::eglGetConfigAttribs( EGL::Display        &display,
                                       EGLNativePixmapType  native,
                                       EGLint              *attribs,
                                       EGLint               max )
{
     D_DEBUG_AT( DFBEGL_GetConfigAttribs, "%s( display %p, native %p, attribs %p, max %d )\n", __FUNCTION__, &display, native, attribs, max );

     if (!attribs)
          return DFB_INVARG;

     DFB_EGL_ATTRIB_LIST_DEBUG_AT( DFBEGL_GetConfigAttribs, attribs );

     IDirectFBSurface *surface = (IDirectFBSurface *) native;

     for (EGLint *v=attribs; *v != EGL_NONE; v+=2) {
          if (max > 0 && v-attribs >= max) {
               D_DEBUG_AT( DFBEGL_GetConfigAttribs, "  -> max (%d) reached (%ld)\n", max, v-attribs );
               break;
          }

          EGLint                attribute = v[0];
          EGLint                value     = v[1];
          DFBSurfacePixelFormat format;
          DFBDimension          size;

          D_DEBUG_AT( DFBEGL_GetConfigAttribs, "  -> [%ld] 0x%04x '%s'  <- %d (0x%08x)\n", v-attribs, attribute, **EGLInt(attribute), value, value );

          switch (attribute) {
          case EGL_BUFFER_SIZE:
               surface->GetPixelFormat( surface, &format );
               value = DFB_COLOR_BITS_PER_PIXEL( format );
               break;

          case EGL_ALPHA_SIZE:
               surface->GetPixelFormat( surface, &format );
               value = DFB_ALPHA_BITS_PER_PIXEL( format );
               break;

          case EGL_BLUE_SIZE:
          case EGL_GREEN_SIZE:
          case EGL_RED_SIZE:
               surface->GetPixelFormat( surface, &format );
               value = DFB_COLOR_BITS_PER_PIXEL( format ) / 3;//FIXME
               break;

          //case EGL_DEPTH_SIZE:
          //case EGL_STENCIL_SIZE:
          //case EGL_RENDERABLE_TYPE:

          case EGL_SURFACE_TYPE:
               value = EGL_WINDOW_BIT;  // FIXME
               break;

          case EGL_WIDTH:     // keep? not a config attribute actually
               surface->GetSize( surface, &size.w, &size.h );
               value = size.w;
               break;

          case EGL_HEIGHT:    // keep? not a config attribute actually
               surface->GetSize( surface, &size.w, &size.h );
               value = size.h;
               break;

          default:
               D_DEBUG_AT( DFBEGL_GetConfigAttribs, "  -> UNRECOGNIZED!!!\n" );
               continue;
          }

          D_DEBUG_AT( DFBEGL_GetConfigAttribs, "            => %d (0x%08x)\n", value, value );

          v[1] = value;
     }

     D_DEBUG_AT( DFBEGL_GetConfigAttribs, " --> DONE -------------\n" );

     DFB_EGL_ATTRIB_LIST_DEBUG_AT( DFBEGL_GetConfigAttribs, attribs );

     return DFB_OK;
}
开发者ID:kaostao,项目名称:directfb,代码行数:80,代码来源:DIRECTFB_GetConfigAttribs.cpp

示例15: if

int
main( int argc, char *argv[] )
{
     DFBResult              ret;
     int                    i;
     int                    x, y;
     int                    dx, dy;
     int                    sw3, sh3;
     int                    opacity       = 255;
     int                    opacity_delta = -1;
     IDirectFB             *dfb;
     IDirectFBDisplayLayer *layer;
     IDirectFBSurface      *surface;
     DFBDisplayLayerConfig  config;
     DFBDimension           size;
     DFBInputEvent          evt;

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Layer: DirectFBInit() failed!\n" );
          return ret;
     }


     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Layer: DirectFBCreate() failed!\n" );
          return ret;
     }

     dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );

     /* Create an input buffer for key events */
     dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS,
                                  DFB_TRUE, &keybuffer);

     layer->SetCooperativeLevel( layer, DFSCL_EXCLUSIVE );

     layer->GetConfiguration( layer, &config );


     config.options    = DLOP_OPACITY | DLOP_SRC_COLORKEY;
     config.buffermode = DLBM_FRONTONLY;

     layer->SetConfiguration( layer, &config );
     layer->SetSrcColorKey( layer, 0x00, 0xff, 0x00 );



     ret = layer->GetSurface( layer, &surface );
     if (ret) {
          D_DERROR( ret, "DFBTest/Layer: GetSurface() failed!\n" );
          dfb->Release( dfb );
          return ret;
     }

     surface->GetSize( surface, &size.w, &size.h );

     sw3 = ((size.w / 3) + 1) & ~1;
     sh3 = ((size.h / 3) + 1) & ~1;


     surface->Clear( surface, 0, 0, 0, 0xff );

     for (i=0; i<10; i++) {
          surface->SetColor( surface, 0xff - i*16, 0xff - i*16, 0xff - i*16, 0xff );
          surface->DrawRectangle( surface, i, i, size.w - i*2, size.h - i*2 );
     }

     surface->FillRectangle( surface, 10, size.h/2, size.w - 20, 1 );
     surface->FillRectangle( surface, size.w/2, 10, 1, size.h - 20 );

     surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff );
     surface->FillRectangle( surface, size.w/3, size.h/3, size.w/3, size.h/3 );

     surface->SetColor( surface, 0x00, 0xff, 0x00, 0xff );
     surface->FillRectangle( surface, size.w/3 + size.w/9, size.h/3 + size.h/9, size.w/9, size.h/9 );

     surface->Flip( surface, NULL, DSFLIP_NONE );

#ifdef BUILD_AUTOMATION
     sleep( 2 );
#else
     sleep( 12 );
#endif
     layer->SetSourceRectangle( layer, 0, 0, size.w - sw3, size.h - sh3 );

     layer->SetScreenPosition( layer, 100, 100 );
     layer->SetScreenRectangle( layer, 100, 100, size.w - sw3, size.h - sh3 );

     sleep( 2 );
#ifdef BUILD_AUTOMATION
     sleep( 20 );
     quit = 1;
#endif

     for (x=0, y=0, dx=1, dy=1; !quit ; x+=dx, y+=dy) {
          layer->SetOpacity( layer, opacity );
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:DirectFB,代码行数:101,代码来源:dfbtest_layer.c


注:本文中的IDirectFBSurface::GetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。