コード例 #1
0
void QDirectFbWindow::createDirectFBWindow()
{
    Q_ASSERT(!m_dfbWindow.data());

    DFBDisplayLayerConfig layerConfig;
    IDirectFBDisplayLayer *layer;

    layer = toDfbScreen(window())->dfbLayer();
    layer->GetConfiguration(layer, &layerConfig);

    DFBWindowDescription description;
    memset(&description,0,sizeof(DFBWindowDescription));
    description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS
                                                  |DWDESC_OPTIONS
                                                  |DWDESC_CAPS);
    description.width = qMax(1, window()->width());
    description.height = qMax(1, window()->height());
    description.posx = window()->x();
    description.posy = window()->y();

    if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED)
        description.surface_caps = DSCAPS_PREMULTIPLIED;
    description.pixelformat = layerConfig.pixelformat;

    description.options = DFBWindowOptions(DWOP_ALPHACHANNEL);
    description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL);

    DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
    if (result != DFB_OK)
        DirectFBError("QDirectFbWindow: failed to create window", result);

    m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
    m_inputHandler->addWindow(m_dfbWindow.data(), window());
}
コード例 #2
0
ファイル: zkplayerutil.c プロジェクト: jamesyan84/zbase
/* 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;
}
コード例 #3
0
ファイル: qdirectfb_egl.cpp プロジェクト: ghjinlei/qt5
void QDirectFbWindowEGL::createDirectFBWindow()
{
    // Use the default for the raster surface.
    if (window()->surfaceType() == QSurface::RasterSurface)
        return QDirectFbWindow::createDirectFBWindow();

    Q_ASSERT(!m_dfbWindow.data());

    DFBWindowDescription description;
    memset(&description, 0, sizeof(DFBWindowDescription));
    description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH | DWDESC_HEIGHT|
                                                  DWDESC_POSX | DWDESC_POSY|
                                                  DWDESC_PIXELFORMAT | DWDESC_SURFACE_CAPS);
    description.width = qMax(1, window()->width());
    description.height = qMax(1, window()->height());
    description.posx = window()->x();
    description.posy = window()->y();

    description.surface_caps = DSCAPS_GL;
    description.pixelformat = DSPF_RGB16;

    IDirectFBDisplayLayer *layer;
    layer = toDfbScreen(window())->dfbLayer();
    DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
    if (result != DFB_OK)
        DirectFBError("QDirectFbWindow: failed to create window", result);

    m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
    m_inputHandler->addWindow(m_dfbWindow.data(), window());
}
コード例 #4
0
ファイル: main.c プロジェクト: iuridiniz/eitv-lots
int get_display_layer_window() {
    IDirectFB *dfb = NULL;
    IDirectFBDisplayLayer   *layer   = NULL;
    IDirectFBWindow         *window  = NULL;

    DFBWindowDescription desc;


    DFBCHECK(DirectFBInit(NULL, NULL));

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

    desc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY;

    desc.posx = desc.posy = desc.width = desc.height = 20;
    
    DFBCHECK(layer->CreateWindow(layer, &desc, &window));
    push_release(window, window->Release);

    /* check window */

    release_all();
    return 0;

}
コード例 #5
0
void QDirectFBCursor::changeCursor(QCursor *cursor, QWindow *)
{
    int xSpot;
    int ySpot;
    QPixmap map;

    if (cursor->shape() != Qt::BitmapCursor) {
        m_image->set(cursor->shape());
        xSpot = m_image->hotspot().x();
        ySpot = m_image->hotspot().y();
        QImage *i = m_image->image();
        map = QPixmap::fromImage(*i);
    } else {
        QPoint point = cursor->hotSpot();
        xSpot = point.x();
        ySpot = point.y();
        map = cursor->pixmap();
    }

    DFBResult res;
    IDirectFBDisplayLayer *layer = toDfbLayer(m_screen);
    IDirectFBSurface* surface(QDirectFbConvenience::dfbSurfaceForPlatformPixmap(map.handle()));

    res = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
    if (res != DFB_OK) {
        DirectFBError("Failed to set DLSCL_ADMINISTRATIVE", res);
        return;
    }

    layer->SetCursorShape(layer, surface, xSpot, ySpot);
    layer->SetCooperativeLevel(layer, DLSCL_SHARED);
}
コード例 #6
0
jlong Java_vdr_mhp_awt_DFBWindowPeer_createDFBWindow(JNIEnv* env, jobject obj, jlong nativeLayer, jint x, jint y, jint width, jint height) {
     IDirectFBDisplayLayer *layer = (IDirectFBDisplayLayer *)nativeLayer;
     IDirectFBWindow       *window;
     DFBWindowDescription  desc;

     if (!layer)
        layer=MhpOutput::System::self()->GetMainLayer();

     //printf("createDFBWindow %d, %d - %dx%d on layer %p ID %d\n", x, y, width, height, layer, layer->GetID());

     /*if (getenv( "MHP_NO_ALPHA" ))
          bgAlpha = 255;

     if (bgAlpha < 255) {
          desc.flags = DWDESC_CAPS;
          desc.caps  = DWCAPS_ALPHACHANNEL;
     }
     else
          desc.flags = 0;*/
          
     desc.flags=(DFBWindowDescriptionFlags)0;
     
     if (!getenv( "MHP_NO_ALPHA" )) {
          DFB_ADD_WINDOW_DESC(desc.flags, DWDESC_CAPS);
          desc.caps=DWCAPS_NONE;
          DFB_ADD_WINDOW_CAPS(desc.caps, DWCAPS_ALPHACHANNEL);
          DFB_ADD_WINDOW_CAPS(desc.caps, DWCAPS_DOUBLEBUFFER);
     }


     if (x >= 0) {
          DFB_ADD_WINDOW_DESC(desc.flags, DWDESC_POSX);
          desc.posx = x;
     }
     if (y >= 0) {
          DFB_ADD_WINDOW_DESC(desc.flags, DWDESC_POSY);
          desc.posy = y;
     }
     if (width > 0) {
          DFB_ADD_WINDOW_DESC(desc.flags, DWDESC_WIDTH);
          desc.width = width;
     }
     if (height > 0) {
          DFB_ADD_WINDOW_DESC(desc.flags, DWDESC_HEIGHT);
          desc.height = height;
     }
     

     try {
          window=layer->CreateWindow(desc);
     } catch (DFBException *e) {
         printf("DirectFB: Error %s, %s\n", e->GetAction(), e->GetResult());
         delete e;
         return 0;
     }
      int ww,hh;window->GetSize(&ww, &hh);
     //printf("Created window %p, size %dx%d\n", window, ww, hh);
     
     return (jlong )window;
}
コード例 #7
0
ファイル: directfbapp_export.c プロジェクト: jiangxilong/yari
/** Opens application window and return pointer to offscreen buffer for  */
char *directfbapp_open_window() {

    DFBWindowDescription wdesc;
    DFBDisplayLayerConfig lconfig;
    static char *argv_array[] = {
        "CVM",
        "--dfb:system=FBDev"
            ",force-windowed"   /* use windows instead of surfaces */
            ",no-vt-switch"     /* do not switch between Linux' VT */
            ",no-cursor"        /* do not use pointer */
            // ",no-deinit-check" /* do not check for deinit */
        ,NULL
    };
    int argc = sizeof argv_array / sizeof argv_array[0] - 1;
    char **argv = argv_array;
    IDirectFBDisplayLayer *dlayer;
    char *dst;
    int pitch;
    unsigned int win_id;
    int win_x, win_y;

    DFBCHECK(DirectFBInit(&argc, &argv));
    DFBCHECK(DirectFBCreate(&dfb));
    DFBCHECK(dfb->SetCooperativeLevel(dfb, DFSCL_NORMAL));

    DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &dlayer));
    DFBCHECK(dlayer->GetConfiguration(dlayer, &lconfig));
    wdesc.caps = DWCAPS_DOUBLEBUFFER;
    wdesc.surface_caps = DSCAPS_DOUBLE;
    wdesc.pixelformat = DSPF_RGB16;
    wdesc.width = CHAM_WIDTH;
    wdesc.height = CHAM_HEIGHT;
    wdesc.flags = DWDESC_CAPS | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT |
        DWDESC_SURFACE_CAPS;
    DFBCHECK(dlayer->CreateWindow(dlayer, &wdesc, &window));
    releaseInterface(dlayer);
    if ((lconfig.flags & (DLCONF_WIDTH | DLCONF_HEIGHT)) == (DLCONF_WIDTH | DLCONF_HEIGHT)) {
        DFBCHECK(window->GetID(window, &win_id));
        set_win_position(win_id, lconfig.width, lconfig.height, win_x, win_y);
        DFBCHECK(window->MoveTo(window, win_x, win_y));
    }
    DFBCHECK(window->RaiseToTop(window));
    DFBCHECK(window->SetOpacity(window, 0xff));
    DFBCHECK(window->RequestFocus(window));
    DFBCHECK(window->GetSurface(window, &screen));
    DFBCHECK(screen->GetSize(screen, &screen_width, &screen_height));
    DFBCHECK(screen->Lock(screen, DSLF_WRITE, (void**)(void*)&dst, &pitch));
    if (pitch != (int)sizeof(gxj_pixel_type) * screen_width) {
        REPORT_ERROR(LC_LOWUI,
            "Invalid pixel format: Supports only 16-bit, 5:6:5 display");
        goto dfb_err;
    }
    return dst;

