예제 #1
0
static DFBResult
Test_HideWindow( IDirectFBDisplayLayer *layer, void *arg )
{
    IDirectFBWindow *window;

    D_ASSERT( m_toplevel_id != 0 );

    /*
     * Get the top level window
     */
    _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );

    /*
     * Hide it
     */
    SHOW_TEST( "SetOpacity( 0 )..." );

    _T( window->SetOpacity( window, 0 ) );

    SHOW_RESULT( "...SetOpacity( 0 ) done." );

    /*
     * Show it again
     */
    SHOW_TEST( "SetOpacity( 0xff )..." );

    _T( window->SetOpacity( window, 0xff ) );

    SHOW_RESULT( "...SetOpacity( 0xff ) done." );

    window->Release( window );

    return DFB_OK;
}
예제 #2
0
/* DFB API */
IDirectFBWindow* dfb_create_window (IDirectFB *dfb, int x, int y, int width, int height, gboolean isAlpha)
{
	DFBResult err;
	DFBWindowDescription dsc;
	IDirectFBWindow *window = NULL;
	IDirectFBDisplayLayer *layer = NULL;
	
	DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer));
	layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
	
	dsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT;
	dsc.posx = x;
	dsc.posy = y;
	dsc.width = width;
	dsc.height = height;
	if(isAlpha) {
		dsc.flags |= DWDESC_CAPS;
		dsc.caps   = DWCAPS_ALPHACHANNEL;
	}
	err = layer->CreateWindow (layer, &dsc, &window);
	if (err!=DR_OK) {
		ZError(DBG_INIT, "Failed  to dfb_create_window.");
		return NULL;
	}
	/* Set ZKPlayer to Bottom but upper ZImagePlayer */
	DFBCHECK(window->LowerToBottom(window));
	DFBCHECK(window->SetOpacity(window, 0x0));
	return window;
}
static struct graphics_device *
directfb_init_device (void)
{
  struct graphics_device *gd;
  DFBDeviceData          *data;
  IDirectFBWindow        *window;
  DFBWindowDescription    desc;

  desc.flags  = (DFBWindowDescriptionFlags)(DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY);
  desc.width  = directfb_driver.x;
  desc.height = directfb_driver.y;
  desc.posx   = 0;
  desc.posy   = 0;

  retry:
  if (layer->CreateWindow (layer, &desc, &window) != DFB_OK) {
    if (out_of_memory(MF_GPI, NULL, 0))
      goto retry;
    return NULL;
  }

  gd = mem_alloc (sizeof (struct graphics_device));

  gd->size.x1 = 0;
  gd->size.y1 = 0;
  window->GetSize (window, &gd->size.x2, &gd->size.y2);

  gd->clip = gd->size;

  data = mem_alloc (sizeof (DFBDeviceData));

  data->window       = window;
  data->flip_pending = 0;

  if (arrow)
    window->SetCursorShape (window, arrow, arrow_hot_x, arrow_hot_y);

  window->GetSurface (window, &data->surface);
  window->GetID (window, &data->id);

  gd->driver_data = data;
  gd->user_data   = NULL;

  directfb_add_to_table (gd);

  window->AttachEventBuffer (window, events);

  window->SetOpacity (window, FOCUSED_OPACITY);

  return gd;
}
예제 #4
0
static DFBResult
Test_CreateSubWindow( IDirectFBDisplayLayer *layer, void *arg )
{
    IDirectFBWindow      *window;
    DFBWindowID           window_id;
    DFBDimension          size = { m_desc_sub.width, m_desc_sub.height };

    D_ASSERT( m_toplevel_id != 0 );

    /* Write window ID of top level into description */
    m_desc_sub.toplevel_id = m_toplevel_id;

    /*
     * Create a new sub window with 75% width/height and positioned at 20,20 within top level window
     */
    SHOW_TEST( "CreateWindow( %d,%d - %dx%d %s + toplevel ID %u, options 0x%08x )...",
               m_desc_sub.posx, m_desc_sub.posy, m_desc_sub.width, m_desc_sub.height,
               dfb_pixelformat_name( m_desc_sub.pixelformat ), m_desc_sub.toplevel_id, m_desc_top.options );

    _T( layer->CreateWindow( layer, &m_desc_sub, &window ) );

    if (m_subcolor.valid) {
        DFBColor c = m_subcolor.color;

        SHOW_INFO( "  - SetColor( 0x%02x, 0x%02x, 0x%02x, 0x%02x )...", c.r, c.g, c.b, c.a );

        _T( window->SetColor( window, c.r, c.g, c.b, c.a ) );
    }

    /*
     * Query its surface and clear it with light gray (if not input or color only)
     */
    if (!(m_desc_sub.caps & (DWCAPS_INPUTONLY | DWCAPS_COLOR) )) {
        IDirectFBSurface     *surface;

        SHOW_INFO( "  - GetSurface()..." );

        _T( window->GetSurface( window, &surface ) );

        SHOW_INFO( "  - Clear( 0xC0, 0xC0, 0xC0, 0xFF )..." );

        _T( surface->Clear( surface, 0xC0, 0xC0, 0xC0, 0xFF ) );

        _T( surface->DrawRectangle( surface, 0, 0, size.w, size.h ) );

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

        surface->Release( surface );
    }

    /*
     * Show the window
     */
    SHOW_INFO( "  - SetOpacity( 255 )..." );

    _T( window->SetOpacity( window, 0xff ) );

    /*
     * Query and print ID of new window
     */
    SHOW_INFO( "  - GetID()..." );

    _T( window->GetID( window, &window_id ) );

    /*
     * Set association of new window
     */
    if (m_desc_sub.parent_id) {
        SHOW_INFO( "  - SetAssociation( %u )...", m_desc_sub.parent_id );

        _T( window->SetAssociation( window, m_desc_sub.parent_id ) );
    }

    /*
     * Set top level window ID (user hasn't specified one)
     */
    m_subwindow_id = window_id;
    m_subwindow    = window;

    SHOW_RESULT( "...CreateWindow( %d,%d - %dx%d %s + toplevel ID %u ) done. => Sub Window ID %u",
                 m_desc_sub.posx, m_desc_sub.posy, m_desc_sub.width, m_desc_sub.height,
                 dfb_pixelformat_name( m_desc_sub.pixelformat ), m_desc_sub.toplevel_id, window_id );

    return DFB_OK;
}
예제 #5
0
int
main( int argc, char *argv[] )
{
     DFBResult ret;
     int       i;
     int       quit = 0;
     const int num = 2;
     Context   contexts[num];

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

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

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

     /* create the default font */
     DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font ));

     for (i=0; i<num; i++) {
          IDirectFBWindow      *window;
          IDirectFBSurface     *surface;
          IDirectFBGL          *gl;
          DFBWindowDescription  desc;

          desc.flags  = DWDESC_POSX | DWDESC_POSY |
                        DWDESC_WIDTH | DWDESC_HEIGHT;
          desc.posx   = (i%3) * 200 + 10;
          desc.posy   = (i/3) * 200 + 10;
          desc.width  = 180;
          desc.height = 180;

          DFBCHECK(layer->CreateWindow( layer, &desc, &window ));
          DFBCHECK(window->GetSurface( window, &surface ));
          DFBCHECK(surface->GetGL( surface, &gl ));

          contexts[i].window    = window;
          contexts[i].surface   = surface;
          contexts[i].gl        = gl;

          contexts[i].last_time = get_millis();
          contexts[i].frames    = 0;
          contexts[i].fps       = 0;

          setup( &contexts[i] );

          if (events)
               DFBCHECK(window->AttachEventBuffer( window, events ));
          else
               DFBCHECK(window->CreateEventBuffer( window, &events ));
          
          DFBCHECK(surface->SetFont( surface, font ));

          window->SetOpacity( window, 0xff );
     }
     
     while (!quit) {
          DFBWindowEvent evt;

          for (i=0; i<num; i++)
               update( &contexts[i] );
          
          while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) {
               switch (evt.type) {
                    case DWET_KEYDOWN:
                         switch (evt.key_symbol) {
                              case DIKS_ESCAPE:
                                   quit = 1;
                                   break;

                              default:
                                   break;
                         }
                         break;

                    default:
                         break;
               }
          }
     }

     events->Release( events );

     for (i=0; i<num; i++) {
          contexts[i].gl->Release( contexts[i].gl );
          contexts[i].surface->Release( contexts[i].surface );
          contexts[i].window->Release( contexts[i].window );
     }

     font->Release( font );
     layer->Release( layer );
     dfb->Release( dfb );

     return 0;
}
예제 #6
0
static DFBResult
app_init( App                   *app,
          IDirectFBDisplayLayer *layer,
          int                    x,
          int                    y,
          int                    width,
          int                    height,
          int                    index )
{
     DFBResult             ret;
     DFBWindowDescription  desc;
     IDirectFBWindow      *window;
     IDirectFBSurface     *surface;

     desc.flags  = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_CAPS;
     desc.width  = width;
     desc.height = height;
     desc.posx   = x;
     desc.posy   = y;
     desc.caps   = DWCAPS_NONE; //| DWCAPS_ALPHACHANNEL | DWCAPS_DOUBLEBUFFER;

     /* Create a surface for the image. */
     ret = layer->CreateWindow( layer, &desc, &window );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFBDisplayLayer::CreateWindow() failed!\n" );
          return ret;
     }

     /* Get the surface. */
     ret = window->GetSurface( window, &surface );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFBWindow::GetSurface() failed!\n" );
          return ret;
     }

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

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


     direct_thread_sleep( 2000000 );
     D_INFO( "Showing window...\n" );
     direct_thread_sleep( 500000 );

     window->SetOpacity( window, 0xff );

     direct_thread_sleep( 500000 );
     D_INFO( "Done.\n" );
     direct_thread_sleep( 1000000 );

     app->window       = window;
     app->surface      = surface;
     app->index        = index;
     app->resolution.w = width;
     app->resolution.h = height;

     app->anim_dirx    = 5;
     app->anim_diry    = 5;
     app->anim_x       = 0;
     app->anim_y       = 0;

     return DFB_OK;
}