コード例 #1
0
ファイル: surface.c プロジェクト: ysei/uclinux-2
DFBResult
dfb_surface_create_simple ( CoreDFB                 *core,
                            int                      width,
                            int                      height,
                            DFBSurfacePixelFormat    format,
                            DFBSurfaceCapabilities   caps,
                            CoreSurfaceTypeFlags     type,
                            unsigned long            resource_id,
                            CorePalette             *palette,
                            CoreSurface            **ret_surface )
{
     CoreSurfaceConfig config;

     D_DEBUG_AT( Core_Surface, "%s( %p, %dx%d %s, %p )\n", __FUNCTION__, core, width, height,
                 dfb_pixelformat_name( format ), ret_surface );

     D_ASSERT( core != NULL );
     D_ASSERT( ret_surface != NULL );

     config.flags  = CSCONF_SIZE | CSCONF_FORMAT | CSCONF_CAPS;
     config.size.w = width;
     config.size.h = height;
     config.format = format;
     config.caps   = caps;

     return dfb_surface_create( core, &config, type, resource_id, palette, ret_surface );
}
コード例 #2
0
DFBResult
ICore_Real::CreateSurface( const CoreSurfaceConfig  *config,
                           CoreSurfaceTypeFlags      type,
                           u64                       resource_id,
                           CorePalette              *palette,
                           CoreSurface             **ret_surface )
{
     DFBResult    ret;
     CoreSurface *surface;

     D_DEBUG_AT( DirectFB_CoreDFB, "ICore_Real::%s( %p )\n", __FUNCTION__, core );

     D_MAGIC_ASSERT( obj, CoreDFB );
     D_ASSERT( config != NULL );
     D_ASSERT( ret_surface != NULL );

     ret = Core_Resource_CheckSurface( config, type, resource_id, palette );
     if (ret)
          return ret;

     ret = dfb_surface_create( obj, config, type, resource_id, palette, &surface );
     if (ret)
          return ret;

     Core_Resource_AddSurface( surface );

     *ret_surface = surface;

     return DFB_OK;
}
コード例 #3
0
static DFBResult
primaryAllocateSurface( CoreLayer              *layer,
                        void                   *driver_data,
                        void                   *layer_data,
                        void                   *region_data,
                        CoreLayerRegionConfig  *config,
                        CoreSurface           **ret_surface )
{
     CoreSurfaceConfig conf;

     conf.flags  = CSCONF_SIZE | CSCONF_FORMAT | CSCONF_CAPS;
     conf.size.w = config->width;
     conf.size.h = config->height;
     conf.format = config->format;
     conf.caps   = DSCAPS_SYSTEMONLY;

     if (config->buffermode != DLBM_FRONTONLY)
          conf.caps |= DSCAPS_DOUBLE;

     return dfb_surface_create( dfb_rtd_core, &conf, CSTF_LAYER, DLID_PRIMARY, NULL, ret_surface );
}
コード例 #4
0
ファイル: primary.c プロジェクト: kuii/dfbNEON
static DFBResult
primaryInitScreen( CoreScreen           *screen,
                   CoreGraphicsDevice   *device,
                   void                 *driver_data,
                   void                 *screen_data,
                   DFBScreenDescription *description )
{
     DFBX11       *x11    = driver_data;
     DFBX11Shared *shared = x11->shared;
     void         *old_error_handler = 0;

     D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ );

     /* Set the screen capabilities. */
     description->caps    = DSCCAPS_OUTPUTS;
     description->outputs = 1;

     /* Set the screen name. */
     snprintf( description->name, DFB_SCREEN_DESC_NAME_LENGTH, "X11/VDPAU Primary Screen" );


     shared->depth = DefaultDepthOfScreen( x11->screenptr );



     XSetWindowAttributes attr = { .background_pixmap = 0 };

     attr.event_mask =
            ButtonPressMask
          | ButtonReleaseMask
          | PointerMotionMask
          | KeyPressMask
          | KeyReleaseMask
          | ExposureMask
          | StructureNotifyMask;

     XLockDisplay( x11->display );

     old_error_handler = XSetErrorHandler( error_handler );

     error_code = 0;

     shared->window = XCreateWindow( x11->display,
                                     RootWindowOfScreen(x11->screenptr),
                                     0, 0, shared->screen_size.w, shared->screen_size.h, 0, shared->depth, InputOutput,
                                     DefaultVisualOfScreen(x11->screenptr), CWEventMask, &attr );
     XSync( x11->display, False );

     if (!shared->window || error_code) {
          D_ERROR( "DirectFB/X11/VDPAU: XCreateWindow() failed!\n" );
          XUnlockDisplay( x11->display );
          return DFB_FAILURE;
     }

     XSelectInput( x11->display, shared->window,
                   ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
                   KeyPressMask | KeyReleaseMask | StructureNotifyMask );


     XSizeHints Hints;

     /*
      * Here we inform the function of what we are going to change for the
      * window (there's also PPosition but it's obsolete)
      */
     Hints.flags = PSize | PMinSize | PMaxSize;

     /*
      * Now we set the structure to the values we need for width & height.
      * For esthetic reasons we set Width=MinWidth=MaxWidth.
      * The same goes for Height. You can try whith differents values, or
      * let's use Hints.flags=Psize; and resize your window..
      */
     Hints.min_width  = Hints.max_width  = Hints.base_width  = shared->screen_size.w;
     Hints.min_height = Hints.max_height = Hints.base_height = shared->screen_size.h;

     /* Now we can set the size hints for the specified window */
     XSetWMNormalHints( x11->display, shared->window, &Hints );

     /* We change the title of the window (default:Untitled) */
     XStoreName( x11->display, shared->window, "DirectFB/VDPAU" );


     /* maps the window and raises it to the top of the stack */
     XMapRaised( x11->display, shared->window );


     XSetErrorHandler( old_error_handler );


     VdpStatus status;

     status = x11->vdp.PresentationQueueTargetCreateX11( x11->vdp.device, shared->window, &shared->vdp_target );
     if (status) {
          D_ERROR( "DirectFB/X11/VDPAU: PresentationQueueTargetCreateX11() failed (status %d, '%s')!\n",
                   status, x11->vdp.GetErrorString( status ) );
          XUnlockDisplay( x11->display );
          return DFB_FAILURE;
     }

     status = x11->vdp.PresentationQueueCreate( x11->vdp.device, shared->vdp_target, &shared->vdp_queue );
     if (status) {
          D_ERROR( "DirectFB/X11/VDPAU: PresentationQueueCreate() failed (status %d, '%s')!\n",
                   status, x11->vdp.GetErrorString( status ) );
          XUnlockDisplay( x11->display );
          return DFB_FAILURE;
     }



     status = x11->vdp.OutputSurfaceCreate( x11->vdp.device, VDP_RGBA_FORMAT_B8G8R8A8,
                                            shared->screen_size.w, shared->screen_size.h, &shared->vdp_surface );
     if (status) {
          D_ERROR( "DirectFB/X11/VDPAU: OutputSurfaceCreate( RGBA %dx%d ) failed (status %d, '%s')!\n",
                   shared->screen_size.w, shared->screen_size.h, status, x11->vdp.GetErrorString( status ) );
          XUnlockDisplay( x11->display );
          return DFB_FAILURE;
     }


     DFBResult          ret;
     CoreSurfaceConfig  config;

     config.flags  = CSCONF_SIZE | CSCONF_FORMAT | CSCONF_CAPS | CSCONF_PREALLOCATED;
     config.size.w = shared->screen_size.w;
     config.size.h = shared->screen_size.h;
     config.format = DSPF_ARGB;
     config.caps   = DSCAPS_VIDEOONLY;
     config.preallocated[0].addr   = NULL;
     config.preallocated[0].handle = shared->vdp_surface;
     config.preallocated[0].pitch  = shared->screen_size.w * 4;

     ret = dfb_surface_create( x11->core, &config, CSTF_EXTERNAL | CSTF_PREALLOCATED,
                               shared->vdp_surface, NULL, &shared->vdp_core_surface );
     if (ret) {
          D_DERROR( ret, "DirectFB/Xine/VDPAU: Could not create preallocated output surface!\n" );
          XUnlockDisplay( x11->display );
          return ret;
     }


     XUnlockDisplay( x11->display );

     return DFB_OK;
}