dfb_err:;
    directfbapp_finalize();
    exit(1); /* TODO: exit from Java */
    /* return NULL; */
}
コード例 #8
0
void QDirectFBWindowSurface::createWindow(const QRect &rect)
{
    IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
    if (!layer)
        qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");

    updateIsOpaque();

    DFBWindowDescription description;
    memset(&description, 0, sizeof(DFBWindowDescription));

    description.flags = DWDESC_CAPS|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT;
    description.caps = DWCAPS_NODECORATION;
    description.surface_caps = DSCAPS_NONE;
    imageFormat = screen->pixelFormat();

    if (!(surfaceFlags() & Opaque)) {
        imageFormat = screen->alphaPixmapFormat();
        description.caps |= DWCAPS_ALPHACHANNEL;
#if (Q_DIRECTFB_VERSION >= 0x010200)
        description.flags |= DWDESC_OPTIONS;
        description.options |= DWOP_ALPHACHANNEL;
#endif
    }
    description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(imageFormat);
    description.posx = rect.x();
    description.posy = rect.y();
    description.width = rect.width();
    description.height = rect.height();

    if (QDirectFBScreen::isPremultiplied(imageFormat))
        description.surface_caps = DSCAPS_PREMULTIPLIED;

    if (screen->directFBFlags() & QDirectFBScreen::VideoOnly)
        description.surface_caps |= DSCAPS_VIDEOONLY;

    DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow);

    if (result != DFB_OK)
        DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result);

    if (window()) {
        if (window()->windowFlags() & Qt::WindowStaysOnTopHint) {
            dfbWindow->SetStackingClass(dfbWindow, DWSC_UPPER);
        }
        DFBWindowID winid;
        result = dfbWindow->GetID(dfbWindow, &winid);
        if (result != DFB_OK) {
            DirectFBError("QDirectFBWindowSurface::createWindow. Can't get ID", result);
        } else {
            window()->setProperty("_q_DirectFBWindowID", winid);
        }
    }

    Q_ASSERT(!dfbSurface);
    dfbWindow->GetSurface(dfbWindow, &dfbSurface);
}
コード例 #9
0
int
main( int argc, char *argv[] )
{
     int                    i;
     DFBResult              ret;
     IDirectFB             *dfb;
     IDirectFBDisplayLayer *layer  = NULL;
     App                    apps[1];
     DFBDisplayLayerConfig  config;

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          if (!strcmp( argv[i], "-h" ))
               return show_usage( argv[0] );
     }

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

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

     /* Get primary layer. */
     ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFB::GetDisplayLayer( PRIMARY ) failed!\n" );
          goto out;
     }

     
     layer->GetConfiguration( layer, &config );

     app_init( &apps[0], layer, 100, 50, config.width-300, config.height-150, 0 );

     while (true) {
          direct_thread_sleep( 1000000 );

          app_update( &apps[0] );
     }


out:
     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
コード例 #10
0
ファイル: qdirectfbwindow.cpp プロジェクト: BGmot/Qt
void QDirectFbWindow::setVisible(bool visible)
{
    if (visible) {
        int x = geometry().x();
        int y = geometry().y();
        m_dfbWindow->MoveTo(m_dfbWindow,x,y);
    } else {
        IDirectFBDisplayLayer *displayLayer;
        QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer);

        DFBDisplayLayerConfig config;
        displayLayer->GetConfiguration(displayLayer,&config);
        m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1);
    }
}
コード例 #11
0
ファイル: qdirectfbwindow.cpp プロジェクト: Suneal/qt
QT_BEGIN_NAMESPACE

QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler)
    : QPlatformWindow(tlw), m_inputHandler(inputhandler)
{
    DFBDisplayLayerConfig layerConfig;
    IDirectFBDisplayLayer *layer;

    layer = toDfbScreen(tlw)->dfbLayer();
    toDfbScreen(tlw)->dfbLayer()->GetConfiguration(layer, &layerConfig);

    DFBWindowDescription description;
    memset(&description,0,sizeof(DFBWindowDescription));
    description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS
#if DIRECTFB_MINOR_VERSION >= 1
                                                  |DWDESC_OPTIONS
#endif
                                                  |DWDESC_CAPS);
    description.width = tlw->width();
    description.height = tlw->height();
    description.posx = tlw->x();
    description.posy = tlw->y();

    if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED)
        description.surface_caps = DSCAPS_PREMULTIPLIED;
    description.pixelformat = layerConfig.pixelformat;

#if DIRECTFB_MINOR_VERSION >= 1
    description.options = DFBWindowOptions(DWOP_ALPHACHANNEL);
