Beispiel #1
0
void
GP2DEngine::validate_SOURCE( GP2DTask  *mytask,
                             CardState *state )
{
    __u32 *prep = mytask->start( 6 );

    CoreSurfaceBuffer *buffer = state->src.buffer;

    mytask->src_phys  = (unsigned long) state->src.handle;
    mytask->src_pitch = state->src.pitch;
    mytask->src_bpp   = DFB_BYTES_PER_PIXEL( buffer->format );
    mytask->src_index = DFB_PIXELFORMAT_INDEX( buffer->format ) % DFB_NUM_PIXELFORMATS;

    /* Set source start address. */
    prep[0] = GP2D_OPCODE_WPR;
    prep[1] = 0x4c;
    prep[2] = mytask->src_phys;

    /* Set source stride. */
    prep[3] = GP2D_OPCODE_WPR;
    prep[4] = 0x58;
    prep[5] = mytask->src_pitch / mytask->src_bpp;

    mytask->submit( 6 );

    /* Set the flags. */
    GP2D_VALIDATE( SOURCE );
}
Beispiel #2
0
static inline void
pxa3xx_validate_DEST( PXA3XXDriverData *pdrv,
                      PXA3XXDeviceData *pdev,
                      CardState        *state )
{
     CoreSurfaceBuffer *buffer = state->dst.buffer;
     u32               *prep   = start_buffer( pdrv, 6 );

     D_DEBUG_AT( PXA3XX_BLT, "%s( 0x%08lx [%d] )\n", __FUNCTION__,
                 state->dst.phys, state->dst.pitch );

     pdev->dst_phys  = state->dst.phys;
     pdev->dst_pitch = state->dst.pitch;
     pdev->dst_bpp   = DFB_BYTES_PER_PIXEL( buffer->format );
     pdev->dst_index = DFB_PIXELFORMAT_INDEX( buffer->format ) % DFB_NUM_PIXELFORMATS;

     /* Set destination. */
     prep[0] = 0x020000A2;
     prep[1] = pdev->dst_phys;
     prep[2] = (pixel_formats[pdev->dst_index] << 19) | (pdev->dst_pitch << 5) | pdev->dst_bpp;

     prep[3] = 0x02000012;
     prep[4] = prep[1];
     prep[5] = prep[2];

     submit_buffer( pdrv, 6 );

     /* Set the flags. */
     PXA3XX_VALIDATE( DEST );
}
Beispiel #3
0
/*
 * Render a blended rectangle using the current hardware state.
 *
 * As the hardware does not directly support this, we blit a single
 * pixel with blending.
 */
