status_t ServerWindow::UpdateTitle (char *title){
	DFBFontDescription font_dsc;
	IDirectFBSurface *wsurface = NULL;
	int wdth;
	int ht;
	int width1, width2, width3;
	int height1, height2, height3;
		
	DFBCHECK(window->GetSurface(window, &wsurface));  
	DFBCHECK(window->GetSize(window, &wdth, &ht));
	
  if (fType==B_FLOATING_WINDOW){
  	DFBCHECK (shead->GetSize(shead, &width1, &height1));
	DFBCHECK (sok_button->GetSize(sok_button, &width2, &height2));
	DFBCHECK (sclose_button->GetSize(sclose_button, &width3, &height3));

	DFBRectangle rect;
	rect.x = 0;	rect.y = 0;	rect.h = height1;	rect.w = wdth-width2-width3;
	DFBCHECK (wsurface->StretchBlit (wsurface, shead, NULL, &rect));
	DFBCHECK (wsurface->Blit (wsurface, sok_button, NULL, rect.w, 0));
  	DFBCHECK (wsurface->Blit (wsurface, sclose_button, NULL, rect.w+width2, 0));	  		
	
  	// Draw the window title
  	font_dsc.flags = DFDESC_HEIGHT;
  	font_dsc.height = 10;
  	font_dsc.width = 10;  
  	DFBCHECK (app_server->dfb->CreateFont (app_server->dfb, "./decker.ttf", &font_dsc, &font));
  	DFBCHECK (wsurface->SetFont (wsurface, font));
  	DFBCHECK (wsurface->SetColor (wsurface, 0xff, 0x0, 0x0, 0xFF));  	
	DFBCHECK (wsurface->DrawString (wsurface, title, -1, 5, 2*height1/3, DSTF_LEFT));	
  }
  else if (fType==B_TITLED_WINDOW){
  	DFBCHECK (head->GetSize(head, &width1, &height1));
	DFBCHECK (ok_button->GetSize(ok_button, &width2, &height2));
	DFBCHECK (close_button->GetSize(close_button, &width3, &height3));

	DFBRectangle rect;
	rect.x = 0;	rect.y = 0;	rect.h = height1;	rect.w = wdth-width2-width3;
	DFBCHECK (wsurface->StretchBlit (wsurface, head, NULL, &rect));
	DFBCHECK (wsurface->Blit (wsurface, ok_button, NULL, rect.w, 0));
  	DFBCHECK (wsurface->Blit (wsurface, close_button, NULL, rect.w+width2, 0));	
  	
	// Draw the window title
  	font_dsc.flags = DFDESC_HEIGHT;
  	font_dsc.height = 15;
  	font_dsc.width = 15;  
  	DFBCHECK (app_server->dfb->CreateFont (app_server->dfb, "./decker.ttf", &font_dsc, &font));
  	DFBCHECK (wsurface->SetFont (wsurface, font));
  	DFBCHECK (wsurface->SetColor (wsurface, 0x0, 0x10, 0xfa, 0xFF));
	DFBCHECK (wsurface->DrawString (wsurface, title, -1, 6, 2*height1/3, DSTF_LEFT));	
  }	
}
static void
app_update( App *app )
{
     static const DFBColor colors[3] = {
          { 0xff, 0x30, 0xc0, 0xff },
          { 0xff, 0xff, 0xff, 0x30 },
          { 0xff, 0x30, 0xff, 0xc0 }
     };

     IDirectFBSurface *surface = app->surface;

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

     surface->SetColor( surface, colors[app->index].r, colors[app->index].g, colors[app->index].b, colors[app->index].a );
     surface->FillRectangle( surface, app->anim_x, app->anim_y, 40, 300 );

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


     app->anim_x += app->anim_dirx;
     if (app->anim_x >= app->resolution.w - 40)
          app->anim_dirx = -5;
     else if (app->anim_x <= 0)
          app->anim_dirx = 5;

     app->anim_y += app->anim_diry;
     if (app->anim_y >= app->resolution.h - 300)
          app->anim_diry = -5;
     else if (app->anim_y <= 0)
          app->anim_diry = 5;
          
}
static int
PrepareDraw(SDL_Renderer * renderer)
{
    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    IDirectFBSurface *destsurf = data->target;

    Uint8 r, g, b, a;

    r = renderer->r;
    g = renderer->g;
    b = renderer->b;
    a = renderer->a;

    SetBlendMode(data, renderer->blendMode, NULL);
    SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags));

    switch (renderer->blendMode) {
    case SDL_BLENDMODE_NONE:
    /* case SDL_BLENDMODE_MASK: */
    case SDL_BLENDMODE_BLEND:
        break;
    case SDL_BLENDMODE_ADD:
    case SDL_BLENDMODE_MOD:
        r = ((int) r * (int) a) / 255;
        g = ((int) g * (int) a) / 255;
        b = ((int) b * (int) a) / 255;
        a = 255;
        break;
    }

    SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, r, g, b, a));
    return 0;
  error:
    return -1;
}
Exemple #4
0
static int
_dfb_surface_set_blit_params(DirectFB_Engine_Image_Entry *d, DirectFB_Engine_Image_Entry *s, RGBA_Draw_Context *dc)
{
   IDirectFBSurface *surface;
   DFBSurfaceBlittingFlags blit_flags = DSBLIT_NOFX;
   DFBResult res;
   int r, g, b, a;

   _context_get_color(dc, &r, &g, &b, &a);
   if (a == 0)
     return 0;

   if (a != 255)
     blit_flags = DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR;

   if ((r != a) || (g != a) || (b != a))
     {
	blit_flags |= DSBLIT_COLORIZE;

	r = 0xff * r / a;
	g = 0xff * g / a;
	b = 0xff * b / a;
   }

   if (s->cache_entry.src->flags.alpha)
     blit_flags |= DSBLIT_BLEND_ALPHACHANNEL;

   surface = d->surface;

   if (blit_flags &
       (DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR | DSBLIT_COLORIZE))
     {
	res = surface->SetColor(surface, r, g, b, a);
	if (res != DFB_OK)
	  goto error;
     }

   res = surface->SetBlittingFlags(surface, blit_flags);
   if (res != DFB_OK)
     goto error;

#ifdef DFB_DEBUG_FLAGS
   DBG("sfunc=%s, dfunc=%s, color=%d %d %d %d, blit=%s, draw=%s",
	  _dfb_blend_func_str(src_func), _dfb_blend_func_str(dst_func),
	  r, g, b, a,
	  _dfb_blit_flags_str(blit_flags), _dfb_draw_flags_str(draw_flags));
#endif /* DFB_DEBUG_FLAGS */

   return 1;

 error:
   ERR("Could not set blit params: %s",
	 DirectFBErrorString(res));
   return 0;
}
Exemple #5
0
static mrb_value surface_set_color(mrb_state *mrb, mrb_value self)
{
    IDirectFBSurface* surface = mrb_directfb_surface(mrb, self);
    DFBResult ret = -1;
    if (surface != NULL) {
        mrb_int r, g, b, a;
        mrb_get_args(mrb, "iiii", &r, &g, &b, &a);
        ret = surface->SetColor(surface, r, g, b, a);
    }
    return mrb_fixnum_value(ret);
}
     /* render callback */
     virtual void Render( IDirectFBSurface &surface ) {
          surface.Clear( 0, 0, 255, 255 );


          surface.SetFont( font );

          surface.SetColor( 0, 0, 0, 255 );
          surface.SetSrcBlendFunction( DSBF_INVSRCALPHA );
          surface.SetDstBlendFunction( DSBF_INVSRCALPHA );

          surface.DrawString( "Test Text", -1, 10, 10, (DFBSurfaceTextFlags)(DSTF_TOPLEFT | DSTF_BLEND_FUNCS) );
     }