#endif
    description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL);
    description.surface_caps = DSCAPS_PREMULTIPLIED;

    DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
    if (result != DFB_OK) {
        DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result);
    }

    m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);

    setVisible(widget()->isVisible());

    m_inputHandler->addWindow(m_dfbWindow.data(), tlw);
}
コード例 #12
0
ファイル: SDL_DirectFB_yuv.c プロジェクト: 3bu1/crossbridge
int DirectFB_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst)
{
  DFBResult              ret;
  DFBDisplayLayerConfig  conf;
  IDirectFBDisplayLayer *primary = HIDDEN->layer;
  IDirectFBDisplayLayer *layer   = overlay->hwdata->layer;

  primary->GetConfiguration (primary, &conf);

  ret = layer->SetScreenLocation (layer,
                                  dst->x / (float) conf.width, dst->y / (float) conf.height,
                                  dst->w / (float) conf.width, dst->h / (float) conf.height );
  if (ret)
    {
      SetDirectFBerror("IDirectFBDisplayLayer::SetScreenLocation", ret);
      return -1;
    }

  return 0;
}
コード例 #13
0
ファイル: simples.c プロジェクト: iuridiniz/eitv-lots
int main(int argc, char** argv) {
        
    IDirectFB *dfb = NULL;
    IDirectFBDisplayLayer *layer =  NULL;
    IDirectFBSurface *surface = NULL;
    IDirectFBVideoProvider *vp = NULL;

    CHECK(DirectFBInit (&argc, &argv));
    if (argc != 2) {
        return 1;
    }

    CHECK(DirectFBCreate(&dfb));
    /* Signals */
    signal(SIGINT, signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGUSR1, signal_handler);
    signal(SIGUSR2, signal_handler);

    CHECK(dfb->GetDisplayLayer(dfb, 0, &layer));

    CHECK(dfb->CreateVideoProvider(dfb, argv[1], &vp));
   

    CHECK(layer->GetSurface(layer, &surface));
    CHECK(vp->PlayTo(vp, surface, NULL, flip, surface));
    while(to_exit == 0) {
        sleep(1);
    }

    CHECK(vp->Stop(vp));
    CHECK(vp->Release(vp));
    CHECK(surface->Release(surface));
    CHECK(layer->Release(layer));
    CHECK(dfb->Release(dfb));
    

    return 0;


}
コード例 #14
0
void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
{
    const char *ptr = state.constData();
    IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
    SurfaceFlags flags;
    memcpy(&flags, ptr, sizeof(SurfaceFlags));

    setSurfaceFlags(flags);
    ptr += sizeof(SurfaceFlags);
    DFBWindowID id;
    memcpy(&id, ptr, sizeof(DFBWindowID));
    if (dfbSurface)
        dfbSurface->Release(dfbSurface);
    if (id != (DFBWindowID)-1) {
        IDirectFBWindow *dw;
        layer->GetWindow(layer, id, &dw);
        if (dw->GetSurface(dw, &dfbSurface) != DFB_OK)
                dfbSurface = 0;
        dw->Release(dw);
    }
    else {
        dfbSurface = 0;
    }
}
コード例 #15
0
ファイル: main.c プロジェクト: iuridiniz/eitv-lots
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;


}
コード例 #16
0
ファイル: dfbtest_resize.c プロジェクト: Distrotech/DirectFB
static void
TestResize( IDirectFB *dfb )
{
     DFBResult              ret;
     DirectThread          *thread;
     DFBWindowDescription   desc;
     IDirectFBDisplayLayer *layer;
     IDirectFBWindow       *window;
     IDirectFBSurface      *surface;
     DFBInputEvent          evt;
     IDirectFBEventBuffer  *keybuffer;

     quit = 0;

     /* Create an input buffer for key events */
     ret = dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS,
                                        DFB_FALSE, &keybuffer);
     if (ret) {
          D_DERROR( ret, "DFBTest/Resize: CreateInputBuffer() failed!\n" );
          return;
     }

     ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
     if (ret) {
          D_DERROR( ret, "DFBTest/Resize: Failed to get display layer!\n" );
          keybuffer->Release( keybuffer );
          return;
     }

     desc.flags       = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT;
     desc.width       = 500;
     desc.height      = 500;
     desc.pixelformat = DSPF_ARGB;

     ret = layer->CreateWindow( layer, &desc, &window );
     if (ret) {
          D_DERROR( ret, "DFBTest/Resize: CreateWindow() failed!\n" );
          keybuffer->Release( keybuffer );
          layer->Release( layer );
          return;
     }

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

     thread = direct_thread_create( DTT_DEFAULT, TestThread, surface, "Test" );

     while (!quit) {

          ret = window->Resize( window, 500, 400 );
          if (ret)
               D_DERROR( ret, "DFBTest/Resize: Resize() failed!\n" );

          ret = window->Resize( window, 500, 500 );
          if (ret)
               D_DERROR( ret, "DFBTest/Resize: Resize() failed!\n" );

          /* Process keybuffer */
          while (keybuffer->GetEvent( keybuffer, DFB_EVENT(&evt)) == DFB_OK)
          {
              if (evt.type == DIET_KEYPRESS) {
                  switch (DFB_LOWER_CASE(evt.key_symbol)) {
                      case DIKS_ESCAPE:
                      case DIKS_SMALL_Q:
                      case DIKS_BACK:
                      case DIKS_STOP:
                      case DIKS_EXIT:
                          /* Quit main loop & test thread */
                          quit = 1;
                          direct_thread_join(thread);
                          break;
                      default:
                          break;
                  }
              }
          }
     }

     keybuffer->Release( keybuffer );
     surface->Release( surface );
     window->Release( window );
     layer->Release( layer );
}
コード例 #17
0
ファイル: gdkdisplay-directfb.c プロジェクト: Aridna/gtk2
/* Main entry point for gdk in 2.6 args are parsed
 */