static bool
pxa3xxFillRectangleBlend( void *drv, void *dev, DFBRectangle *rect )
{
     PXA3XXDriverData *pdrv   = drv;
     PXA3XXDeviceData *pdev   = dev;
     u32              *prep   = start_buffer( pdrv, 22 );
     const u32         format = pixel_formats[DFB_PIXELFORMAT_INDEX( DSPF_ARGB )];

     D_DEBUG_AT( PXA3XX_BLT, "%s( %d, %d - %dx%d )\n", __FUNCTION__,
                 DFB_RECTANGLE_VALS( rect ) );
     DUMP_INFO();

     /* Set fake destination. */
     prep[0]  = 0x020000A2;
     prep[1]  = pdev->fake_phys;
     prep[2]  = (format << 19) | 4;

     /* Fill rectangle. */
     prep[3]  = 0x40000014 | (format << 8);
     prep[4]  = 0;
     prep[5]  = 0;
     prep[6]  = PXA3XX_WH( rect->w, 1 );
     prep[7]  = PIXEL_ARGB( pdev->color.a, pdev->color.r, pdev->color.g, pdev->color.b );

     /* Restore destination. */
     prep[8]  = 0x020000A2;
     prep[9]  = pdev->dst_phys;
     prep[10] = (pixel_formats[pdev->dst_index] << 19) | (pdev->dst_pitch << 5) | pdev->dst_bpp;

     /* Set fake buffer as source. */
     prep[11] = 0x02000002;
     prep[12] = pdev->fake_phys;
     prep[13] = (format << 19) | 4;

     /* Blit with blending. */
     prep[14] = 0x47000107;
     prep[15] = rect->x;
     prep[16] = rect->y;
     prep[17] = 0;
     prep[18] = 0;
     prep[19] = rect->x;
     prep[20] = rect->y;
     prep[21] = PXA3XX_WH( rect->w, rect->h );

     submit_buffer( pdrv, 22 );

     /* Clear the flag. */
     PXA3XX_INVALIDATE( SOURCE );

     return true;
}
Beispiel #4
0
Datei: tdfx.c Projekt: uiv/Lerdu
static inline void tdfx_validate_source2D( TDFXDriverData *tdrv,
        TDFXDeviceData *tdev,
        CardState      *state )
{
    CoreSurface   *source   = state->source;
    Voodoo2D      *voodoo2D = tdrv->voodoo2D;

    if (tdev->v_source2D)
        return;

    tdfx_waitfifo( tdrv, tdev, 2 );

    voodoo2D->srcBaseAddr = state->src.offset & 0xFFFFFF;
    voodoo2D->srcFormat   = (state->src.pitch & 0x3FFF) |
                            (blitFormat[DFB_PIXELFORMAT_INDEX(source->config.format)] << 16);

    tdev->v_source2D = 1;
}
Beispiel #5
0
Datei: tdfx.c Projekt: uiv/Lerdu
static inline void tdfx_validate_destination2D( TDFXDriverData *tdrv,
        TDFXDeviceData *tdev,
        CardState      *state )
{
    CoreSurface   *destination = state->destination;
    Voodoo2D      *voodoo2D    = tdrv->voodoo2D;

    if (tdev->v_destination2D)
        return;

    tdfx_waitfifo( tdrv, tdev, 2 );

    voodoo2D->dstBaseAddr = state->dst.offset;
    voodoo2D->dstFormat   = (state->dst.pitch & 0x3FFF) |
                            (blitFormat[DFB_PIXELFORMAT_INDEX(destination->config.format)] << 16);

    tdev->v_destination2D = 1;
}
static DFBResult
x11TestConfig( CoreSurfacePool         *pool,
               void                    *pool_data,
               void                    *pool_local,
               CoreSurfaceBuffer       *buffer,
               const CoreSurfaceConfig *config )
{
     x11PoolLocalData *local = pool_local;
     DFBX11           *x11   = local->x11;

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

     if (!x11->visuals[DFB_PIXELFORMAT_INDEX(config->format)]) {
          D_DEBUG_AT( X11_Surfaces, "  -> NO VISUAL for %s\n", dfb_pixelformat_name(config->format) );
          return DFB_UNSUPPORTED;
     }

     return DFB_OK;
}
Beispiel #7
0
DFBResult x11ImageInit( DFBX11                *x11,
                        x11Image              *image,
                        int                    width,
                        int                    height,
                        DFBSurfacePixelFormat  format )
{
     int           ret;
     Visual       *visual;
     DFBX11Shared *shared = x11->shared;

     if (!x11->use_shm)
          return DFB_UNSUPPORTED;

     /* Lookup visual. */
     visual = x11->visuals[DFB_PIXELFORMAT_INDEX(format)];
     if (!visual)
          return DFB_UNSUPPORTED;

     /* For probing. */
     if (!image)
          return DFB_OK;

     image->width  = width;
     image->height = height;
     image->format = format;
     image->depth  = DFB_COLOR_BITS_PER_PIXEL( format );

     D_MAGIC_SET( image, x11Image );

     if (fusion_call_execute( &shared->call, FCEF_NONE, X11_IMAGE_INIT, image, &ret )) {
          D_MAGIC_CLEAR( image );
          return DFB_FUSION;
     }

     if (ret) {
          D_DERROR( ret, "X11/Image: X11_IMAGE_INIT call failed!\n" );
          D_MAGIC_CLEAR( image );
          return ret;
     }

     return DFB_OK;
}
Beispiel #8
0
static inline void
pxa3xx_validate_SOURCE( PXA3XXDriverData *pdrv,
                        PXA3XXDeviceData *pdev,
                        CardState        *state )
{
     CoreSurfaceBuffer *buffer = state->src.buffer;
     u32               *prep   = start_buffer( pdrv, 3 );

     pdev->src_phys  = state->src.phys;
     pdev->src_pitch = state->src.pitch;
     pdev->src_bpp   = DFB_BYTES_PER_PIXEL( buffer->format );
     pdev->src_index = DFB_PIXELFORMAT_INDEX( buffer->format ) % DFB_NUM_PIXELFORMATS;
     pdev->src_alpha = DFB_PIXELFORMAT_HAS_ALPHA( buffer->format );

     /* Set source. */
     prep[0] = 0x02000002;
     prep[1] = pdev->src_phys;
     prep[2] = (pixel_formats[pdev->src_index] << 19) | (pdev->src_pitch << 5) | pdev->src_bpp;

     submit_buffer( pdrv, 3 );

     /* Set the flag. */
     PXA3XX_VALIDATE( SOURCE );
}
Beispiel #9
0
void
pxa3xxCheckState( void                *drv,
                  void                *dev,
                  CardState           *state,
                  DFBAccelerationMask  accel )
{
     D_DEBUG_AT( PXA3XX_BLT, "%s( %p, 0x%08x )\n", __FUNCTION__, state, accel );

     /* Return if the desired function is not supported at all. */
     if (accel & ~(PXA3XX_SUPPORTED_DRAWINGFUNCTIONS | PXA3XX_SUPPORTED_BLITTINGFUNCTIONS))
          return;

     /* Return if the destination format is not supported. */
     if (!pixel_formats[DFB_PIXELFORMAT_INDEX(state->destination->config.format)])
          return;

     /* Check if drawing or blitting is requested. */
     if (DFB_DRAWING_FUNCTION( accel )) {
          /* Return if unsupported drawing flags are set. */
          if (state->drawingflags & ~PXA3XX_SUPPORTED_DRAWINGFLAGS)
               return;

          /* Return if blending with unsupported blend functions is requested. */
          if (state->drawingflags & DSDRAW_BLEND) {
               /* Check blend functions. */
               if (!check_blend_functions( state ))
                    return;
          }

          /* Enable acceleration of drawing functions. */
          state->accel |= PXA3XX_SUPPORTED_DRAWINGFUNCTIONS;
     }
     else {
          const DFBSurfaceBlittingFlags flags = state->blittingflags;

          /* Return if unsupported blitting flags are set. */
          if (flags & ~PXA3XX_SUPPORTED_BLITTINGFLAGS)
               return;

          /* Return if the source format is not supported. */
          if (!pixel_formats[DFB_PIXELFORMAT_INDEX(state->source->config.format)])
               return;

          /* Return if blending with unsupported blend functions is requested. */
          if (flags & (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA)) {
               if (DFB_PIXELFORMAT_HAS_ALPHA( state->destination->config.format ))
                    return;

               /* Rotated blits are not supported with blending. */
               if (flags & ~(DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA | DSBLIT_COLORIZE))
                    return;

               /* Blending with alpha from color value is not supported
                * in combination with other blending functions.
                */
               if (flags & DSBLIT_BLEND_COLORALPHA &&
                   flags != DSBLIT_BLEND_COLORALPHA)
                 return;

               /* Check blend functions. */
               if (!check_blend_functions( state ))
                    return;
          }

          /* Colorizing is only supported for rendering ARGB glyphs. */
          if (flags & DSBLIT_COLORIZE &&
              (flags != (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE) || ! (state->source->type & CSTF_FONT)))
               return;

          /* Enable acceleration of blitting functions. */
          state->accel |= PXA3XX_SUPPORTED_BLITTINGFUNCTIONS;
     }
}
Beispiel #10
0
static void
set_configuration( void )
{
     DFBResult             ret;
     DFBDisplayLayerConfig config;

     printf( "\n" );
     printf( "%s\n", desc.name );
     printf( "\n" );

     config.flags = DLCONF_NONE;

     if (width) {
          config.flags |= DLCONF_WIDTH;
          config.width  = width;
     }

     if (height) {
          config.flags  |= DLCONF_HEIGHT;
          config.height  = height;
     }

     if (format != DSPF_UNKNOWN) {
          config.flags       |= DLCONF_PIXELFORMAT;
          config.pixelformat  = format;
     }

     if (buffermode != -1) {
          config.flags      |= DLCONF_BUFFERMODE;
          config.buffermode  = buffermode;
     }

     /* Set the configuration if anything changed. */
     if (config.flags) {
          ret = layer->TestConfiguration( layer, &config, NULL );
          if (ret) {
               DirectFBError( "IDirectFBDisplayLayer::TestConfiguration() failed", ret );
               return;
          }

          ret = layer->SetConfiguration( layer, &config );
          if (ret) {
               DirectFBError( "IDirectFBDisplayLayer::SetConfiguration() failed", ret );
               return;
          }
     }

     /* Get and show the current (new) configuration. */
     ret = layer->GetConfiguration( layer, &config );
     if (ret) {
          DirectFBError( "IDirectFBDisplayLayer::GetConfiguration() failed", ret );
          return;
     }

     /* Set the opacity if requested. */
     if (opacity != -1) {
          ret = layer->SetOpacity( layer, opacity );
          if (ret == DFB_UNSUPPORTED)
               fprintf( stderr, "Opacity value (%d) not supported!\n\n", opacity );
          else if (ret)
               DirectFBError( "IDirectFBDisplayLayer::SetOpacity() failed", ret );
     }

     /* Set the level if requested. */
     if (set_level) {
          ret = layer->SetLevel( layer, level );
          if (ret == DFB_UNSUPPORTED)
               fprintf( stderr, "Level (%d) not supported!\n\n", level );
          else if (ret)
               DirectFBError( "IDirectFBDisplayLayer::SetLevel() failed", ret );
     }

     /* Set the rotation if requested. */
     if (set_rotation) {
          ret = layer->SetRotation( layer, rotation );
          if (ret == DFB_UNSUPPORTED)
               fprintf( stderr, "Rotation (%d) not supported!\n\n", level );
          else if (ret)
               DirectFBError( "IDirectFBDisplayLayer::SetRotation() failed", ret );
     }


     if (config.flags & DLCONF_WIDTH)
          printf( "Width       %d\n", config.width );

     if (config.flags & DLCONF_HEIGHT)
          printf( "Height      %d\n", config.height );

     if (config.flags & DLCONF_PIXELFORMAT)
          printf( "Format      %s\n",
                  format_names[DFB_PIXELFORMAT_INDEX(config.pixelformat)].name );

     if (config.flags & DLCONF_BUFFERMODE) {
          printf( "Buffermode  " );

          switch (config.buffermode) {
               case DLBM_FRONTONLY:
                    printf( "FRONTONLY\n" );
                    break;
               case DLBM_BACKVIDEO:
                    printf( "BACKVIDEO\n" );
                    break;
               case DLBM_BACKSYSTEM:
                    printf( "BACKSYSTEM\n" );
                    break;
               case DLBM_TRIPLE:
                    printf( "TRIPLE\n" );
                    break;
               case DLBM_WINDOWS:
                    printf( "WINDOWS\n" );
                    break;
               default:
                    printf( "unknown!\n" );
                    break;
          }
     }

     if (config.flags & DLCONF_OPTIONS) {
          printf( "Options     " );

          if (config.options == DLOP_NONE) {
               printf( "none\n" );
          }
          else {
               if (config.options & DLOP_ALPHACHANNEL)
                    printf( "ALPHA CHANNEL       " );

               if (config.options & DLOP_DEINTERLACING)
                    printf( "DEINTERLACING       " );

               if (config.options & DLOP_DST_COLORKEY)
                    printf( "DST COLOR KEY       " );

               if (config.options & DLOP_FIELD_PARITY)
                    printf( "FIELD PARITY        " );

               if (config.options & DLOP_FLICKER_FILTERING)
                    printf( "FLICKER FILTERING   " );

               if (config.options & DLOP_OPACITY)
                    printf( "OPACITY             " );

               if (config.options & DLOP_SRC_COLORKEY)
                    printf( "SRC COLOR KEY       " );

               printf( "\n" );
          }
     }

     /* Query current level. */
     if (desc.caps & DLCAPS_LEVELS) {
          int l;

          ret = layer->GetLevel( layer, &l );
          if (ret)
               DirectFBError( "IDirectFBDisplayLayer::GetLevel() failed", ret );
          else
               printf( "Level       %d\n", l );
     }

     printf( "\n" );
}
Beispiel #11
0
static DFBResult
Inspector_Run( Inspector *inspector )
{
     static const DFBSurfacePixelFormat formats[] = {
          DSPF_LUT8,
          DSPF_ALUT44,
          DSPF_RGB332,
          DSPF_RGB16,
          DSPF_RGB24,
          DSPF_RGB32,
          DSPF_ARGB1555,
          DSPF_RGBA5551,
          DSPF_ARGB2554,
          DSPF_ARGB4444,
          DSPF_ARGB8565,
          DSPF_ARGB,
          DSPF_AiRGB,
          DSPF_A1,
          DSPF_A1_LSB,
          DSPF_A8,
          DSPF_YUY2,
          DSPF_UYVY,
          DSPF_I420,
          DSPF_YV12,
          DSPF_YV16,
          DSPF_NV12,
          DSPF_NV21,
          DSPF_NV16,
          DSPF_AYUV,
          DSPF_YUV444P,
          DSPF_AVYU,
          DSPF_VYU,
     };

     int                    i, j, n;
     DFBResult              ret;
     DFBSurfaceDescription  desc;
     IDirectFBSurface      *surfaces[D_ARRAY_SIZE(formats)];
     char                   buf[strlen( inspector->directory ? : "" ) + 23];


     if (inspector->options & CREATE_FILES) {
          /* Create the directory. */
          if (mkdir( inspector->directory, 0755 ) < 0 && errno != EEXIST) {
               D_PERROR( "Inspector/Init: Could not create directory '%s'!\n", inspector->directory );
               return DFB_INIT;
          }

          /* Open file for writing supported format conversions (blitting). */
          snprintf( buf, sizeof(buf), "%s/blit.formats", inspector->directory );
          inspector->files.formats = fopen( buf, "w" );
          if (!inspector->files.formats) {
               D_PERROR( "Inspector/Init: Could not open file '%s' for writing!\n", buf );
               return DFB_INIT;
          }
     }

     desc.flags  = (DFBSurfaceDescriptionFlags)(DSDESC_WIDTH  |
                                                DSDESC_HEIGHT |
                                                DSDESC_PIXELFORMAT);
     desc.width  = 64;
     desc.height = 64;

     for (i=0; i<D_ARRAY_SIZE(formats); i++) {
          desc.pixelformat = formats[i];

          ret = inspector->dfb->CreateSurface( inspector->dfb, &desc, &surfaces[i] );
          if (ret) {
               D_DERROR( ret, "Inspector/Init: Could not create %s surface!\n",
                         format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
               while (i--)
                    surfaces[i]->Release( surfaces[i] );
               return ret;
          }

          surfaces[i]->SetFont( surfaces[i], inspector->font );

          if (inspector->files.formats)
               fprintf( inspector->files.formats, "%s%s", i ? "," : "",
                        format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
     }

     if (inspector->files.formats)
          fprintf( inspector->files.formats, "\n" );

     printf("\n");



     printf("source ->");

     for (i=0; i<D_ARRAY_SIZE(formats); i++)
          printf( "%9s", format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );

     printf("\n");



     printf("dest.\n");

     for (i=0; i<D_ARRAY_SIZE(formats); i++) {
          printf( "%9s", format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );

          for (j=0; j<D_ARRAY_SIZE(formats); j++) {
               DFBAccelerationMask mask;

               surfaces[i]->GetAccelerationMask( surfaces[i], surfaces[j], &mask );

               if (mask & DFXL_DRAWSTRING)
                    inspector->device_drawstring = true;

               printf( "%9s", (mask & DFXL_BLIT) ? "X" : "" );

               if (inspector->files.formats)
                    fputc( (mask & DFXL_BLIT) ? '1' : '0', inspector->files.formats );
          }

          printf( "  %s", format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );

          printf("\n");

          if (inspector->files.formats)
               fprintf( inspector->files.formats, "\n" );
     }

     for (i=0; i<D_ARRAY_SIZE(formats); i++)
          surfaces[i]->Release( surfaces[i] );

     if (inspector->options & CREATE_FILES) {
          FILE                         *f;
          DFBGraphicsDeviceDescription  desc;

          if (inspector->files.formats)
               fclose( inspector->files.formats );

          /* Query device and driver information. */
          inspector->dfb->GetDeviceDescription( inspector->dfb, &desc );

          if (inspector->device_drawstring)
               desc.acceleration_mask = (DFBAccelerationMask)(desc.acceleration_mask | DFXL_DRAWSTRING);

          /* Write device info to a file. */
          snprintf( buf, sizeof(buf), "%s/device.info", inspector->directory );
          f = fopen( buf, "w" );
          if (!f) {
               D_PERROR( "Inspector/Init: Could not open file '%s' for writing!\n", buf );
               return DFB_FAILURE;
          }

          fprintf( f, "name = %s\n", desc.name );
          fprintf( f, "vendor = %s\n", desc.vendor );

          fprintf( f, "acceleration_mask = " );
          for (i=0, n=0; accelerationmask_names[i].mask; i++) {
               if (desc.acceleration_mask & accelerationmask_names[i].mask)
                    fprintf( f, "%s%s", n++ ? "," : "", accelerationmask_names[i].name );
          }
          fprintf( f, "\n" );

          fprintf( f, "blitting_flags = " );
          for (i=0, n=0; blittingflags_names[i].flag; i++) {
               if (desc.blitting_flags & blittingflags_names[i].flag)
                    fprintf( f, "%s%s", n++ ? "," : "", blittingflags_names[i].name );
          }
          fprintf( f, "\n" );

          fprintf( f, "drawing_flags = " );
          for (i=0, n=0; drawingflags_names[i].flag; i++) {
               if (desc.drawing_flags & drawingflags_names[i].flag)
                    fprintf( f, "%s%s", n++ ? "," : "", drawingflags_names[i].name );
          }
          fprintf( f, "\n" );

          fclose( f );


          /* Write driver info to a file. */
          snprintf( buf, sizeof(buf), "%s/driver.info", inspector->directory );
          f = fopen( buf, "w" );
          if (!f) {
               D_PERROR( "Inspector/Init: Could not open file '%s' for writing!\n", buf );
               return DFB_FAILURE;
          }

          fprintf( f, "name = %s\n", desc.driver.name );
          fprintf( f, "vendor = %s\n", desc.driver.vendor );
          fprintf( f, "version = %d.%d\n", desc.driver.major, desc.driver.minor );

          fclose( f );
     }

     return DFB_OK;
}
Beispiel #12
0
void
GP2DEngine::validate_DEST_CLIP( GP2DTask  *mytask,
                                CardState *state )
{
    __u32 *prep = mytask->start( 18 );

    D_DEBUG_AT( GP2D_Engine, "%s( %p [%d] - %4d,%4d-%4dx%4d )\n", __FUNCTION__,
                state->dst.handle, state->dst.pitch, DFB_RECTANGLE_VALS_FROM_REGION( &state->clip ) );


    prep[0] = GP2D_OPCODE_WPR;
    prep[1] = 0x0d4;
    prep[2] = GP2D_XY( state->clip.x1, state->clip.y1 ) ;

    prep[3] = GP2D_OPCODE_WPR;
    prep[4] = 0x0d8;
    prep[5] = GP2D_XY( state->clip.x2, state->clip.y2) ;

    if (mytask->v_flags & DEST) {
        mytask->submit( 6 );
    }
    else {
        CoreSurface       *surface = state->destination;
        CoreSurfaceBuffer *buffer  = state->dst.buffer;

        mytask->dst_phys  = (unsigned long) state->dst.handle;
        mytask->dst_pitch = state->dst.pitch;
        mytask->dst_bpp   = DFB_BYTES_PER_PIXEL( buffer->format );
        mytask->dst_index = DFB_PIXELFORMAT_INDEX( buffer->format ) % DFB_NUM_PIXELFORMATS;

        mytask->rclr &= ~0x00140000;

        switch (buffer->format) {
        case DSPF_RGB16:
            mytask->rclr |= 0x00040000;
            break;

        case DSPF_ARGB1555:
            mytask->rclr |= 0x00140000;
            break;

        default:
            D_BUG("Unexpected pixelformat\n");
            return;
        }

        /* Set destination start address. */
        prep[ 6] = GP2D_OPCODE_WPR;
        prep[ 7] = 0x50;
        prep[ 8] = mytask->dst_phys;

        /* Set destination stride. */
        prep[ 9] = GP2D_OPCODE_WPR;
        prep[10] = 0x5c;
        prep[11] = mytask->dst_pitch / mytask->dst_bpp;

        /* Set destination pixelformat in rendering control. */
        prep[12] = GP2D_OPCODE_WPR;
        prep[13] = 0xc0;
        prep[14] = mytask->rclr;

        /* Set system clipping rectangle. */
        prep[15] = GP2D_OPCODE_WPR;
        prep[16] = 0xd0;
        prep[17] = GP2D_XY( surface->config.size.w - 1, surface->config.size.h - 1 );

        mytask->submit( 18 );
    }

    /* Set the flags. */
    GP2D_VALIDATE( DEST_CLIP );
}
static bool
stretch_hvx( CardState *state, DFBRectangle *srect, DFBRectangle *drect )
{
     GenefxState                *gfxs;
     const StretchFunctionTable *table;
     StretchHVx                  stretch;
     bool                        down = false;
     void                       *dst;
     void                       *src;
     StretchCtx                  ctx;
     int                         idx = STRETCH_NONE;
     u32                         colors[256];

     D_ASSERT( state != NULL );
     DFB_RECTANGLE_ASSERT( srect );
     DFB_RECTANGLE_ASSERT( drect );

     gfxs = state->gfxs;

     if (srect->w > drect->w && srect->h > drect->h)
          down = true;

     if (down) {
          if (!(state->render_options & DSRO_SMOOTH_DOWNSCALE))
               return false;
     }
     else {
          if (!(state->render_options & DSRO_SMOOTH_UPSCALE))
               return false;
     }

     switch (gfxs->dst_format) {
          case DSPF_NV12:
          case DSPF_NV21:
               return stretch_hvx_planar( state, srect, drect, down );

          default:
               break;
     }

     if (state->blittingflags & ~(DSBLIT_COLORKEY_PROTECT | DSBLIT_SRC_COLORKEY | DSBLIT_SRC_PREMULTIPLY))
          return false;

     if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY && !DFB_PIXELFORMAT_IS_INDEXED( gfxs->src_format ))
          return false;

     if (DFB_PIXELFORMAT_INDEX(gfxs->dst_format) >= D_ARRAY_SIZE(stretch_tables))
          return false;

     if (DFB_PIXELFORMAT_INDEX(gfxs->src_format) >= D_ARRAY_SIZE((stretch_tables[0])->f))
          return false;

     table = stretch_tables[DFB_PIXELFORMAT_INDEX(gfxs->dst_format)];
     if (!table)
          return false;

     if (state->blittingflags & DSBLIT_SRC_COLORKEY)
          idx |= STRETCH_SRCKEY;

     if (state->blittingflags & DSBLIT_COLORKEY_PROTECT)
          idx |= STRETCH_PROTECT;

     if (down)
          stretch = table->f[DFB_PIXELFORMAT_INDEX(gfxs->src_format)].down[idx];
     else
          stretch = table->f[DFB_PIXELFORMAT_INDEX(gfxs->src_format)].up[idx];

     if (!stretch)
          return false;

     ctx.clip = state->clip;

     if (!dfb_region_rectangle_intersect( &ctx.clip, drect ))
          return false;

     dfb_region_translate( &ctx.clip, - drect->x, - drect->y );

     if (DFB_PIXELFORMAT_IS_INDEXED( gfxs->src_format )) {
          int             i;
          const DFBColor *entries;
          u16            *colors16 = (void*) colors;

          D_ASSERT( gfxs->Blut != NULL );

          entries = gfxs->Blut->entries;

          switch (gfxs->dst_format) {
               case DSPF_ARGB:
                    if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) {
                         for (i=0; i<gfxs->Blut->num_entries; i++) {
                              int alpha = entries[i].a + 1;

                              switch (alpha) {
                                   case 0:
                                        colors[i] = 0;
                                        break;

                                   case 255:
                                        colors[i] = PIXEL_ARGB( entries[i].a,
                                                                entries[i].r,
                                                                entries[i].g,
                                                                entries[i].b );
                                        break;

                                   default:
                                        colors[i] = PIXEL_ARGB( entries[i].a,
                                                                (alpha * entries[i].r) >> 8,
                                                                (alpha * entries[i].g) >> 8,
                                                                (alpha * entries[i].b) >> 8 );
                              }
                         }
                    }
                    else {
                         for (i=0; i<gfxs->Blut->num_entries; i++)
                              colors[i] = PIXEL_ARGB( entries[i].a, entries[i].r, entries[i].g, entries[i].b );
                    }
                    break;

               case DSPF_RGB32:
                    for (i=0; i<gfxs->Blut->num_entries; i++)
                         colors[i] = PIXEL_RGB32( entries[i].r, entries[i].g, entries[i].b );
                    break;

               case DSPF_RGB16:
                    for (i=0; i<gfxs->Blut->num_entries; i++)
                         colors16[i] = PIXEL_RGB16( entries[i].r, entries[i].g, entries[i].b );
                    break;

               case DSPF_ARGB4444:
                    if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) {
                         for (i=0; i<gfxs->Blut->num_entries; i++) {
                              int alpha = entries[i].a + 1;

                              switch (alpha) {
                                   case 0:
                                        colors16[i] = 0;
                                        break;

                                   case 255:
                                        colors16[i] = PIXEL_ARGB4444( entries[i].a,
                                                                      entries[i].r,
                                                                      entries[i].g,
                                                                      entries[i].b );
                                        break;

                                   default:
                                        colors16[i] = PIXEL_ARGB4444( entries[i].a,
                                                                      (alpha * entries[i].r) >> 8,
                                                                      (alpha * entries[i].g) >> 8,
                                                                      (alpha * entries[i].b) >> 8 );
                              }
                         }
                    }
                    else {
                         for (i=0; i<gfxs->Blut->num_entries; i++)
Beispiel #14
0
DFBResult
dfb_x11_image_init_handler( DFBX11 *x11, x11Image *image )
{
     Visual *visual;
     XImage *ximage;

     D_MAGIC_ASSERT( image, x11Image );

     if (!x11->use_shm)
          return DFB_UNSUPPORTED;

     /* Lookup visual. */
     visual = x11->visuals[DFB_PIXELFORMAT_INDEX(image->format)];
     if (!visual)
          return DFB_UNSUPPORTED;

     image->visual = visual;

     XLockDisplay( x11->display );

     ximage = XShmCreateImage( x11->display, image->visual, image->depth,
                               ZPixmap, NULL, &image->seginfo, image->width, image->height );
     if (!ximage) {
          D_ERROR( "X11/ShmImage: Error creating shared image (XShmCreateImage)!\n");
          XUnlockDisplay( x11->display );
          return DFB_FAILURE;
     }

     /* we firstly create our shared memory segment with the size we need, and
      correct permissions for the owner, the group and the world --> 0777 */
     image->seginfo.shmid = shmget( IPC_PRIVATE, 
                                    ximage->bytes_per_line * ximage->height,
                                    IPC_CREAT | 0777 );
     if (image->seginfo.shmid < 0)
          goto error;

     /* Then, we have to attach the segment to our process, and we let the
        function search the correct memory place --> NULL. It's safest ! */
     image->seginfo.shmaddr = shmat( image->seginfo.shmid, NULL, 0 );
     if (!image->seginfo.shmaddr)
          goto error_shmat;

     ximage->data = image->seginfo.shmaddr;

     /* We set the buffer in Read and Write mode */
     image->seginfo.readOnly = False;

     if (!XShmAttach( x11->display, &image->seginfo ))
          goto error_xshmattach;

     image->ximage = ximage;
     image->pitch  = ximage->bytes_per_line;

     image->pixmap = XShmCreatePixmap( x11->display, DefaultRootWindow(x11->display), ximage->data,
                                       &image->seginfo, image->width, image->height, image->depth );

     image->gc = XCreateGC( x11->display, image->pixmap, 0, NULL );

     XUnlockDisplay( x11->display );

     return DFB_OK;


error_xshmattach:
     shmdt( image->seginfo.shmaddr );

error_shmat:
     shmctl( image->seginfo.shmid, IPC_RMID, NULL );

error:
     XDestroyImage( ximage );

     XUnlockDisplay( x11->display );

     return DFB_FAILURE;
}
static DFBResult
x11AllocateKey( CoreSurfacePool       *pool,
                void                  *pool_data,
                void                  *pool_local,
                CoreSurfaceBuffer     *buffer,
                const char            *key,
                u64                    handle,
                CoreSurfaceAllocation *allocation,
                void                  *alloc_data )
{
     CoreSurface       *surface;
     x11AllocationData *alloc = alloc_data;
     x11PoolLocalData  *local = pool_local;
     DFBX11            *x11   = local->x11;

     D_DEBUG_AT( X11_Surfaces, "%s( %s, 0x%08llx )\n", __FUNCTION__, key, (unsigned long long) handle );
     D_DEBUG_AT( X11_Surfaces, "  -> allocation: %s\n", ToString_CoreSurfaceAllocation( allocation ) );

     D_MAGIC_ASSERT( pool, CoreSurfacePool );
     D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );

     surface = buffer->surface;
     D_MAGIC_ASSERT( surface, CoreSurface );

     if (!strcmp( key, "Pixmap/X11" )) {
          D_DEBUG_AT( X11_Surfaces, "  -> Pixmap/X11\n" );

          alloc->type = X11_ALLOC_PIXMAP;
     }
     else if (!strcmp( key, "Window/X11" )) {
          D_DEBUG_AT( X11_Surfaces, "  -> Window/X11\n" );

          alloc->type = X11_ALLOC_WINDOW;
     }
     else {
          D_BUG( "unexpected key '%s'", key );
          return DFB_BUG;
     }

     dfb_surface_calc_buffer_size( surface, 8, 8, &alloc->pitch, &allocation->size );

//     alloc->depth  = DefaultDepthOfScreen( x11->screenptr );
//     alloc->visual = DefaultVisualOfScreen( x11->screenptr );
     alloc->visual = x11->visuals[DFB_PIXELFORMAT_INDEX(buffer->format)];
     alloc->depth  = DFB_COLOR_BITS_PER_PIXEL( buffer->format ) + DFB_ALPHA_BITS_PER_PIXEL( buffer->format );

     if (alloc->depth == DefaultDepthOfScreen( x11->screenptr ))
          alloc->visual = DefaultVisualOfScreen( x11->screenptr );

     D_DEBUG_AT( X11_Surfaces, "  -> visual %p (id %lu), depth %d\n", alloc->visual, alloc->visual->visualid, alloc->depth );

     if (handle) {
          switch (alloc->type) {
               case X11_ALLOC_PIXMAP:
                    XLockDisplay( x11->display );

                    alloc->xid = (unsigned long) handle;
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> pixmap 0x%08lx\n", (long) alloc->xid );

                    XUnlockDisplay( x11->display );

                    D_INFO( "X11/Windows: Import Pixmap 0x%08lx\n", alloc->xid );
                    break;

               case X11_ALLOC_WINDOW: {
                    XLockDisplay( x11->display );

                    alloc->window = (unsigned long) handle;
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> window 0x%08lx\n", (long) alloc->window );

                    XCompositeRedirectWindow( x11->display, alloc->window, CompositeRedirectManual );
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> redirected\n" );

                    alloc->xid = XCompositeNameWindowPixmap( x11->display, alloc->window );
//                    alloc->xid = alloc->window;
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> pixmap 0x%08lx\n", (long) alloc->xid );

                    XUnmapWindow( x11->display, alloc->window );
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> unmapped\n" );

                    XUnlockDisplay( x11->display );

                    D_INFO( "X11/Windows: Import Window 0x%08lx with Pixmap handle 0x%08lx\n", alloc->window, alloc->xid );
                    break;
               }

               default:
                    D_BUG( "unexpected allocation type %d\n", alloc->type );
                    return DFB_BUG;
          }
     }
     else {
//          alloc->type = X11_ALLOC_PIXMAP;

          switch (alloc->type) {
               case X11_ALLOC_PIXMAP:
                    XLockDisplay( x11->display );

                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> creating pixmap...\n" );

                    alloc->xid = XCreatePixmap( x11->display, DefaultRootWindow(x11->display),
                                                allocation->config.size.w, allocation->config.size.h, alloc->depth );
                    x11->Sync( x11 );
                    XSync( x11->display, False );
                    D_DEBUG_AT( X11_Surfaces, "  -> pixmap 0x%08lx\n", (long) alloc->xid );

                    XUnlockDisplay( x11->display );

                    D_INFO( "X11/Windows: New Pixmap 0x%08lx\n", alloc->xid );

                    alloc->created = true;
                    break;

               case X11_ALLOC_WINDOW: {
                    Window w = (Window) (long) buffer->surface->data;


                    XSetWindowAttributes attr;

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

                    attr.background_pixmap = 0;

                    XLockDisplay( x11->display );

                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> creating window...\n" );

                    alloc->window = w?:XCreateWindow( x11->display,
                                                   DefaultRootWindow(x11->display),
                                                   600, 200, allocation->config.size.w, allocation->config.size.h, 0,
                                                   alloc->depth, InputOutput,
                                                   alloc->visual, CWEventMask, &attr );
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> window 0x%08lx\n", (long) alloc->window );
                    buffer->surface->data = (void*) (long) alloc->window;

                    XMapRaised( x11->display, alloc->window );
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> raised\n" );

                    XCompositeRedirectWindow( x11->display, alloc->window, CompositeRedirectManual );
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> redirected\n" );

                    alloc->xid = XCompositeNameWindowPixmap( x11->display, alloc->window );
//                    alloc->xid = alloc->window;
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> pixmap 0x%08lx\n", (long) alloc->xid );

                    XUnmapWindow( x11->display, alloc->window );
                    x11->Sync( x11 );
                    D_DEBUG_AT( X11_Surfaces, "  -> unmapped\n" );

                    XUnlockDisplay( x11->display );

                    D_INFO( "X11/Windows: New Window 0x%08lx with Pixmap handle 0x%08lx\n", alloc->window, alloc->xid );

                    alloc->created = !w;
                    break;
               }

               default:
                    D_BUG( "unexpected allocation type %d\n", alloc->type );
                    return DFB_BUG;
          }
     }

     alloc->gc = XCreateGC( x11->display, alloc->xid, 0, NULL );

     allocation->offset = alloc->type;

     return DFB_OK;
}
Beispiel #16
0
/*
 * Blit a glyph with alpha blending and colorizing using the current hardware state.
 */
static bool
pxa3xxBlitGlyph( void *drv, void *dev, DFBRectangle *rect, int x, int y )
{
     PXA3XXDriverData *pdrv   = drv;
     PXA3XXDeviceData *pdev   = dev;
     u32              *prep   = start_buffer( pdrv, 40 );
     const u32         format = pixel_formats[DFB_PIXELFORMAT_INDEX( DSPF_ARGB )];

     D_DEBUG_AT( PXA3XX_BLT, "%s( %d, %d - %dx%d )\n", __FUNCTION__,
                 DFB_RECTANGLE_VALS( rect ) );
     DUMP_INFO();

     if (rect->w * (rect->h + 1) * 4 > pdev->fake_size)
          return false;

     /* Set fake destination. */
     prep[0]  = 0x020000A2;
     prep[1]  = pdev->fake_phys;
     prep[2]  = (format << 19) | ((rect->w << 2) << 5) | 4;

     /* Fill first row of fake buffer. */
     prep[3]  = 0x40000014 | (format << 8);
     prep[4]  = 0;
     prep[5]  = 0;
     prep[6]  = PXA3XX_WH( rect->w, 1 );
     prep[7]  = PIXEL_ARGB( pdev->color.a, pdev->color.r, pdev->color.g, pdev->color.b );

     /* Set first row of fake buffer as source1. */
     prep[8]  = 0x02000012;
     prep[9]  = pdev->fake_phys;
     prep[10] = (format << 19) | 4;

     /* Blit with blending. */
     prep[11] = 0x47000118;
     prep[12] = 0;
     prep[13] = 1;
     prep[14] = rect->x;
     prep[15] = rect->y;
     prep[16] = 0;
     prep[17] = 0;
     prep[18] = PXA3XX_WH( rect->w, rect->h );
     prep[19] = 0;

     /* Restore destination. */
     prep[20] = 0x020000A2;
     prep[21] = pdev->dst_phys;
     prep[22] = (pixel_formats[pdev->dst_index] << 19) | (pdev->dst_pitch << 5) | pdev->dst_bpp;

     /* Restore source1 to destination. */
     prep[23] = 0x02000012;
     prep[24] = prep[21];
     prep[25] = prep[22];

     /* Set fake buffer as source0. */
     prep[26] = 0x02000002;
     prep[27] = pdev->fake_phys;
     prep[28] = (format << 19) | ((rect->w << 2) << 5) | 4;

     /* Blit with blending. */
     prep[29] = 0x47000107;
     prep[30] = x;
     prep[31] = y;
     prep[32] = 0;
     prep[33] = 1;
     prep[34] = x;
     prep[35] = y;
     prep[36] = PXA3XX_WH( rect->w, rect->h );

     /* Restore source0. */
     prep[37] = 0x02000002;
     prep[38] = pdev->src_phys;
     prep[39] = (pixel_formats[pdev->src_index] << 19) | (pdev->src_pitch << 5) | pdev->src_bpp;

     submit_buffer( pdrv, 40 );

     return true;
}
Beispiel #17
0
static DFBResult
system_initialize( CoreDFB *core, void **data )
{
     int         i, n;
     CoreScreen *screen;

     D_ASSERT( dfb_x11 == NULL );

     dfb_x11 = (DFBX11*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFBX11) );
     if (!dfb_x11) {
          D_ERROR( "DirectFB/X11: Couldn't allocate shared memory!\n" );
          return D_OOSHM();
     }

     dfb_x11_core = core;

     fusion_skirmish_init( &dfb_x11->lock, "X11 System", dfb_core_world(core) );

     fusion_call_init( &dfb_x11->call, call_handler, NULL, dfb_core_world(core) );

     dfb_surface_pool_initialize( core, &x11SurfacePoolFuncs, &dfb_x11->surface_pool );

     screen = dfb_screens_register( NULL, NULL, &x11PrimaryScreenFuncs );

     dfb_layers_register( screen, NULL, &x11PrimaryLayerFuncs );

     fusion_arena_add_shared_field( dfb_core_arena( core ), "x11", dfb_x11 );

     *data = dfb_x11;

     XInitThreads();

     dfb_x11->data_shmpool = dfb_core_shmpool_data( core );

     dfb_x11->display = XOpenDisplay(getenv("DISPLAY"));
     if (!dfb_x11->display) {
          D_ERROR("X11: Error in XOpenDisplay for '%s'\n", getenv("DISPLAY"));
          return DFB_INIT;
     }

     dfb_x11->screenptr = DefaultScreenOfDisplay(dfb_x11->display);
     dfb_x11->screennum = DefaultScreen(dfb_x11->display);

     for (i=0; i<dfb_x11->screenptr->ndepths; i++) {
          const Depth *depth = &dfb_x11->screenptr->depths[i];

          for (n=0; n<depth->nvisuals; n++) {
               Visual *visual = &depth->visuals[n];

               D_DEBUG( "X11/Visual: ID %02lu, depth %d, red 0x%06lx, green 0x%06lx, blue 0x%06lx, %d bits/rgb, %d entries\n",
                        visual->visualid, depth->depth,
                        visual->red_mask, visual->green_mask, visual->blue_mask,
                        visual->bits_per_rgb, visual->map_entries );

               switch (depth->depth) {
                    case 24:
                         if (visual->red_mask   == 0xff0000 &&
                             visual->green_mask == 0x00ff00 &&
                             visual->blue_mask  == 0x0000ff) {
                              dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = visual;
                              dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)]  = visual;
                         }
                         break;

                    case 16:
                         if (visual->red_mask   == 0xf800 &&
                             visual->green_mask == 0x07e0 &&
                             visual->blue_mask  == 0x001f)
                              dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = visual;
                         break;

                    case 15:
                         if (visual->red_mask   == 0x7c00 &&
                             visual->green_mask == 0x03e0 &&
                             visual->blue_mask  == 0x001f)
                              dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)] = visual;
                         break;
               }
          }
     }

     return DFB_OK;
}
Beispiel #18
0
static DFBResult
InitLocal( DFBX11 *x11, DFBX11Shared *shared, CoreDFB *core )
{
     int i, n, d;

     XInitThreads();

     x11->shared = shared;
     x11->core   = core;

     x11->display = XOpenDisplay(getenv("DISPLAY"));
     if (!x11->display) {
          D_ERROR("X11: Error in XOpenDisplay for '%s'\n", getenv("DISPLAY"));
          return DFB_INIT;
     }

     x11->screenptr = DefaultScreenOfDisplay(x11->display);
     x11->screennum = DefaultScreen(x11->display);
     d              = DefaultDepthOfScreen(x11->screenptr);

     for (i=0; i<x11->screenptr->ndepths; i++) {
          const Depth *depth = &x11->screenptr->depths[i];

          for (n=0; n<depth->nvisuals; n++) {
               Visual *visual = &depth->visuals[n];

               D_DEBUG_AT( X11_Core, "[Visual %d] ID 0x%02lx, depth %d, RGB 0x%06lx/0x%06lx/0x%06lx, %d bpRGB, %d entr.\n",
                        n, visual->visualid, depth->depth,
                        visual->red_mask, visual->green_mask, visual->blue_mask,
                        visual->bits_per_rgb, visual->map_entries );

               if (depth->depth != d)
                    continue;

               switch (depth->depth) {
                    case 32:
                         if (visual->red_mask   == 0xff0000 &&
                             visual->green_mask == 0x00ff00 &&
                             visual->blue_mask  == 0x0000ff &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = visual;
                         break;

                    case 24:
                         if (visual->red_mask   == 0xff0000 &&
                             visual->green_mask == 0x00ff00 &&
                             visual->blue_mask  == 0x0000ff &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = visual;
                         break;

                    case 16:
                         if (visual->red_mask   == 0xf800 &&
                             visual->green_mask == 0x07e0 &&
                             visual->blue_mask  == 0x001f &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = visual;
                         break;

                    case 15:
                         if (visual->red_mask   == 0x7c00 &&
                             visual->green_mask == 0x03e0 &&
                             visual->blue_mask  == 0x001f &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)] = visual;
                         break;
               }
          }
     }

     if (XShmQueryExtension( x11->display ))
          XShmQueryVersion( x11->display, &x11->xshm_major, &x11->xshm_minor, &x11->use_shm );


     x11->screen = dfb_screens_register( NULL, x11, x11PrimaryScreenFuncs );

     dfb_layers_register( x11->screen, x11, x11PrimaryLayerFuncs );
     dfb_layers_register( x11->screen, x11, x11PrimaryLayerFuncs );
     dfb_layers_register( x11->screen, x11, x11PrimaryLayerFuncs );

     return DFB_OK;
}
Beispiel #19
0
static DFBResult
InitLocal( DFBX11 *x11, DFBX11Shared *shared, CoreDFB *core )
{
     int i, n;

     XInitThreads();

     if (direct_config_get_int_value( "x11-sync" ))
          x11->Sync = sync_display;
     else
          x11->Sync = sync_display_noop;

     x11->shared = shared;
     x11->core   = core;

     x11->display = XOpenDisplay(getenv("DISPLAY"));
     if (!x11->display) {
          D_ERROR("X11: Error in XOpenDisplay for '%s'\n", getenv("DISPLAY"));
          return DFB_INIT;
     }

     x11->screenptr = DefaultScreenOfDisplay(x11->display);
     x11->screennum = DefaultScreen(x11->display);

     D_DEBUG_AT( X11_Core, "  -> ndepths %d\n", x11->screenptr->ndepths);

     for (i=0; i<x11->screenptr->ndepths; i++) {
          const Depth *depth = &x11->screenptr->depths[i];

          D_DEBUG_AT( X11_Core, "  -> [%d] depth %d, nvisuals %d\n", i, depth->depth, depth->nvisuals );

          for (n=0; n<depth->nvisuals; n++) {
               Visual *visual = &depth->visuals[n];

               D_DEBUG_AT( X11_Core, "[Visual %d] ID 0x%02lx, depth %d, RGB 0x%06lx/0x%06lx/0x%06lx, %d bpRGB, %d entr.\n",
                        n, visual->visualid, depth->depth,
                        visual->red_mask, visual->green_mask, visual->blue_mask,
                        visual->bits_per_rgb, visual->map_entries );

               //if (depth->depth != d)
               //     continue;

               //if (visual->visualid == 0x24) {
               //     x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = visual;
               //     continue;
               //}

               switch (depth->depth) {
                    case 32:
                         if (visual->red_mask   == 0xff0000 &&
                             visual->green_mask == 0x00ff00 &&
                             visual->blue_mask  == 0x0000ff &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = visual;
                         break;

                    case 24:
                         if (visual->red_mask   == 0xff0000 &&
                             visual->green_mask == 0x00ff00 &&
                             visual->blue_mask  == 0x0000ff &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = visual;
                         break;

                    case 16:
                         if (visual->red_mask   == 0xf800 &&
                             visual->green_mask == 0x07e0 &&
                             visual->blue_mask  == 0x001f &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = visual;
                         break;

                    case 15:
                         if (visual->red_mask   == 0x7c00 &&
                             visual->green_mask == 0x03e0 &&
                             visual->blue_mask  == 0x001f &&
                             !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)])
                              x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)] = visual;
                         break;
               }
          }
     }


     DFBSurfacePixelFormat formats[] = { DSPF_ARGB, DSPF_RGB32, DSPF_RGB16, DSPF_RGB555 };

     for (i=0; i<D_ARRAY_SIZE(formats); i++) {
          Visual *visual = x11->visuals[DFB_PIXELFORMAT_INDEX(formats[i])];

          if (visual) {
               D_DEBUG_AT( X11_Core, "  %-20s [Visual ID 0x%02lx] RGB 0x%06lx/0x%06lx/0x%06lx, %d bpRGB, %d entr.\n",
                           dfb_pixelformat_name(formats[i]), visual->visualid, visual->red_mask, visual->green_mask, visual->blue_mask,
                           visual->bits_per_rgb, visual->map_entries );
          }
          else
               D_DEBUG_AT( X11_Core, "  %-20s [NO VISUAL]\n", dfb_pixelformat_name(formats[i]) );
     }


     if (XShmQueryExtension( x11->display ))
          XShmQueryVersion( x11->display, &x11->xshm_major, &x11->xshm_minor, &x11->use_shm );
     x11->use_shm = 0;


     x11->screen = dfb_screens_register( NULL, x11, x11PrimaryScreenFuncs );

     for (i=0; i<shared->outputs * shared->layers; i++) {
          if (!dfb_layers_register( x11->screen, x11, x11PrimaryLayerFuncs ))
               return DFB_INIT;
     }

     return DFB_OK;
}