Beispiel #1
0
DFBResult
dfb_layer_region_set_surface( CoreLayerRegion *region,
                              CoreSurface     *surface )
{
     DFBResult ret;

     D_ASSERT( region != NULL );
     D_ASSERT( surface != NULL );

     /* Lock the region. */
     if (dfb_layer_region_lock( region ))
          return DFB_FUSION;

     if (region->surface != surface) {
          /* Setup hardware for the new surface if the region is realized. */
          if (D_FLAGS_IS_SET( region->state, CLRSF_REALIZED )) {
               ret = set_region( region, &region->config, CLRCF_SURFACE | CLRCF_PALETTE, surface );
               if (ret) {
                    dfb_layer_region_unlock( region );
                    return ret;
               }
          }

          /* Throw away the old surface. */
          if (region->surface) {
               /* Detach the global listener. */
               dfb_surface_detach_global( region->surface,
                                          &region->surface_reaction );

               /* Unlink surface from structure. */
               dfb_surface_unlink( &region->surface );
          }

          /* Take the new surface. */
          if (surface) {
               /* Link surface into structure. */
               if (dfb_surface_link( &region->surface, surface )) {
                    D_WARN( "region lost it's surface" );
                    dfb_layer_region_unlock( region );
                    return DFB_FUSION;
               }

               /* Attach the global listener. */
               dfb_surface_attach_global( region->surface,
                                          DFB_LAYER_REGION_SURFACE_LISTENER,
                                          region, &region->surface_reaction );
          }
     }

     /* Unlock the region. */
     dfb_layer_region_unlock( region );

     return DFB_OK;
}
Beispiel #2
0
DFBResult
dfb_surface_client_create( CoreDFB            *core,
                           CoreSurface        *surface,
                           CoreSurfaceClient **ret_client )
{
     DFBResult          ret;
     CoreSurfaceClient *client;

     CORE_SURFACE_ASSERT( surface );
     D_ASSERT( ret_client != NULL );

     D_DEBUG_AT( Core_SurfClient, "%s( %p %dx%d %s )\n", __FUNCTION__, surface, surface->config.size.w,
                 surface->config.size.h, dfb_pixelformat_name( surface->config.format ) );

     client = dfb_core_create_surface_client( core );
     if (!client)
          return DFB_FUSION;

     ret = dfb_surface_link( &client->surface, surface );
     if (ret) {
          fusion_object_destroy( &client->object );
          return ret;
     }

     D_MAGIC_SET( client, CoreSurfaceClient );

     *ret_client = client;


     CoreSurfaceClient_Init_Dispatch( core, client, &client->call );


     dfb_surface_lock( surface );

     client->flip_count = surface->flips;

     fusion_vector_add( &surface->clients, client );

     dfb_surface_unlock( surface );

     fusion_object_activate( &client->object );

     return DFB_OK;
}
Beispiel #3
0
DFBResult
dfb_window_create( CoreWindowStack        *stack,
                   int                     x,
                   int                     y,
                   int                     width,
                   int                     height,
                   DFBWindowCapabilities   caps,
                   DFBSurfaceCapabilities  surface_caps,
                   DFBSurfacePixelFormat   pixelformat,
                   CoreWindow            **window )
{
     DFBResult               ret;
     CoreSurface            *surface;
     CoreSurfacePolicy       surface_policy;
     CoreWindow             *w;
     DisplayLayer           *layer = dfb_layer_at( stack->layer_id );
     CoreSurface            *layer_surface = dfb_layer_surface( layer );

     surface_caps &= DSCAPS_INTERLACED | DSCAPS_SEPERATED |
                     DSCAPS_STATIC_ALLOC | DSCAPS_SYSTEMONLY | DSCAPS_VIDEOONLY;

     if (caps & DWCAPS_ALPHACHANNEL) {
          if (pixelformat == DSPF_UNKNOWN)
               pixelformat = DSPF_ARGB;
          else if (! DFB_PIXELFORMAT_HAS_ALPHA(pixelformat))
               return DFB_INVARG;

          surface_policy = stack->wsp_alpha;
     }
     else {
          surface_policy = stack->wsp_opaque;

          if (pixelformat == DSPF_UNKNOWN)
               pixelformat = layer_surface->format;
     }

     if (surface_caps & DSCAPS_VIDEOONLY)
          surface_policy = CSP_VIDEOONLY;
     else if (surface_caps & DSCAPS_SYSTEMONLY)
          surface_policy = CSP_SYSTEMONLY;
     else if (layer_surface->back_buffer->policy == CSP_SYSTEMONLY)
          surface_policy = CSP_SYSTEMONLY;

     if (caps & DWCAPS_DOUBLEBUFFER)
          surface_caps |= DSCAPS_FLIPPING;

     /* Create the window object. */
     w = (CoreWindow*) fusion_object_create( stack->pool );

     /* Create the window's surface using the layer's palette. */
     if (! (caps & DWCAPS_INPUTONLY)) {
          ret = dfb_surface_create( width, height, pixelformat, surface_policy,
                                    surface_caps, layer_surface->palette,
                                    &surface );
          if (ret) {
               fusion_object_destroy( &w->object );
               return ret;
          }

          dfb_surface_link( &w->surface, surface );
          dfb_surface_unref( surface );
     }

     w->id      = new_window_id( stack );

     w->x       = x;
     w->y       = y;
     w->width   = width;
     w->height  = height;

     w->caps    = caps;
     w->opacity = 0;

     if (caps & DWCAPS_ALPHACHANNEL)
          w->options = DWOP_ALPHACHANNEL;

     w->stack   = stack;

     w->events  = DWET_ALL;

     *window = w;

     return DFB_OK;;
}