GdkDisplay *
gdk_display_open (const gchar *display_name)
{
  IDirectFB             *directfb;
  IDirectFBDisplayLayer *layer;
  IDirectFBInputDevice  *keyboard;
  DFBResult              ret;

  if (_gdk_display)
    {
      return GDK_DISPLAY_OBJECT (_gdk_display); /* single display only */
    }

  ret = DirectFBInit (NULL, NULL);
  if (ret != DFB_OK)
    {
      DirectFBError ("gdk_display_open: DirectFBInit", ret);
      return NULL;
    }

  ret = DirectFBCreate (&directfb);
  if (ret != DFB_OK)
    {
      DirectFBError ("gdk_display_open: DirectFBCreate", ret);
      return NULL;
    }

  _gdk_display = g_object_new (GDK_TYPE_DISPLAY_DFB, NULL);
  _gdk_display->directfb = directfb;

  ret = directfb->GetDisplayLayer (directfb, DLID_PRIMARY, &layer);
  if (ret != DFB_OK)
    {
      DirectFBError ("gdk_display_open: GetDisplayLayer", ret);
      directfb->Release (directfb);
      _gdk_display->directfb = NULL;
      return NULL;
    }


  ret = directfb->GetInputDevice (directfb, DIDID_KEYBOARD, &keyboard);
  if (ret != DFB_OK)
    {
      DirectFBError ("gdk_display_open: GetInputDevice", ret);
      directfb->Release (directfb);
      _gdk_display->directfb = NULL;
      return NULL;
    }

  _gdk_display->layer    = layer;
  _gdk_display->keyboard = keyboard;

  _gdk_directfb_keyboard_init ();

  _gdk_screen = g_object_new (GDK_TYPE_SCREEN, NULL);

  _gdk_visual_init ();
  _gdk_windowing_window_init (_gdk_screen);

  gdk_screen_set_default_colormap (_gdk_screen,
                                   gdk_screen_get_system_colormap (_gdk_screen));
  _gdk_windowing_image_init ();

  _gdk_events_init ();
  _gdk_input_init ();
  _gdk_dnd_init ();

  layer->EnableCursor (layer, 1);

  g_signal_emit_by_name (gdk_display_manager_get (),
			 "display_opened", _gdk_display);

  return GDK_DISPLAY_OBJECT (_gdk_display);
}
コード例 #18
0
ファイル: evas_directfb_window.c プロジェクト: Limsik/e17
int main( int argc, char *argv[] )
{
     IDirectFB              *dfb;
     IDirectFBDisplayLayer  *layer;

     IDirectFBSurface       *bgsurface;
     IDirectFBImageProvider *provider;

     IDirectFBWindow        *window1;
     IDirectFBWindow        *window2;
     IDirectFBSurface       *window_surface1;
     IDirectFBSurface       *window_surface2;

     IDirectFBEventBuffer   *buffer;

     DFBDisplayLayerConfig  layer_config;

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     DFBCardCapabilities    caps;
#else
     DFBGraphicsDeviceDescription caps;
#endif
     IDirectFBWindow*       upper;
     DFBWindowID            id1;

     IDirectFBFont          *font;
     int fontheight;
     int err;
     int quit = 0;


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

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     dfb->GetCardCapabilities( dfb, &caps );
#else
     dfb->GetDeviceDescription( dfb, &caps );
#endif

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

     if (!((caps.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
           (caps.blitting_flags & DSBLIT_BLEND_COLORALPHA  )))
     {
          layer_config.flags = DLCONF_BUFFERMODE;
          layer_config.buffermode = DLBM_BACKSYSTEM;

          layer->SetConfiguration( layer, &layer_config );
     }

     layer->GetConfiguration( layer, &layer_config );
     layer->EnableCursor ( layer, 1 );

     {
          DFBFontDescription desc;

          desc.flags = DFDESC_HEIGHT;
          desc.height = layer_config.width/50;

          DFBCHECK(dfb->CreateFont( dfb, PACKAGE_DATA_DIR"/grunge.ttf", &desc, &font ));
          font->GetHeight( font, &fontheight );
     }

     {
          DFBSurfaceDescription desc;

          DFBCHECK(dfb->CreateImageProvider( dfb,
                                             PACKAGE_DATA_DIR"/bg.png",
                                             &provider ));

          desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
          desc.width = layer_config.width;
          desc.height = layer_config.height;

          DFBCHECK(dfb->CreateSurface( dfb, &desc, &bgsurface ) );


          provider->RenderTo( provider, bgsurface, NULL );
          provider->Release( provider );

	  DFBCHECK(bgsurface->SetFont( bgsurface, font ));

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                                 "Move the mouse over a window to activate it.",
                                 -1, 10, 0, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xFF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                    "You can drag them around, too, if you want.",
                                 -1, 10 , 40, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
	  bgsurface->DrawString( bgsurface,
                    "The one with funky stuff happening and things flying around is an evas.",
                                 -1, 10, 80, DSTF_LEFT | DSTF_TOP );




          layer->SetBackgroundImage( layer, bgsurface );
          layer->SetBackgroundMode( layer, DLBM_IMAGE );
     }
     {
	  DFBWindowDescription desc;
	  desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );

	  desc.posx = 20;
          desc.posy = 120;
          desc.width = 200;
          desc.height = 200;
	  desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK( layer->CreateWindow( layer, &desc, &window2 ) );
          window2->GetSurface( window2, &window_surface2 );

          window2->SetOpacity( window2, 0xFF );

          window2->CreateEventBuffer( window2, &buffer );

	  {
	     window_surface2->SetColor( window_surface2,
		   0x00, 0x30, 0x10, 0xc0 );
	     window_surface2->DrawRectangle( window_surface2, 0, 0,
		   desc.width, desc.height );
	     window_surface2->SetColor( window_surface2,
		   0x80, 0xa0, 0x00, 0x90 );
	     window_surface2->FillRectangle( window_surface2, 1, 1,
		   desc.width-2, desc.height-2 );


	     DFBCHECK(window_surface2->SetFont(window_surface2, font ));
	     window_surface2->SetColor( window_surface2, 0xCF, 0xFF, 0xCF, 0xFF );

	     window_surface2->DrawString( window_surface2,
		   "Pants!",
		   -1,10, fontheight + 5, DSTF_LEFT | DSTF_TOP );

	  }

          window_surface2->Flip( window_surface2, NULL, 0 );
     }

     {
          DFBWindowDescription desc;

          desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );
          desc.posx = 200;
          desc.posy = 200;
          desc.width = 240;
          desc.height = 320;
          desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK(layer->CreateWindow( layer, &desc, &window1 ) );
          window1->GetSurface( window1, &window_surface1 );

          window_surface1->SetColor( window_surface1, 0xFF, 0x20, 0x20, 0x90 );
          window_surface1->DrawRectangle( window_surface1, 0, 0,
                                          desc.width, desc.height );

          window_surface1->Flip( window_surface1, NULL, 0 );

          window1->SetOpacity( window1, 0xFF );

          window1->GetID( window1, &id1 );

          window1->AttachEventBuffer( window1, buffer );
     }

     window1->RequestFocus( window1 );
     window1->RaiseToTop( window1 );
     upper = window1;
     {
	evas_init();
	evas = evas_new();
	evas_output_method_set(evas, evas_render_method_lookup("directfb"));
	evas_output_size_set(evas, 240, 320);
	evas_output_viewport_set(evas, 0, 0, 240, 320);
	{
	   Evas_Engine_Info_DirectFB *einfo;

	   einfo = (Evas_Engine_Info_DirectFB *) evas_engine_info_get(evas);

	   einfo->info.dfb = dfb;
	   einfo->info.surface = window_surface1;
	   einfo->info.flags = DSDRAW_BLEND;
	   evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
	}
	setup();
	evas_render(evas);
	start_time = get_time();
     }

     while (!quit) {
          static IDirectFBWindow* active = NULL;
          static int grabbed = 0;
          static int startx = 0;
          static int starty = 0;
          static int endx = 0;
          static int endy = 0;
          DFBWindowEvent evt;

          buffer->WaitForEventWithTimeout( buffer, 0, 10 );

          while (buffer->GetEvent( buffer, DFB_EVENT(&evt) ) == DFB_OK) {
               IDirectFBWindow* window;

               if (evt.window_id == id1)
                    window = window1;
               else
                    window = window2;

               if (active) {
                    switch (evt.type) {

                    case DWET_BUTTONDOWN:
                         if (!grabbed && evt.button == DIBI_LEFT) {
                              grabbed = 1;
                              layer->GetCursorPosition( layer,
                                                        &startx, &starty );
                              window->GrabPointer( window );
                         }
                         break;

                    case DWET_BUTTONUP:
                         switch (evt.button) {
                              case DIBI_LEFT:
                                   if (grabbed) {
                                        window->UngrabPointer( window );
                                        grabbed = 0;
                                   }
                                   break;
                              case DIBI_MIDDLE:
                                   upper->LowerToBottom( upper );
                                   upper = (upper == window1) ? window2 : window1;
                                   break;
                              case DIBI_RIGHT:
                                   quit = DIKS_DOWN;
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_KEYDOWN:
                         if (grabbed)
                              break;
                         switch (evt.key_id) {
                              case DIKI_RIGHT:
                                   active->Move (active, 1, 0);
                                   break;
                              case DIKI_LEFT:
                                   active->Move (active, -1, 0);
                                   break;
                              case DIKI_UP:
                                   active->Move (active, 0, -1);
                                   break;
                              case DIKI_DOWN:
                                   active->Move (active, 0, 1);
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_LOSTFOCUS:
                         if (!grabbed)
                              active = NULL;
                         break;

                    default:
                         break;

                    }
               }
               else if (evt.type == DWET_GOTFOCUS)
                    active = window;

               switch (evt.type) {

               case DWET_MOTION:
                    endx = evt.cx;
                    endy = evt.cy;
                    break;

               case DWET_KEYDOWN:
                    switch (evt.key_symbol) {
                    case DIKS_ESCAPE:
                    case DIKS_SMALL_Q:
                    case DIKS_CAPITAL_Q:
                    case DIKS_BACK:
                    case DIKS_STOP:
                         quit = 1;
                         break;
                    default:
                         break;
                    }
                    break;

               default:
                    break;
               }
          }

          if (active) {
               if (grabbed) {
                    active->Move( active, endx - startx, endy - starty);
                    startx = endx;
                    starty = endy;
               }
               active->SetOpacity( active,
                                   (sin( myclock()/300.0 ) * 85) + 170 );
          }
	  loop();
	  {
	     Eina_List *updates;

	     updates = evas_render_updates(evas);
	     /* efficient update.. only flip the rectangle regions that changed! */
	     if (updates)
	       {
		  DFBRegion region;
		  Eina_List *l;

		  for (l = updates; l; l = l->next)
		    {
		       Evas_Rectangle *rect;

		       rect = l->data;
		       region.x1 = rect->x;
		       region.y1 = rect->y;
		       region.x2 = rect->x + rect->w - 1;
		       region.y2 = rect->y + rect->h - 1;
		       window_surface1->Flip(window_surface1, &region,
					     DSFLIP_BLIT);
		    }
		  evas_render_updates_free(updates);
	       }
	  }
     }

     buffer->Release( buffer );
     window_surface2->Release( window_surface2 );
     window_surface1->Release( window_surface1 );
     window2->Release( window2 );
     window1->Release( window1 );
     layer->Release( layer );
     bgsurface->Release( bgsurface );
     dfb->Release( dfb );

   evas_shutdown();
   return 0;
}
コード例 #19
0
ファイル: main.c プロジェクト: beto1014/eve-browser
void *BrowserMain(void * argument)
{
    printf("%s:%d\n", __func__, __LINE__);

    int argc = 0;
    char**argv = NULL;


    pthread_mutex_init (&mutex, NULL);
    
    g_type_init();
    g_thread_init(NULL);

    lite_open( &argc, &argv );

    WebKitDFB_Initialize( lite_get_dfb_interface() );

    IDirectFBDisplayLayer *layer;
    DFBDisplayLayerConfig  config;
    lite_get_layer_interface( &layer );
    layer->GetConfiguration( layer, &config );

    DFBRectangle windowRect        = {   0,  0, config.width, config.height };
    DFBRectangle webviewRect       = {   0,  0, config.width, config.height };

    lite_new_window( NULL, &windowRect, DWCAPS_NONE, liteNoWindowTheme, "WebKitDFB", &g_window );
    
    lite_new_webview( LITE_BOX(g_window), &webviewRect, liteDefaultWebViewTheme, &g_webview);

    lite_on_webview_doc_loaded ( g_webview, on_webview_doc_loaded, NULL );

    lite_on_raw_window_keyboard(g_window, on_key_press, g_webview );

    lite_focus_box( LITE_BOX(g_webview) );

    lite_set_window_opacity(g_window, 0xff);

    g_window->bg.enabled = DFB_FALSE;
    //lite_set_window_background_color(g_window, 0xff, 0, 0, 0xff);

    registerJsFunctions(g_webview, g_Callback);

    lite_webview_load(g_webview, g_url);
    lite_webview_set_transparent(g_webview, true);

    // FAKE KEY INTERFACE
    //IDirectFB *dfb;
    //dfb = lite_get_dfb_interface();
    //IDirectFBDisplayLayer *layer = NULL;
    //dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer);
    layer->GetWindow(layer, 1, &g_dfb_window);

    lite_enqueue_window_timeout(200, timeout_cb, NULL, &timer_id);
    g_run = 1;
    while (g_run) {
        pthread_mutex_lock(&mutex);

        g_main_context_iteration(NULL, FALSE);
        lite_window_event_loop(g_window, 1);
        pthread_mutex_unlock(&mutex);
    }

   lite_close();

   return NULL;
}
コード例 #20
0
int
main( int argc, char *argv[] )
{
     DFBResult              ret;
     IDirectFB             *dfb;
     IDirectFBDisplayLayer *layer;

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


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

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


     while (true) {
          DFBWindowDescription   desc;
          IDirectFBWindow       *window;
          IDirectFBSurface      *surface;

          desc.flags  = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS;
          desc.posx   = 150;
          desc.posy   = 150;
          desc.width  = 300;
          desc.height = 300;
          desc.caps   = DWCAPS_ALPHACHANNEL;
     
          ret = layer->CreateWindow( layer, &desc, &window );
          if (ret) {
               D_DERROR( ret, "DFBTest/Window_Surface: CreateWindow() failed!\n" );
               return ret;
          }
     
          window->GetSurface( window, &surface );

          D_INFO( "Created window and surface, going to release window... (in 2 seconds)\n" );
          usleep( 2000000 );

          D_INFO("Releasing window...\n");

          window->Release( window );

          D_INFO("Window released, going to release surface... (in 2 seconds)\n");
          usleep( 2000000 );

          D_INFO("Releasing surface...\n");

          surface->Release( surface );

          D_INFO("Surface released, done.\n");
          usleep( 5000000 );
     }


     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
コード例 #21
0
ファイル: dfbinfo.c プロジェクト: batman52/dingux-code
static DFBEnumerationResult
display_layer_callback( DFBDisplayLayerID           id,
                        DFBDisplayLayerDescription  desc,
                        void                       *arg )
{
     int i;

     /* Name */
     printf( "     Layer (%02x) %-30s", id, desc.name );

     switch (id) {
          case DLID_PRIMARY:
               printf( "  (primary layer)" );
               break;
          default:
               break;
     }

     printf( "\n" );


     /* Type */
     printf( "        Type:    " );

     for (i=0; layer_types[i].type; i++) {
          if (desc.type & layer_types[i].type)
               printf( "%s ", layer_types[i].name );
     }

     printf( "\n" );


     /* Caps */
     printf( "        Caps:    " );

     for (i=0; layer_caps[i].capability; i++) {
          if (desc.caps & layer_caps[i].capability)
               printf( "%s ", layer_caps[i].name );
     }

     printf( "\n" );


     /* Sources */
     if (desc.caps & DLCAPS_SOURCES) {
          DFBResult                         ret;
          IDirectFBDisplayLayer            *layer;
          DFBDisplayLayerSourceDescription  descs[desc.sources];

          ret = dfb->GetDisplayLayer( dfb, id, &layer );
          if (ret) {
               DirectFBError( "DirectFB::GetDisplayLayer() failed", ret );
          }
          else {
               ret = layer->GetSourceDescriptions( layer, descs );
               if (ret) {
                    DirectFBError( "DirectFBDisplayLayer::GetSourceDescriptions() failed", ret );
               }
               else {
                    printf( "        Sources: " );

                    for (i=0; i<desc.sources; i++) {
                         if (i > 0)
                              printf( ", %s", descs[i].name );
                         else
                              printf( "%s", descs[i].name );
                    }

                    printf( "\n" );
               }

               layer->Release( layer );
          }
     }


     printf( "\n" );

     return DFB_OK;
}
コード例 #22
0
int
main( int argc, char *argv[] )
{
    DFBResult              ret;
    int                    i;
    IDirectFB             *dfb;
    IDirectFBDisplayLayer *layer;

    /* 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;

    SHOW_INFO( "Starting up..." );

    /* Create the super interface. */
    ret = DirectFBCreate( &dfb );
    if (ret) {
        DirectFBError( "DirectFBCreate() failed", ret );
        return -3;
    }

    /* Get the primary layer interface. */
    ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
    if (ret) {
        D_DERROR( ret, "IDirectFB::GetDisplayLayer() failed!\n" );
        dfb->Release( dfb );
        return -4;
    }


    if (!m_toplevel_id)
        RunTest( Test_CreateWindow, "CreateWindow", layer, NULL );

    RunTest( Test_CreateSubWindow, "CreateSubWindow", layer, NULL );


    for (i=0; i<D_ARRAY_SIZE(m_tests); i++) {
        if (m_tests[i].run_top)
            RunTest( m_tests[i].func, m_tests[i].name, layer, NULL );

        if (m_tests[i].run_sub)
            RunTest( m_tests[i].func, m_tests[i].name, layer, (void*) (unsigned long) m_subwindow_id );
    }

    while (m_wait_at_end)
        direct_thread_sleep( 1000000 );

    SHOW_INFO( "Shutting down..." );

    /* Release the sub window. */
    if (m_subwindow)
        m_subwindow->Release( m_subwindow );

    /* Release the top level. */
    if (m_toplevel)
        m_toplevel->Release( m_toplevel );

    /* Release the layer. */
    layer->Release( layer );

    /* Release the super interface. */
    dfb->Release( dfb );

    return EXIT_SUCCESS;
}
コード例 #23
0
ファイル: SDL_DirectFB_yuv.c プロジェクト: 3bu1/crossbridge
static DFBResult CreateYUVSurface(_THIS, struct private_yuvhwdata *hwdata,
                                  int width, int height, Uint32 format)
{
  DFBResult              ret;
  IDirectFB             *dfb = HIDDEN->dfb;
  IDirectFBDisplayLayer *layer;
  DFBDisplayLayerConfig  conf;

  ret = dfb->EnumDisplayLayers (dfb, enum_layers_callback, hwdata);
  if (ret)
    {
      SetDirectFBerror("IDirectFB::EnumDisplayLayers", ret);
      return ret;
    }

  if (!hwdata->layer_id)
    return DFB_UNSUPPORTED;

  ret = dfb->GetDisplayLayer (dfb, hwdata->layer_id, &layer);
  if (ret)
    {
      SetDirectFBerror("IDirectFB::GetDisplayLayer", ret);
      return ret;
    }

  conf.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT;
  conf.width = width;
  conf.height = height;

  switch (format)
    {
    case SDL_YV12_OVERLAY:
      conf.pixelformat = DSPF_YV12;
      break;
    case SDL_IYUV_OVERLAY:
      conf.pixelformat = DSPF_I420;
      break;
    case SDL_YUY2_OVERLAY:
      conf.pixelformat = DSPF_YUY2;
      break;
    case SDL_UYVY_OVERLAY:
      conf.pixelformat = DSPF_UYVY;
      break;
    default:
      fprintf (stderr, "SDL_DirectFB: Unsupported YUV format (0x%08x)!\n", format);
      break;
    }

  /* Need to set coop level or newer DirectFB versions will fail here. */
  ret = layer->SetCooperativeLevel (layer, DLSCL_ADMINISTRATIVE);
  if (ret)
    {
      SetDirectFBerror("IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret);
      layer->Release (layer);
      return ret;
    }

  ret = layer->SetConfiguration (layer, &conf);
  if (ret)
    {
      SetDirectFBerror("IDirectFBDisplayLayer::SetConfiguration", ret);
      layer->Release (layer);
      return ret;
    }

  ret = layer->GetSurface (layer, &hwdata->surface);
  if (ret)
    {
      SetDirectFBerror("IDirectFBDisplayLayer::GetSurface", ret);
      layer->Release (layer);
      return ret;
    }

  hwdata->layer = layer;

  return DFB_OK;
}
コード例 #24
0
void
DirectFB_InitModes(_THIS)
{
    SDL_DFB_DEVICEDATA(_this);
    IDirectFBDisplayLayer *layer = NULL;
    SDL_VideoDisplay display;
    DFB_DisplayData *dispdata = NULL;
    SDL_DisplayMode mode;
    DFBGraphicsDeviceDescription caps;
    DFBDisplayLayerConfig dlc;
    struct screen_callback_t *screencbdata;

    int tcw[DFB_MAX_SCREENS];
    int tch[DFB_MAX_SCREENS];
    int i;
    DFBResult ret;

    SDL_DFB_ALLOC_CLEAR(screencbdata, sizeof(*screencbdata));

    screencbdata->numscreens = 0;

    for (i = 0; i < DFB_MAX_SCREENS; i++) {
        screencbdata->gralayer[i] = -1;
        screencbdata->vidlayer[i] = -1;
    }

    SDL_DFB_CHECKERR(devdata->dfb->EnumScreens(devdata->dfb, &EnumScreensCallback,
                                               screencbdata));

    for (i = 0; i < screencbdata->numscreens; i++) {
        IDirectFBScreen *screen;

        SDL_DFB_CHECKERR(devdata->dfb->GetScreen(devdata->dfb,
                                                 screencbdata->screenid
                                                 [i], &screen));

        screencbdata->aux = i;
        SDL_DFB_CHECKERR(screen->EnumDisplayLayers(screen, &EnumLayersCallback,
                                                   screencbdata));
        screen->GetSize(screen, &tcw[i], &tch[i]);

        screen->Release(screen);
    }

    /* Query card capabilities */

    devdata->dfb->GetDeviceDescription(devdata->dfb, &caps);

    for (i = 0; i < screencbdata->numscreens; i++) {
        SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb,
                                                       screencbdata->gralayer
                                                       [i], &layer));

        SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer,
                                                    DLSCL_ADMINISTRATIVE));
        layer->EnableCursor(layer, 1);
        SDL_DFB_CHECKERR(layer->SetCursorOpacity(layer, 0xC0));

        if (devdata->use_yuv_underlays) {
            dlc.flags = DLCONF_PIXELFORMAT | DLCONF_OPTIONS;
            dlc.pixelformat = DSPF_ARGB;
            dlc.options = DLOP_ALPHACHANNEL;

            ret = layer->SetConfiguration(layer, &dlc);
            if (ret != DFB_OK) {
                /* try AiRGB if the previous failed */
                dlc.pixelformat = DSPF_AiRGB;
                SDL_DFB_CHECKERR(layer->SetConfiguration(layer, &dlc));
            }
        }

        /* Query layer configuration to determine the current mode and pixelformat */
        dlc.flags = DLCONF_ALL;
        SDL_DFB_CHECKERR(layer->GetConfiguration(layer, &dlc));

        mode.format = DirectFB_DFBToSDLPixelFormat(dlc.pixelformat);
        
        if (mode.format == SDL_PIXELFORMAT_UNKNOWN) {
            SDL_DFB_ERR("Unknown dfb pixelformat %x !\n", dlc.pixelformat);
            goto error;
        }

        mode.w = dlc.width;
        mode.h = dlc.height;
        mode.refresh_rate = 0;
        mode.driverdata = NULL;

        SDL_DFB_ALLOC_CLEAR(dispdata, sizeof(*dispdata));

        dispdata->layer = layer;
        dispdata->pixelformat = dlc.pixelformat;
        dispdata->cw = tcw[i];
        dispdata->ch = tch[i];

        /* YUV - Video layer */

        dispdata->vidID = screencbdata->vidlayer[i];
        dispdata->vidIDinuse = 0;

        SDL_zero(display);

        display.desktop_mode = mode;
        display.current_mode = mode;
        display.driverdata = dispdata;

#if (DFB_VERSION_ATLEAST(1,2,0))
        dlc.flags =
            DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT |
            DLCONF_OPTIONS;
        ret = layer->SetConfiguration(layer, &dlc);
#endif

        SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer, DLSCL_SHARED));

        SDL_AddVideoDisplay(&display);
    }
    SDL_DFB_FREE(screencbdata);
    return;
  error:
    /* FIXME: Cleanup not complete, Free existing displays */
    SDL_DFB_FREE(dispdata);
    SDL_DFB_RELEASE(layer);
    return;
}
コード例 #25
0
ファイル: test_pcba.c プロジェクト: vonfritz/owl
int main(int argc, char *argv[])
{
	IDirectFBDisplayLayer 	*layer;
	DFBWindowDescription	dwsc;
	DFBSurfaceDescription 	dsc;
	DFBDisplayLayerConfig	config;
	IDirectFBWindow 	*window_mic, *window_camera, *window_case, *window_tp;
	IDirectFBSurface 	*surface_case, *surface_tp, *surface_camera;
	IDirectFBSurface 	*surface_mic, *primary, *surface_button;
	IDirectFBFont 		*font;
	DFBRectangle		rect;
	DFBFontDescription 	font_desc;
	DirectThread     *thread_camera, *thread_music, *thread_mic, *thread_tp, *thread_flashlight, *thread_case[case_num];
	DirectThread 	*thread_button;
	 

//	int font_size = 24;
//	int camera_frame = 0;

	int i;
	char font_file[50] = "/misc/font/wqy-zenhei.ttc";
	char conf_file[50] = "/misc/pcba.conf";

	
	bool overflow = false;
	
	case_t *case_x;
	case_x = malloc((case_num + 3) * sizeof(case_t));
	
	//20 case,11 auto case,gps is the last autocase
	init_case(case_x, case_num + 3, gps + 1);
	
	if(parser_config_file(conf_file, case_x))
	{
		printf("config file open error, use default\n");
	}
	
	parse_global_config(case_x);

	printf("camera_frame = %d\n", camera_frame);
	printf("font_size = %d\n", font_size);
	printf("camera pixel [%d*%d]\n", camera_pixel_width, camera_pixel_height);

#ifndef __GS900A__
	ion_open_alc();
#endif
	//define window size
	int screen_width, screen_height;
	int mic_width, camera_window_width, camera_window_height;
	int case_width, case_name_align, case_result_align;
	int font_height;
	
	//change env
	char event_path[100];
	char env_gsensor[256];
	
	//enable gsensor
	i = get_input_event_name(case_x[gsensor].dev_name, event_path);
	if(i != -1)
	{
		sprintf(env_gsensor, "echo 1 > /sys/class/input/input%d/enable", i);
		system(env_gsensor);
	}
	else
	{
		printf("----error! gsensor not found\n");
	}
	
	//vibrate test for 3 second
	test_vibrate(3);
	
	//dfb init
	DFBCHECK(DirectFBInit(&argc, &argv));
	DFBCHECK(DirectFBCreate(&dfb));
	
	font_desc.flags = DFDESC_HEIGHT;
	font_desc.height = font_size;
	DFBCHECK(dfb->CreateFont( dfb, font_file,  &font_desc, &font));
	DFBCHECK(font->GetHeight(font, &font_height));
	DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer));
	DFBCHECK(layer->GetConfiguration( layer, &config ));
	// DFBCHECK(layer->SetRotation( layer, 180 ));
	//set window size
	screen_width = config.width;
	screen_height = config.height;
	mic_width = screen_width / 20;
	camera_window_width = (screen_width - mic_width) / 2;
	camera_window_height = screen_height / 2;
	case_width = screen_width - mic_width - camera_window_width;
	case_name_align = font_size;
	case_result_align = 7 * font_size;
	
	//create tp window
	dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS;
	dwsc.posx = 0;
	dwsc.posy = 0;
	dwsc.width = screen_width;
	dwsc.height = screen_height;
	dwsc.caps = DWCAPS_ALPHACHANNEL;
	
	DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_tp));
	DFBCHECK(window_tp->GetSurface(window_tp, &surface_tp));
	DFBCHECK(window_tp->SetOptions(window_tp, DWOP_ALPHACHANNEL));
	DFBCHECK(window_tp->SetStackingClass(window_tp, DWSC_UPPER));
	DFBCHECK(window_tp->RaiseToTop(window_tp));
	DFBCHECK(surface_tp->Clear(surface_tp, 0, 0, 0, 0));
	DFBCHECK(surface_tp->SetColor(surface_tp, 0, 0xff, 0, 0xff));
	DFBCHECK(window_tp->SetOpacity(window_tp, 0xff));
	
	//config camera window
	dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT;
	dwsc.posx = case_width + mic_width;
	dwsc.posy = 0;
	dwsc.width = camera_window_width;
	dwsc.height = screen_height;
	
	DFBCHECK(layer->CreateWindow( layer, &dwsc, &window_camera ));
	DFBCHECK(window_camera->GetSurface(window_camera, &windowsurface));
	DFBCHECK(windowsurface->SetColor(windowsurface, 0, 0, 0, 0xff));
	DFBCHECK(windowsurface->FillRectangle(windowsurface, 0, 0, camera_window_width , screen_height));
	DFBCHECK(windowsurface->Flip(windowsurface, NULL, 0));
	DFBCHECK(window_camera->SetOpacity( window_camera, 0xff ));
	
	drawRGB(windowsurface, 0, screen_height / 2, camera_window_width, screen_height /2);
	
	rect.x = 0;
	rect.y = 0;
	rect.w = camera_window_width;
	rect.h = camera_window_height;
	DFBCHECK(windowsurface->GetSubSurface(windowsurface, &rect, &surface_camera));
	
	rect.x = 0;
	rect.y = screen_height / 4 * 3;
	rect.w = camera_window_width;
	rect.h = screen_height - rect.y;
	DFBCHECK(windowsurface->GetSubSurface(windowsurface, &rect, &surface_button));
	
	//create camera surface
	dsc.flags       = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
    dsc.pixelformat = DSPF_NV12;
	dsc.width = camera_pixel_width;
	dsc.height = camera_pixel_height;
	DFBCHECK(dfb->CreateSurface(dfb, &dsc, &camera_source));
	
	//config mic window
	dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT;
	dwsc.posx = case_width;
	dwsc.posy = 0;
	dwsc.width = mic_width;
	dwsc.height = screen_height;
	
	DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_mic));
	DFBCHECK(window_mic->GetSurface(window_mic, &surface_mic));
	DFBCHECK(surface_mic->SetColor(surface_mic, 0, 0, 0, 0xff));
	DFBCHECK(surface_mic->FillRectangle(surface_mic, 0, 0, mic_width , screen_height));
	DFBCHECK(surface_mic->Flip(surface_mic, NULL, 0));
	DFBCHECK(window_mic->SetOpacity( window_mic, 0xff));
	
	//config case window
	dwsc.posx = 0;
	dwsc.posy = 0;
	dwsc.width = case_width;
	dwsc.height = screen_height;
	
	DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_case));
	DFBCHECK(window_case->GetSurface(window_case, &surface_case));
	DFBCHECK(surface_case->SetColor(surface_case, 0xff, 0xff, 0xff, 0xff));
	DFBCHECK(surface_case->SetFont(surface_case, font));
	DFBCHECK(surface_case->FillRectangle(surface_case, 0, 0, case_width, screen_height));
	
	//draw headline
	DFBCHECK(surface_case->SetColor(surface_case, 0xff, 0xff, 0, 0xff));
	DFBCHECK(surface_case->FillRectangle(surface_case, 0, 0, case_width, font_size + 2));
	DFBCHECK(surface_case->FillRectangle(surface_case, 0, screen_height / 2, case_width, font_size + 2));
	DFBCHECK(surface_case->SetColor(surface_case, 0, 0, 0, 0xff));
	DFBCHECK(surface_case->DrawString(surface_case, "自动测试选项", -1, case_width / 2, 0, DSTF_TOPCENTER));
	DFBCHECK(surface_case->DrawString(surface_case, "手动测试选项", -1, case_width / 2, screen_height / 2, DSTF_TOPCENTER));
	
	int auto_skip = 0;
	int manu_skip = 0;
	int skip_height = 0;
	bool double_line = false;
	//draw string
	for(i = 0; i < case_num; i++)
	{
		double_line = false;
		if(overflow)
		{
			case_x[i].enable = 0;
			continue;
		}
		if(!case_x[i].enable)
		{
			if(case_x[i].type)
				manu_skip++;
			else
				auto_skip++;
				
			//case_x[i].position = -1;
			continue;
		}
		if(case_x[i].doubleline == 1)
		{
			double_line = true;
		}
		if(case_x[i].type)
			skip_height = manu_skip * (font_height);
		else
			skip_height = auto_skip * (font_height);
		
		case_x[i].position = case_x[i].type * screen_height / 2 + (case_x[i].index + 1) * (font_height);
		case_x[i].position -= skip_height;
		
		// printf("name_h = %d\n", case_x[i].position);
		DFBCHECK(surface_case->SetColor(surface_case, 0, 0, 0, 0xff));
		DFBCHECK(surface_case->DrawString(surface_case, case_x[i].name, -1, case_name_align, case_x[i].position, DSTF_TOPLEFT));
		DFBCHECK(surface_case->SetColor(surface_case, 0xc0, 0xc0, 0xc0, 0xff));
		DFBCHECK(surface_case->DrawString(surface_case, case_x[i].init_string, -1, case_result_align, case_x[i].position, DSTF_TOPLEFT));
		
		rect.x = case_result_align;
		rect.y = case_x[i].position;
		rect.w = case_width - case_result_align;
		rect.h = font_height;
		if((rect.y + rect.h) > screen_height)
		{
			overflow = true;
			case_x[i].enable = 0;
			printf("case %d overflow, disable all case after it\n", i);
			continue;
		}
		if(double_line)
		{
			// case_x[i].position = -2;
			rect.h *= 2;
			if(case_x[i].type)
				manu_skip--;
			else
				auto_skip--;
		}
		DFBCHECK(surface_case->GetSubSurface(surface_case, &rect, &case_x[i].surface));
		DFBCHECK(case_x[i].surface->SetFont(case_x[i].surface, font));
	}
	
	DFBCHECK(window_case->SetOpacity(window_case, 0xff ));

