DFBResult
CoreGraphicsStateClient_StretchBlit( CoreGraphicsStateClient *client,
                                     const DFBRectangle      *srects,
                                     const DFBRectangle      *drects,
                                     unsigned int             num )
{
     D_DEBUG_AT( Core_GraphicsStateClient, "%s( client %p )\n", __FUNCTION__, client );

     D_MAGIC_ASSERT( client, CoreGraphicsStateClient );
     D_ASSERT( srects != NULL );
     D_ASSERT( drects != NULL );

     if (num == 0)
          return DFB_OK;

     if (num != 1)
          D_UNIMPLEMENTED();

     if (dfb_core_is_master( client->core ) || !fusion_config->secure_fusion) {
          // FIXME: will overwrite rects
          dfb_gfxcard_stretchblit( (DFBRectangle*) srects, (DFBRectangle*) drects, client->state );
     }
     else {
          DFBResult ret;

          CoreGraphicsStateClient_Update( client, DFXL_STRETCHBLIT, client->state );

          ret = CoreGraphicsState_StretchBlit( client->gfx_state, srects, drects, num );
          if (ret)
               return ret;
     }

     return DFB_OK;
}
static void* FrameThread( void *ctx )
{
    IDirectFBVideoProvider_Swf_data *data = (IDirectFBVideoProvider_Swf_data*)ctx;
    struct timeval wd2,now,tv;
    long           cmd;
    long           wakeUp;
    long delay = 0;

    cmd = FLASH_WAKEUP;
    wakeUp = FlashExec (data->flashHandle, cmd, 0, &wd2);

    while (1) {

        pthread_testcancel();


        gettimeofday (&now, 0);
        delay = (wd2.tv_sec - now.tv_sec) * 1000 + (wd2.tv_usec - now.tv_usec) / 1000;

        if (delay < 0)
            delay = 20;

        if (data->flashDisplay.flash_refresh) {
            DFBRectangle   rect, drect;

            rect.x=0;
            rect.y=0;
            rect.w=(int) data->flashInfo.frameWidth / 20;
            rect.h=(int) data->flashInfo.frameHeight / 20;

            drect = data->dest_rect;

            dfb_gfxcard_stretchblit( &rect, &drect, &data->state );
            data->flashDisplay.flash_refresh = 0;

            if (data->callback)
                data->callback (data->ctx);
        }

        if (wakeUp) {
            tv.tv_sec = 0;
            tv.tv_usec = delay * 1000;
            select( 0, 0, 0, 0, &tv );

            cmd = FLASH_WAKEUP;
            wakeUp = FlashExec (data->flashHandle, cmd, 0, &wd2);
        }
        else
            return NULL;
    }
}
Beispiel #3
0
void
dfb_gfx_stretch_to( CoreSurface *source, CoreSurface *destination,
                    const DFBRectangle *srect, const DFBRectangle *drect, bool from_back )
{
     DFBRectangle sourcerect = { 0, 0, source->config.size.w, source->config.size.h };
     DFBRectangle destrect =   { 0, 0, destination->config.size.w, destination->config.size.h };

     if (srect) {
          if (!dfb_rectangle_intersect( &sourcerect, srect ))
               return;
     }

     if (drect) {
          if (!dfb_rectangle_intersect( &destrect, drect ))
               return;
     }

     pthread_mutex_lock( &copy_lock );

     if (!copy_state_inited) {
          dfb_state_init( &copy_state, NULL );
          copy_state_inited = true;
     }

     copy_state.modified   |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION;

     copy_state.clip.x2     = destination->config.size.w - 1;
     copy_state.clip.y2     = destination->config.size.h - 1;
     copy_state.source      = source;
     copy_state.destination = destination;
     copy_state.from        = from_back ? CSBR_BACK : CSBR_FRONT;

     dfb_gfxcard_stretchblit( &sourcerect, &destrect, &copy_state );

     /* Signal end of sequence. */
     dfb_state_stop_drawing( &copy_state );

     pthread_mutex_unlock( &copy_lock );
}
Beispiel #4
0
DFBResult
IGraphicsState_Real__StretchBlit(
    CoreGraphicsState                         *obj,
    const DFBRectangle                        *srects,
    const DFBRectangle                        *drects,
    u32                                        num
)
{
    D_DEBUG_AT( DirectFB_CoreGraphicsState, "%s()\n", __FUNCTION__ );

    D_ASSERT( srects != NULL );
    D_ASSERT( drects != NULL );

    if (!obj->state.destination || !obj->state.source)
        return DFB_NOCONTEXT;

    if ((obj->state.blittingflags & (DSBLIT_SRC_MASK_ALPHA | DSBLIT_SRC_MASK_COLOR)) && !obj->state.source_mask)
        return DFB_NOCONTEXT;

    for (u32 i=0; i<num; i++)
        dfb_gfxcard_stretchblit( (DFBRectangle*) &srects[i], (DFBRectangle*) &drects[i], &obj->state );

    return DFB_OK;
}
Beispiel #5
0
static DFBResult
DisplaySurface( DFBX11                *x11,
                X11LayerData          *lds,
                VdpPresentationQueue   queue,
                CoreSurfaceBufferLock *lock )
{
     DirectResult                        ret;
     DFBX11Shared                       *shared = x11->shared;
     DFBX11CallPresentationQueueDisplay  display;

     display.presentation_queue         = queue;
     display.clip_width                 = 0;
     display.clip_height                = 0;
     display.earliest_presentation_time = 0;

     if (lock &&
         lds->config.dest.x == 0 && lds->config.dest.y == 0 &&
         lds->config.dest.w == shared->screen_size.w &&
         lds->config.dest.h == shared->screen_size.h)
     {
          display.surface = (VdpOutputSurface) (unsigned long) lock->handle;
     }
     else {
          CardState    state;
          DFBRectangle rect;

          dfb_state_init( &state, x11->core );

          state.destination = shared->vdp_core_surface;
          state.source      = lock ? lock->buffer->surface : NULL;
          state.clip.x1     = 0;
          state.clip.y1     = 0;
          state.clip.x2     = shared->screen_size.w - 1;
          state.clip.y2     = shared->screen_size.h - 1;

          rect.x = 0;
          rect.y = 0;
          rect.w = shared->screen_size.w;
          rect.h = shared->screen_size.h;

          dfb_gfxcard_fillrectangles( &rect, 1, &state );

          if (lock)
               dfb_gfxcard_stretchblit( &lds->config.source, &lds->config.dest, &state );

          dfb_gfxcard_sync();

          state.destination = NULL;
          state.source      = NULL;

          dfb_state_destroy( &state );


          display.surface = shared->vdp_surface;
     }

     ret = fusion_call_execute2( &x11->shared->call, FCEF_ONEWAY,
                                 X11_VDPAU_PRESENTATION_QUEUE_DISPLAY, &display, sizeof(display), NULL );
     if (ret) {
          D_DERROR( ret, "DirectFB/X11/VDPAU: fusion_call_execute2() failed!\n" );
          return ret;
     }

     return DFB_OK;
}
Beispiel #6
0
static void
root_update( StretRegion     *region,
             void            *region_data,
             void            *update_data,
             unsigned long    arg,
             int              x,
             int              y,
             const DFBRegion *updates,
             int              num )
{
     int              i;
     CoreWindowStack *stack;
     UniqueContext   *context = region_data;
     CardState       *state   = update_data;

     D_ASSERT( region != NULL );
     D_ASSERT( region_data != NULL );
     D_ASSERT( update_data != NULL );
     D_ASSERT( updates != NULL );

     D_ASSERT( x == 0 );
     D_ASSERT( y == 0 );

     D_MAGIC_ASSERT( context, UniqueContext );
     D_MAGIC_ASSERT( state, CardState );

     stack = context->stack;

     D_ASSERT( stack != NULL );
     D_ASSERT( stack->bg.image != NULL || (stack->bg.mode != DLBM_IMAGE &&
                                           stack->bg.mode != DLBM_TILE) );

     D_DEBUG_AT( UniQuE_Root, "root_update( region %p, num %d )\n", region, num );
#if D_DEBUG_ENABLED
     for (i=0; i<num; i++) {
          D_DEBUG_AT( UniQuE_Root, "    (%d)  %4d,%4d - %4dx%4d\n",
                      i, DFB_RECTANGLE_VALS_FROM_REGION( &updates[i] ) );
     }
#endif

     switch (stack->bg.mode) {
          case DLBM_COLOR: {
               CoreSurface *dest  = state->destination;
               DFBColor    *color = &stack->bg.color;
               DFBRectangle rects[num];

               /* Set the background color. */
               if (DFB_PIXELFORMAT_IS_INDEXED( dest->config.format ))
                    dfb_state_set_color_index( state,
                                               dfb_palette_search( dest->palette, color->r,
                                                                   color->g, color->b, color->a ) );
               else
                    dfb_state_set_color( state, color );

               for (i=0; i<num; i++)
                    dfb_rectangle_from_region( &rects[i], &updates[i] );

               /* Simply fill the background. */
               dfb_gfxcard_fillrectangles( rects, num, state );

               break;
          }

          case DLBM_IMAGE: {
               CoreSurface *bg = stack->bg.image;

               /* Set blitting source. */
               state->source    = bg;
               state->modified |= SMF_SOURCE;

               /* Set blitting flags. */
               dfb_state_set_blitting_flags( state, DSBLIT_NOFX );

               /* Check the size of the background image. */
               if (bg->config.size.w == stack->width && bg->config.size.h == stack->height) {
                    for (i=0; i<num; i++) {
                         DFBRectangle dst = DFB_RECTANGLE_INIT_FROM_REGION( &updates[i] );

                         /* Simple blit for 100% fitting background image. */
                         dfb_gfxcard_blit( &dst, dst.x, dst.y, state );
                    }
               }
               else {
                    DFBRegion clip = state->clip;

                    for (i=0; i<num; i++) {
                         DFBRectangle src = { 0, 0, bg->config.size.w, bg->config.size.h };
                         DFBRectangle dst = { 0, 0, stack->width, stack->height };

                         /* Change clipping region. */
                         dfb_state_set_clip( state, &updates[i] );

                         /* Stretch blit for non fitting background images. */
                         dfb_gfxcard_stretchblit( &src, &dst, state );
                    }

                    /* Restore clipping region. */
                    dfb_state_set_clip( state, &clip );
               }

               /* Reset blitting source. */
               state->source    = NULL;
               state->modified |= SMF_SOURCE;

               break;
          }

          case DLBM_TILE: {
               CoreSurface  *bg   = stack->bg.image;
               DFBRegion     clip = state->clip;

               /* Set blitting source. */
               state->source    = bg;
               state->modified |= SMF_SOURCE;

               /* Set blitting flags. */
               dfb_state_set_blitting_flags( state, DSBLIT_NOFX );

               for (i=0; i<num; i++) {
                    DFBRectangle src = { 0, 0, bg->config.size.w, bg->config.size.h };

                    /* Change clipping region. */
                    dfb_state_set_clip( state, &updates[i] );

                    /* Tiled blit (aligned). */
                    dfb_gfxcard_tileblit( &src, 0, 0, stack->width, stack->height, state );
               }

               /* Restore clipping region. */
               dfb_state_set_clip( state, &clip );

               /* Reset blitting source. */
               state->source    = NULL;
               state->modified |= SMF_SOURCE;

               break;
          }

          case DLBM_DONTCARE:
               break;

          default:
               D_BUG( "unknown background mode" );
               break;
     }
}