static DFBResult
primaryShutdownScreen( CoreScreen *screen,
                       void       *driver_data,
                       void       *screen_data )
{
     DFBX11       *x11    = driver_data;
     DFBX11Shared *shared = x11->shared;

     VdpStatus status;

     status = x11->vdp.PresentationQueueDestroy( shared->vdp_queue );
     if (status)
          D_ERROR( "DirectFB/X11/VDPAU: PresentationQueueDestroy() failed (status %d, '%s')!\n",
                   status, x11->vdp.GetErrorString( status ) );

     status = x11->vdp.PresentationQueueTargetDestroy( shared->vdp_target );
     if (status)
          D_ERROR( "DirectFB/X11/VDPAU: PresentationQueueTargetDestroy() failed (status %d, '%s')!\n",
                   status, x11->vdp.GetErrorString( status ) );

     XDestroyWindow( x11->display, shared->window );

     return DFB_OK;
}
コード例 #5
0
ファイル: windows.c プロジェクト: Claruarius/stblinux-2.6.37
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;;
}
コード例 #6
0
ファイル: fonts.c プロジェクト: Kvasshtain/uos-embedded
DFBResult
dfb_font_get_glyph_data( CoreFont        *font,
                         unichar          glyph,
                         CoreGlyphData  **ret_data )
{
     DFBResult      ret;
     CoreGlyphData *data;

     D_MAGIC_ASSERT( font, CoreFont );

     D_ASSERT( ret_data != NULL );

     if ((data = direct_tree_lookup (font->glyph_infos, (void *)glyph)) != NULL) {
          *ret_data = data;
          return DFB_OK;
     }

     data = (CoreGlyphData *) D_CALLOC(1, sizeof (CoreGlyphData));
     if (!data)
          return DFB_NOSYSTEMMEMORY;

     if (font->GetGlyphInfo &&
         font->GetGlyphInfo (font, glyph, data) == DFB_OK &&
         data->width > 0 && data->height > 0)
     {
          if (font->next_x + data->width > font->row_width) {
               CoreSurface *surface;

               if (font->row_width == 0) {
                    int width = 8192 / font->height;

                    if (width > 2048)
                         width = 2048;

                    if (width < font->maxadvance)
                         width = font->maxadvance;

                    font->row_width = (width + 7) & ~7;
               }

               ret = dfb_surface_create( font->core,
                                         font->row_width,
                                         MAX( font->height + 1, 8 ),
                                         font->pixel_format,
                                         CSP_VIDEOLOW, DSCAPS_NONE, NULL,
                                         &surface );
               if (ret) {
                    D_ERROR( "DirectFB/core/fonts: "
                              "Could not create glyph surface! (%s)\n",
                              DirectFBErrorString( ret ) );

                    D_FREE( data );
                    return ret;
               }

               font->next_x = 0;
               font->rows++;

               font->surfaces = D_REALLOC( font->surfaces, sizeof(void *) * font->rows );

               font->surfaces[font->rows - 1] = surface;
          }

          if (font->RenderGlyph(font, glyph, data,
                                font->surfaces[font->rows - 1]) == DFB_OK)
          {
               int align = DFB_PIXELFORMAT_ALIGNMENT(font->pixel_format);

               data->surface = font->surfaces[font->rows - 1];
               data->start   = font->next_x;
               font->next_x += (data->width + align) & ~align;

               dfb_gfxcard_flush_texture_cache();
          }
          else {
               data->start = data->width = data->height = 0;
          }
     }
     else {
          data->start = data->width = data->height = 0;
     }

     direct_tree_insert (font->glyph_infos, (void *) glyph, data);

     *ret_data = data;

     return DFB_OK;
}