#ifdef __GS900A__
	system("echo 1 > /sys/devices/e0250000.hdmi/enable");
#endif
	//start case thread
	for(i = 0; i < case_num; i++)
	{
		char thread_name[10];
		sprintf(thread_name,"thread_%d", i);
		if(case_x[i].enable)
		{
			thread_case[i] = direct_thread_create(DTT_DEFAULT, case_thread, &case_x[i], thread_name);
		}
	}
	
	case_x[tp].surface = surface_tp;
	
	//start thread
#ifdef __GS702C__
	thread_music = direct_thread_create(DTT_DEFAULT, music_thread, NULL, "music");
	thread_mic = direct_thread_create(DTT_DEFAULT, mic_thread, surface_mic, "mic");
#else
	thread_music  = direct_thread_create(DTT_DEFAULT, tinyalsa_music_thread, NULL, "tinyalsa_music");
	thread_mic = direct_thread_create(DTT_DEFAULT, tinyalsa_mic_thread, surface_mic, "tinyalsa_mic");
#endif

	thread_tp = direct_thread_create(DTT_DEFAULT, tp_thread, &case_x[tp], "tp");
	thread_flashlight = direct_thread_create(DTT_DEFAULT, flashlight_thread, &case_x[flashlight], "flashlight");
	thread_camera = direct_thread_create(DTT_DEFAULT, camera_thread, &camera_frame, "camera" );
	//thread_mic = direct_thread_create(DTT_DEFAULT, mic_thread, surface_mic, "mic");
	thread_button = direct_thread_create(DTT_DEFAULT, handle_record_button, surface_button, "button");
	sleep(1);
	
	DFBCHECK(surface_case->Flip(surface_case, NULL, 0));
	
	if(iio_read(info, case_x[gsensor].enable, case_x[gyro].enable, case_x[comp].enable) == -1)
		printf("get iio device error\n");
		
	//block in iio_read
	//useless statement
	for(i = 0; i < case_num; i++)
	{
		if(case_x[i].enable)
		{
			direct_thread_join(thread_case[i]);
			case_x[i].surface->Release(case_x[i].surface);
			direct_thread_destroy(thread_case[i]);
			printf("thread %d destroyed\n", i);
		}
	}

	direct_thread_join(thread_camera);
	direct_thread_destroy(thread_camera);
	direct_thread_join(thread_music);
	direct_thread_destroy(thread_music);
	direct_thread_join(thread_mic);
	direct_thread_destroy(thread_mic);

	surface_button->Release(surface_button);
	surface_camera->Release(surface_camera);
	camera_source->Release(camera_source);
	windowsurface->Release(windowsurface);
	window_camera->Release(window_camera);
	
	surface_case->Release(surface_case);
	window_case->Release(window_case);
	layer->Release(layer);
	font->Release(font);
	dfb->Release(dfb);
	