static int l_SetColor (lua_State* L)
{
	// [ sfc | r | g | b | a ]
	DFBColor color;
	IDirectFBSurface* sfc = * (IDirectFBSurface**) luaL_checkudata(L, 1, "ldirectfb.IDirectFBSurface");
	DFBCHECK( sfc->SetColor(sfc,
	                        luaL_checkint(L, 2),       // r
							luaL_checkint(L, 3),       // g
							luaL_checkint(L, 4),       // b
							luaL_optint(L, 5, 255)) ); // a
	return 0;
}
Exemple #8
0
static void* render_loop (void *arg)
{
     IDirectFBSurface *view = (IDirectFBSurface*)arg;

     view->SetBlittingFlags( view, DSBLIT_SRC_COLORKEY | DSBLIT_COLORIZE );

     while (started_rendering()) {
          int i;

          pthread_testcancel();

          view->SetColor( view, 0, 0, 0, 0 );
          view->FillRectangle( view, 0, 0, xres, yres );

          for (i=0; i<STARFIELD_SIZE; i++) {
               int map = (int)(t_starfield[i].pos.v[Z]) >> 8;
               int light = 0xFF - ((int)(t_starfield[i].pos.v[Z] * t_starfield[i].pos.v[Z]) >> 12);

               if (map >= 0 && light > 0) {
                    if (map >= NUM_STARS)
                         map = NUM_STARS - 1;

                    view->SetColor( view, light, light, light, 0xff );
                    view->Blit( view, stars[map], NULL,
                                (int)(t_starfield[i].pos.v[X]),
                                (int)(t_starfield[i].pos.v[Y]) );
               }
          }

          view->Flip( view, NULL, DSFLIP_WAITFORSYNC );

          finished_rendering();
     }

     pthread_testcancel();

     return NULL;
}
Exemple #9
0
static void
update( Context *context )
{
     unsigned long     t;
     IDirectFBSurface *surface = context->surface;
     static __u8  r = 0, g = 0, b = 0;
    
     
     context->gl->Lock( context->gl );

     glClearColor( r++/255.0, g++/255.0, b++/255.0, 1.0 );
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
     context->gl->Unlock( context->gl );
     
     if (context->fps) {
          char buf[16];

          snprintf(buf, sizeof(buf), "%.1f FPS\n", context->fps);

          surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff );
          surface->DrawString( surface, buf, -1,
                               context->width - 5, 5, DSTF_TOPRIGHT );
     }
     
     surface->Flip( surface, NULL, 0 );

     context->frames++;

     t = get_millis();
     if (t - context->last_time >= 2000) {
          float seconds = (t - context->last_time) / 1000.0f;

          context->fps = context->frames / seconds;

          context->last_time = t;
          context->frames    = 0;
     }
}
Exemple #10
0
void
DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
{
    SDL_DFB_WINDOWDATA(window);
    IDirectFBSurface *s = windata->window_surface;
    DFB_Theme *t = &windata->theme;
    int i;
    int d = (t->caption_size - t->font_size) / 2;
    int x, y, w;


    if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
        return;

    SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE));
    SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO));
    SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX));
    SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX));

    LoadFont(_this, window);
    /* s->SetDrawingFlags(s, DSDRAW_BLEND); */
    s->SetColor(s, COLOR_EXPAND(t->frame_color));
    /* top */
    for (i = 0; i < t->top_size; i++)
        s->DrawLine(s, 0, i, windata->size.w, i);
    /* bottom */
    for (i = windata->size.h - t->bottom_size; i < windata->size.h; i++)
        s->DrawLine(s, 0, i, windata->size.w, i);
    /* left */
    for (i = 0; i < t->left_size; i++)
        s->DrawLine(s, i, 0, i, windata->size.h);
    /* right */
    for (i = windata->size.w - t->right_size; i < windata->size.w; i++)
        s->DrawLine(s, i, 0, i, windata->size.h);
    /* Caption */
    s->SetColor(s, COLOR_EXPAND(t->caption_color));
    s->FillRectangle(s, t->left_size, t->top_size, windata->client.w,
                     t->caption_size);
    /* Close Button */
    w = t->caption_size;
    x = windata->size.w - t->right_size - w + d;
    y = t->top_size + d;
    s->SetColor(s, COLOR_EXPAND(t->close_color));
    DrawTriangle(s, 1, x, y, w - 2 * d);
    /* Max Button */
    s->SetColor(s, COLOR_EXPAND(t->max_color));
    DrawTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w,
               y, w - 2 * d);

    /* Caption */
    if (*window->title) {
        s->SetColor(s, COLOR_EXPAND(t->font_color));
        DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
    }
    /* Icon */
    if (windata->icon) {
        DFBRectangle dr;

        dr.x = t->left_size + d;
        dr.y = t->top_size + d;
        dr.w = w - 2 * d;
        dr.h = w - 2 * d;
        s->SetBlittingFlags(s, DSBLIT_BLEND_ALPHACHANNEL);

        s->StretchBlit(s, windata->icon, NULL, &dr);
    }
    windata->wm_needs_redraw = 0;
}
Exemple #11
0
static DFBResult
Test_CreateWindow( IDirectFBDisplayLayer *layer, void *arg )
{
    IDirectFBSurface *surface = NULL;
    IDirectFBWindow  *window;
    DFBWindowID       window_id;
    DFBDimension      size = { m_desc_top.width, m_desc_top.height };

    D_ASSERT( m_toplevel_id == 0 );

    /*
     * Create a new top level window
     */
    SHOW_TEST( "CreateWindow( %d,%d - %dx%d %s, options 0x%08x )...",
               m_desc_top.posx, m_desc_top.posy, m_desc_top.width, m_desc_top.height,
               dfb_pixelformat_name( m_desc_top.pixelformat ), m_desc_top.options );

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

    if (m_topcolor.valid) {
        DFBColor c = m_topcolor.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 blue (if not input or color only)
     */
    if (!(m_desc_top.caps & (DWCAPS_INPUTONLY | DWCAPS_COLOR) )) {
        SHOW_INFO( "  - GetSurface()..." );

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

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

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

        _T( surface->SetColor( surface, 0x90, 0xF0, 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 ) );
    }

    /*
     * 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_top.parent_id) {
        SHOW_INFO( "  - SetAssociation( %u )...", m_desc_top.parent_id );

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

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

    SHOW_RESULT( "...CreateWindow( %d,%d - %dx%d %s ) done. => Top Window ID %u",
                 m_desc_top.posx, m_desc_top.posy, m_desc_top.width, m_desc_top.height,
                 dfb_pixelformat_name( m_desc_top.pixelformat ), window_id );

    if (surface)
        surface->Release( surface );

    return DFB_OK;
}
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;
}
Exemple #13
0
int main (int argc,char *argv[])
{
  int videofd1 = open("/dev/video0",O_RDWR);
  int videofd2 = open("/dev/video0",O_RDWR);
  IDirectFBSurface     *SurfaceHandle;
  IDirectFBSurface     *SurfaceHandle2;
  void *ptr,*ptr2;
  int pitch,pitch2;
  int colour_palette[256];
  int colour_palette2_real[256]; /* random... */
  int *colour_palette2 = colour_palette2_real;
  int is_lut8;

  is_lut8 = (argc > 1 && !strcmp (argv[1], "both"));

  memset(&colour_palette,0x0,4*256);
  //memset(&colour_palette[1],0xff,255*4);

  colour_palette[0] = 0xff000000; // black
  colour_palette[1] = 0xffff0000; // red
  colour_palette[2] = 0xff00ff00; // green
  colour_palette[3] = 0xff0000ff; // blue
  colour_palette[4] = 0xffffffff; // white
  colour_palette[5] = 0x80808000; // half-transp yellow
  colour_palette[6] = 0x00000000; // transp black

  if (videofd1 < 0)
    perror("Couldn't open video device 1\n");

  if (videofd2 < 0)
    perror("Couldn't open video device 2\n");
  
  v4l2_list_outputs (videofd1);

  fb_make_transparent();

  init_dfb(&SurfaceHandle,is_lut8);
  init_dfb(&SurfaceHandle2,1);

  v4l2_set_output_by_name (videofd1, "RGB1");
  v4l2_set_output_by_name (videofd2, "RGB2");
  init_v4l(videofd1,0,0,1280,720,is_lut8);
  init_v4l(videofd2,0,0,1280,720,1);

  printf("%s:%d\n",__FUNCTION__,__LINE__);


//  memcpy (colour_palette, colour_palette2, sizeof (colour_palette));
  colour_palette2 = colour_palette;

  {
    int coords = 60;
    int size   = 100;

    // clear
    if (!is_lut8) SurfaceHandle->Clear (SurfaceHandle, 0x00, 0x00, 0x00, 0x00);
    else {
      SurfaceHandle->SetColorIndex (SurfaceHandle, 0x6);
      SurfaceHandle->FillRectangle (SurfaceHandle, 0, 0, 600, 600);
    }
    // White
    if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x4);
    else SurfaceHandle->SetColor (SurfaceHandle, 0xff, 0xff, 0xff, 0xff);
    SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
    coords += size;
    // Red
    if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x1);
    else SurfaceHandle->SetColor (SurfaceHandle, 0xff, 0x00, 0x00, 0xff);
    SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
    coords += size;
    // Green
    if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x2);
    else SurfaceHandle->SetColor (SurfaceHandle, 0x00, 0xff, 0x00, 0xff);
    SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
    coords += size;
    // Blue
    if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x3);
    else SurfaceHandle->SetColor (SurfaceHandle, 0x00, 0x00, 0xff, 0xff);
    SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
    coords += size;
    // half transp yellow
    if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x5);
    else SurfaceHandle->SetColor (SurfaceHandle, 0x80, 0x80, 0x00, 0x80);
    SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
    coords += size;
    // transp
    if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x6);
    else SurfaceHandle->SetColor (SurfaceHandle, 0x00, 0x00, 0x00, 0x00);
    SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
    coords += size;
  }

  {
    int xcoords = 60 + (100 * 6), ycoords = 60;
    int size   = 100;

    // clear
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x6);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, 220, 220, 440, 440);
    // transp
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x6);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
    xcoords -= size; ycoords += size;
    // half transp yellow
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x5);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
    xcoords -= size; ycoords += size;
    // Blue
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x3);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
    xcoords -= size; ycoords += size;
    // Green
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x2);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
    xcoords -= size; ycoords += size;
    // Red
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x1);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
    xcoords -= size; ycoords += size;
    // White
    SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x4);
    SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
    xcoords -= size; ycoords += size;
  }
    
  DFBCHECK (SurfaceHandle->Lock (SurfaceHandle, DSLF_READ, &ptr, &pitch));
  DFBCHECK (SurfaceHandle2->Lock (SurfaceHandle2, DSLF_READ, &ptr2, &pitch2));

  printf("%s:%d\n",__FUNCTION__,__LINE__);

  zorder(videofd2,V4L2_CID_STM_Z_ORDER_RGB2,1);
  zorder(videofd1,V4L2_CID_STM_Z_ORDER_RGB1,2);

  queue_buffer( videofd1, ptr, (is_lut8 ? colour_palette : 0), 0ULL);

  stream_on( videofd1 );

  getchar();
  queue_buffer( videofd2, ptr2, colour_palette2, 0ULL); 

  printf("%s:%d\n",__FUNCTION__,__LINE__);

  stream_on( videofd2 );

  printf("%s:%d\n",__FUNCTION__,__LINE__);


  getchar();

  zorder(videofd2,V4L2_CID_STM_Z_ORDER_RGB2,2);
  zorder(videofd1,V4L2_CID_STM_Z_ORDER_RGB1,1);

  fprintf(stderr,"Press Return/Enter to quit\n");
  getchar();

  // This seems to dequeue all buffers too, but that's what the spec says
  // so this is ok.
  stream_off( videofd1 );
  stream_off( videofd2 );

  deinit_dfb();
  close(videofd1);  

  return 0;
}
Exemple #14
0
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);
}
//---------------------------------------------------------------------------------
//--------------------------wael work----------------------
//---------------------------------------------------------------------------------
status_t ServerWindow::CreateWindow (IDirectFBDisplayLayer *layer){

  DFBFontDescription font_dsc;
  DFBWindowDescription wdsc;  
  IDirectFBSurface *wsurface = NULL;
  DFBSurfaceDescription dsc;
  
//  char *title;TODO: I need to convert the fTitle from BString to char *
  char title[fTitle.CountChars()+1];
  fTitle.CopyInto(title, 0, fTitle.CountChars());
  DFBRectangle frame;
  frame.x=(int)fFrame.LeftTop().x;
  frame.y=(int)fFrame.LeftTop().y;
  frame.w=(int)fFrame.IntegerWidth();
  frame.h=(int)fFrame.IntegerHeight();
    
  int width1, width2, width3;
  int height1, height2, height3;

  //create window inside the primary layer  
  wdsc.flags = (DFBWindowDescriptionFlags)(DWDESC_CAPS | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS);
  wdsc.caps = DWCAPS_ALPHACHANNEL;
  wdsc.width = frame.w;
  wdsc.height = frame.h;
  wdsc.posx = frame.x;
  wdsc.posy = frame.y;
  wdsc.surface_caps = DSCAPS_FLIPPING;
  DFBCHECK(layer->CreateWindow(layer, &wdsc, &window));
  
  //Get the window surface and clear it
  DFBCHECK(window->GetSurface(window, &wsurface));  
  DFBCHECK(wsurface->Clear (wsurface, 0x00, 0x00, 0x00, 0x00));
  DFBCHECK(window->SetOpaqueRegion (window, 0, 0, frame.h, frame.w));
  
  //Set the window options to be transparent
  DFBWindowOptions options;
  window->GetOptions (window, &options);
  
  options = (DFBWindowOptions) ( options | DWOP_SHAPED );
  DFBCHECK(window->SetOptions (window, options));  
  wsurface->SetSrcColorKey(wsurface, R, G, B);
  wsurface->SetBlittingFlags(wsurface, DSBLIT_SRC_COLORKEY);  
        
  if (fType==B_FLOATING_WINDOW){
  	DFBCHECK (shead->GetSize(shead, &width1, &height1));
	DFBCHECK (sok_button->GetSize(sok_button, &width2, &height2));
	DFBCHECK (sclose_button->GetSize(sclose_button, &width3, &height3));

	DFBRectangle rect;
	rect.x = 0;
	rect.y = 0;
	rect.h = height1;
	rect.w = frame.w-width2-width3;
	DFBCHECK (wsurface->StretchBlit (wsurface, shead, NULL, &rect));
	DFBCHECK (wsurface->Blit (wsurface, sok_button, NULL, rect.w, 0));
  	DFBCHECK (wsurface->Blit (wsurface, sclose_button, NULL, rect.w+width2, 0));	  	

  	// Draw the window title
  	font_dsc.flags = DFDESC_HEIGHT;
  	font_dsc.height = 10;
  	font_dsc.width = 10;  
  	DFBCHECK (app_server->dfb->CreateFont (app_server->dfb, "./decker.ttf", &font_dsc, &font));
  	DFBCHECK (wsurface->SetFont (wsurface, font));
  	DFBCHECK (wsurface->SetColor (wsurface, 0xff, 0x0, 0x0, 0xFF));
	int size = 0;
	DFBRectangle rect1;		
  	DFBCHECK (font->GetStringExtents (font, title, -1, NULL, &rect1));
	if (rect1.w > rect.w){
		do{
			size++;
			DFBCHECK (font->GetStringExtents (font, title, size, NULL, &rect1));
		}while (rect1.w < rect.w);
		size--;
	}  		  	
	DFBCHECK (wsurface->DrawString (wsurface, title, size-1, 5, 2*height1/3, DSTF_LEFT));	
		
	rect.x = 0;
	rect.y = height1;
	rect.w = frame.w;
	rect.h = frame.h-height1;
	DFBCHECK (wsurface->StretchBlit (wsurface, body, NULL, &rect));	
  }
  else if (fType==B_TITLED_WINDOW){
  	DFBCHECK (head->GetSize(head, &width1, &height1));
	DFBCHECK (ok_button->GetSize(ok_button, &width2, &height2));
	DFBCHECK (close_button->GetSize(close_button, &width3, &height3));

	DFBRectangle rect;
	rect.x = 0;
	rect.y = 0;
	rect.h = height1;
	rect.w = frame.w-width2-width3;
	DFBCHECK (wsurface->StretchBlit (wsurface, head, NULL, &rect));
	DFBCHECK (wsurface->Blit (wsurface, ok_button, NULL, rect.w, 0));
  	DFBCHECK (wsurface->Blit (wsurface, close_button, NULL, rect.w+width2, 0));
	
	// Draw the window title
  	font_dsc.flags = DFDESC_HEIGHT;
  	font_dsc.height = 15;
  	font_dsc.width = 15;  
  	DFBCHECK (app_server->dfb->CreateFont (app_server->dfb, "./decker.ttf", &font_dsc, &font));
  	DFBCHECK (wsurface->SetFont (wsurface, font));
  	DFBCHECK (wsurface->SetColor (wsurface, 0x0, 0x10, 0xfa, 0xFF));
	int size = 0;
	DFBRectangle rect1;		
  	DFBCHECK (font->GetStringExtents (font, title, -1, NULL, &rect1));
	if (rect1.w > rect.w){
		do{
			size++;
			DFBCHECK (font->GetStringExtents (font, title, size, NULL, &rect1));
		}while (rect1.w < rect.w);
		size-=2;
	}  		
	DFBCHECK (wsurface->DrawString (wsurface, title, -1, 6, 2*height1/3, DSTF_LEFT));	
		
	rect.x = 0;
	rect.y = height1;
	rect.w = frame.w;
	rect.h = frame.h-height1;
  	DFBCHECK (wsurface->StretchBlit (wsurface, body, NULL, &rect));  	
  }
  else if (fType==B_MODAL_WINDOW){
  }
  created = true;

}
Exemple #16
0
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;
}
Exemple #17
0
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;
}