#ifndef __GS900A__
	ion_close_alc();
#endif
}
コード例 #26
0
ファイル: dfbtest_layer.c プロジェクト: Distrotech/DirectFB
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 );

          if (opacity == 255)
               opacity_delta = -1;
          else if (opacity == 0)
               opacity_delta = 1;

          opacity += opacity_delta;


          layer->SetSourceRectangle( layer, x, y, size.w - sw3, size.h - sh3 );

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

          if (dx > 0) {
               if (x == size.w/3) {
                    dx = -1;

                    usleep( 500000 );
               }
          }
          else if (x == 0) {
               dx = 1;

               usleep( 500000 );
          }

          if (dy > 0) {
               if (y == size.h/3) {
                    dy = -1;

                    usleep( 500000 );
               }
          }
          else if (y == 0) {
               dy = 1;

               usleep( 500000 );
          }

          usleep( 10000 );

          /* Process keybuffer */
          while (keybuffer->GetEvent( keybuffer, DFB_EVENT(&evt)) == DFB_OK)
          {
              if (evt.type == DIET_KEYPRESS) {
                  switch (DFB_LOWER_CASE(evt.key_symbol)) {
                      case DIKS_ESCAPE:
                      case DIKS_SMALL_Q:
                      case DIKS_BACK:
                      case DIKS_STOP:
                      case DIKS_EXIT:
                          /* Quit main loop & test thread */
                          quit = 1;
                          break;
                      default:
                          break;
                  }
              }
          }

     }

     surface->Release( surface );
     layer->Release( layer );

     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
コード例 #27
0
int
main( int argc, char *argv[] )
{
     DFBResult              ret;
     bool                   quit = false;
     int                    i;
     IDirectFB              dfb;
     IDirectFBDisplayLayer  layer;
     IDirectFBSurface       surface;
     DFBDisplayLayerConfig  config;
     DFBDimension           sizes[2]  = { {400, 400}, {600, 600} };
     size_t                 num_sizes = D_ARRAY_SIZE(sizes);
     DFBInputEvent          evt;
     IDirectFBEventBuffer   keybuffer;

     /* Initialize DirectFB. */
     DirectFB::Init( &argc, &argv );

     /* Create super interface. */
     dfb = DirectFB::Create();

     layer = dfb.GetDisplayLayer( DLID_PRIMARY );

     /* Create an input buffer for key events */
     keybuffer = dfb.CreateInputEventBuffer( DICAPS_KEYS, DFB_TRUE );

     layer.SetCooperativeLevel( DLSCL_EXCLUSIVE );

     layer.GetConfiguration( &config );

     config.width  = sizes[0].w;
     config.height = sizes[0].h;

     layer.SetConfiguration( config );

     surface = layer.GetSurface();

     while (true) {
          surface.Clear( 0, 0, 0, 0xff );

          surface.SetColor( 0x00, 0xff, 0x00, 0xff );
          surface.DrawRectangle( 0, 0, config.width, config.height );

          surface.Flip( NULL, DSFLIP_NONE );


          keybuffer.WaitForEventWithTimeout( 3, 0 );

          /* Process keybuffer */
          while (keybuffer.GetEvent( DFB_EVENT(&evt) )) {
              if (evt.type == DIET_KEYPRESS) {
                  switch (DFB_LOWER_CASE(evt.key_symbol)) {
                      case DIKS_ESCAPE:
                      case DIKS_SMALL_Q:
                      case DIKS_BACK:
                      case DIKS_STOP:
                      case DIKS_EXIT:
                          /* Quit main loop & test thread */
                          quit = 1;
                          break;

                      case DIKS_SPACE:
                      case DIKS_OK:
                          i++;

                          config.width  = sizes[i % num_sizes].w;
                          config.height = sizes[i % num_sizes].h;

                          layer.SetConfiguration( config );
                          break;

                      default:
                          break;
                  }
              }
          }
     }

     return 0;
}