Ejemplo n.º 1
0
Archivo: rlist.c Proyecto: aahud/harvey
void main(int argc, char * argv[])
{
	Rectangle r1 = Rect(0, 0, 300, 200);
	Rectangle r2 = Rect(100, 100, 400, 300);
	Rectangle r3 = Rect(200, 100, 500, 300);
	Region reg;

	initdraw(0, 0, "vncviewer");
	region_init(&reg);
	region_union(&reg, r1, r1);
	region_union(&reg, r2, r2);
	region_union(&reg, r3, r3);
}
Ejemplo n.º 2
0
void mouse_draw( INSTANCE * i, REGION * clip )
{
    int r ;
    REGION region;

    r = GLOINT32( libmouse, MOUSEREGION ) ;
    if ( r < 0 || r > 31 ) r = 0 ;

    region = regions[r];
    if ( clip ) region_union( &region, clip );

    if ( GLOINT32( libmouse, MOUSEANGLE ) || GLOINT32( libmouse, MOUSESIZE ) != 100 )
        gr_rotated_blit(
            0,
            &region,
            GLOINT32( libmouse, MOUSEX ),
            GLOINT32( libmouse, MOUSEY ),
            GLODWORD( libmouse, MOUSEFLAGS ),
            GLOINT32( libmouse, MOUSEANGLE ),
            GLOINT32( libmouse, MOUSESIZE ),
            GLOINT32( libmouse, MOUSESIZE ),
            mouse_map ) ;
    else
        gr_blit(
            0,
            &region,
            GLOINT32( libmouse, MOUSEX ),
            GLOINT32( libmouse, MOUSEY ),
            GLODWORD( libmouse, MOUSEFLAGS ),
            mouse_map ) ;

    mouse_map->modified = 0;
}
Ejemplo n.º 3
0
static int check_collision_box( INSTANCE * proc1, GRAPH * bmp1, REGION * bbox1, INSTANCE * proc2 )
{
    REGION bbox2 ;
    GRAPH * bmp2 ;

    bmp2 = instance_graph( proc2 ) ; if ( !bmp2 ) return 0 ;
    instance_get_bbox( proc2, bmp2, &bbox2 );

    region_union( &bbox2, bbox1 ) ;
    if ( region_is_empty( &bbox2 ) ) return 0 ;

    return 1;
}
Ejemplo n.º 4
0
void scroll_draw( int n, REGION * clipping )
{
    int nproc, x, y, cx, cy ;

    static INSTANCE ** proclist = 0;
    static int proclist_reserved = 0;
    int proclist_count;
    REGION r;
    int status;

    GRAPH * graph, * back, * dest = NULL;

    SCROLL_EXTRA_DATA * data;
    INSTANCE * i;

    if ( n < 0 || n > 9 ) return ;

    if ( !scrolls[n].active || !scrolls[n].region || !scrolls[n].graphid ) return ;

    graph = scrolls[n].graphid ? bitmap_get( scrolls[n].fileid, scrolls[n].graphid ) : NULL ;
    back  = scrolls[n].backid  ? bitmap_get( scrolls[n].fileid, scrolls[n].backid )  : NULL ;

    if (                        !graph ) return ; // El fondo de scroll no existe
    if (  scrolls[n].backid  && !back  ) return ; // Grafico no existe

    dest = scrolls[n].destid ? bitmap_get( scrolls[n].destfile, scrolls[n].destid ) : NULL ;

    data = &(( SCROLL_EXTRA_DATA * ) & GLODWORD( libscroll, SCROLLS ) )[n] ;

    /* Dibuja el fondo */

    r = *scrolls[n].region;
    if ( !dest && clipping ) region_union( &r, clipping );

    if ( back )
    {
        if ( back->ncpoints > 0 && back->cpoints[0].x >= 0 )
        {
            cx = back->cpoints[0].x ;
            cy = back->cpoints[0].y ;
        }
        else
        {
            cx = back->width / 2 ;
            cy = back->height / 2 ;
        }

        y = scrolls[n].region->y - scrolls[n].y1 ;

        while ( y < scrolls[n].region->y2 )
        {
            x = scrolls[n].region->x - scrolls[n].x1 ;
            while ( x < scrolls[n].region->x2 )
            {
                gr_blit( dest, &r, x + cx, y + cy, data->flags2, back ) ;
                x += back->width ;
            }
            y += back->height ;
        }
    }

    /* Dibuja el primer plano */

    if ( graph->ncpoints > 0 && graph->cpoints[0].x >= 0 )
    {
        cx = graph->cpoints[0].x ;
        cy = graph->cpoints[0].y ;
    }
    else
    {
        cx = graph->width / 2 ;
        cy = graph->height / 2 ;
    }

    y = scrolls[n].region->y - scrolls[n].y0 ;
    while ( y < scrolls[n].region->y2 )
    {
        x = scrolls[n].region->x - scrolls[n].x0 ;
        while ( x < scrolls[n].region->x2 )
        {
            gr_blit( dest, &r, x + cx, y + cy, data->flags1, graph ) ;
            x += graph->width ;
        }
        y += graph->height ;
    }

    /* Crea una lista ordenada de instancias a dibujar */

    i = first_instance ;
    proclist_count = 0 ;
    while ( i )
    {
        if ( LOCDWORD( libscroll, i, CTYPE ) == C_SCROLL &&
                (
                    (( status = LOCDWORD( libscroll, i, STATUS ) ) & ~STATUS_WAITING_MASK ) == STATUS_RUNNING ||
                    ( status & ~STATUS_WAITING_MASK ) == STATUS_FROZEN
                )
           )
        {
            if ( LOCDWORD( libscroll, i, CNUMBER ) && !( LOCDWORD( libscroll, i, CNUMBER ) & ( 1 << n ) ) )
            {
                i = i->next ;
                continue ;
            }

            if ( proclist_count == proclist_reserved )
            {
                proclist_reserved += 16 ;
                proclist = ( INSTANCE ** ) realloc( proclist, sizeof( INSTANCE * ) * proclist_reserved ) ;
            }

            proclist[proclist_count++] = i ;
        }
        i = i->next ;
    }

    if ( proclist_count )
    {
        /* Ordena la listilla */

        qsort( proclist, proclist_count, sizeof( INSTANCE * ), compare_instances ) ;

        /* Visualiza los procesos */

        for ( nproc = 0 ; nproc < proclist_count ; nproc++ )
        {
            x = LOCDWORD( libscroll, proclist[nproc], COORDX ) ;
            y = LOCDWORD( libscroll, proclist[nproc], COORDY ) ;

            RESOLXY( libscroll, proclist[nproc], x, y );

            draw_instance_at( proclist[nproc], &r, x - scrolls[n].posx0 + scrolls[n].region->x, y - scrolls[n].posy0 + scrolls[n].region->y, dest ) ;
        }
    }
}
Ejemplo n.º 5
0
static int check_collision( INSTANCE * proc1, GRAPH * bmp1, REGION * bbox3, INSTANCE * proc2 )
{
    REGION bbox1, bbox2 ;
    int x, y, w, h ;
    GRAPH * bmp2 ;

    bbox1 = *bbox3;

    bmp2 = instance_graph( proc2 ) ; if ( !bmp2 ) return 0 ;
    instance_get_bbox( proc2, bmp2, &bbox2 );

    region_union( &bbox1, &bbox2 ) ;
    if ( region_is_empty( &bbox1 ) ) return 0 ;

    // Solo si las regiones de ambos bbox se superponen

    w = bbox1.x2 - bbox1.x + 1 ;
    h = bbox1.y2 - bbox1.y + 1 ;
    bbox2.x = bbox2.y = 0 ;
    bbox2.x2 = w - 1 ;
    bbox2.y2 = h - 1 ;

    bmp1 = bitmap_new( 0, w, h, sys_pixel_format->depth ) ;
    if ( !bmp1 ) return 0;

    bmp2 = bitmap_new( 0, w, h, sys_pixel_format->depth ) ;
    if ( !bmp2 )
    {
        bitmap_destroy( bmp1 ) ;
        return 0;
    }

    memset( bmp1->data, 0, bmp1->pitch * h ) ;
    memset( bmp2->data, 0, bmp2->pitch * h ) ;

    x = LOCINT32( mod_grproc, proc1, COORDX ) ;
    y = LOCINT32( mod_grproc, proc1, COORDY ) ;
    RESOLXY( mod_grproc, proc1, x, y );

    x -= bbox1.x ;
    y -= bbox1.y ;
    draw_at( bmp1, x, y, &bbox2, proc1 ) ;

    x = LOCINT32( mod_grproc, proc2, COORDX ) ;
    y = LOCINT32( mod_grproc, proc2, COORDY ) ;
    RESOLXY( mod_grproc, proc2, x, y );

    x -= bbox1.x ;
    y -= bbox1.y ;
    draw_at( bmp2, x, y, &bbox2, proc2 ) ;

    if ( sys_pixel_format->depth == 32 )
    {
        uint32_t * ptr1 = ( uint32_t * ) bmp1->data ;
        uint32_t * ptr2 = ( uint32_t * ) bmp2->data ;

        uint8_t * _ptr1 = ( uint8_t * ) ptr1 ;
        uint8_t * _ptr2 = ( uint8_t * ) ptr2 ;

        for ( y = 0 ; y < h ; y++ )
        {
            for ( x = 0 ; x < w ; x++, ptr1++, ptr2++ )
            {
                if ( *ptr1 && *ptr2 )
                {
                    bitmap_destroy( bmp1 ) ;
                    bitmap_destroy( bmp2 ) ;
                    return 1;
                }
            }
            ptr1 = ( uint32_t * )( _ptr1 += bmp1->pitch );
            ptr2 = ( uint32_t * )( _ptr2 += bmp2->pitch );
        }
    }
    else
    {
        if ( sys_pixel_format->depth == 16 )
        {
            uint16_t * ptr1 = ( uint16_t * ) bmp1->data ;
            uint16_t * ptr2 = ( uint16_t * ) bmp2->data ;

            uint8_t * _ptr1 = ( uint8_t * ) ptr1 ;
            uint8_t * _ptr2 = ( uint8_t * ) ptr2 ;

            for ( y = 0 ; y < h ; y++ )
            {
                for ( x = 0 ; x < w ; x++, ptr1++, ptr2++ )
                {
                    if ( *ptr1 && *ptr2 )
                    {
                        bitmap_destroy( bmp1 ) ;
                        bitmap_destroy( bmp2 ) ;
                        return 1;
                    }
                }
                ptr1 = ( uint16_t * )( _ptr1 += bmp1->pitch );
                ptr2 = ( uint16_t * )( _ptr2 += bmp2->pitch );
            }
        }
        else
        {
            uint8_t * ptr1 = ( uint8_t * )bmp1->data ;
            uint8_t * ptr2 = ( uint8_t * )bmp2->data ;

            uint8_t * _ptr1 = ptr1 ;
            uint8_t * _ptr2 = ptr2 ;

            for ( y = 0 ; y < h ; y++ )
            {
                for ( x = 0 ; x < w ; x++, ptr1++, ptr2++ )
                {
                    if ( *ptr1 && *ptr2 )
                    {
                        bitmap_destroy( bmp1 ) ;
                        bitmap_destroy( bmp2 ) ;
                        return 1;
                    }
                }
                ptr1 = _ptr1 += bmp1->pitch;
                ptr2 = _ptr2 += bmp2->pitch;
            }
        }
    }

    bitmap_destroy( bmp1 ) ;
    bitmap_destroy( bmp2 ) ;
    return 0;
}
Ejemplo n.º 6
0
void draw_instance( INSTANCE * i, REGION * clip )
{
    GRAPH * map ;
    int16_t * blend_table = NULL ;
    int flags;
    int scalex, scaley;
    REGION region;
    int alpha ;
    int blendop = 0 ;
    PALETTE * palette = NULL ;
    int paletteid;

    /* Difference with draw_instance_at from here */
    int x, y, r ;
    /* Difference with draw_instance_at to here */

//    map = instance_graph( i ) ;
    map = ( GRAPH * ) LOCDWORD( librender, i, GRAPHPTR );
    if ( !map ) return ;

    flags = ( LOCDWORD( librender, i, FLAGS ) ^ LOCDWORD( librender, i, XGRAPH_FLAGS ) );

    if (( alpha = LOCDWORD( librender, i, ALPHA ) ) != 255 )
    {
        if ( alpha <= 0 ) return ;
        else if ( alpha < 255 )
            flags |= B_ALPHA | ( alpha << B_ALPHA_SHIFT );
    }

    scalex = LOCINT32( librender, i, GRAPHSIZEX );
    scaley = LOCINT32( librender, i, GRAPHSIZEY );
    if ( scalex == 100 && scaley == 100 ) scalex = scaley = LOCINT32( librender, i, GRAPHSIZE );

    if (( blendop = LOCDWORD( librender, i, BLENDOP ) ) )
    {
        blend_table = map->blend_table;
        map->blend_table = ( int16_t * ) blendop;
    }

    if (( paletteid = LOCDWORD( librender, i, PALETTEID ) ) )
    {
        palette = map->format->palette ;
        map->format->palette = ( PALETTE * ) paletteid;
    }

    /* Difference with draw_instance_at from here */

    x = LOCINT32( librender, i, COORDX ) ;
    y = LOCINT32( librender, i, COORDY ) ;

    RESOLXY( librender, i, x, y );

    r = LOCINT32( librender, i, REGIONID ) ;
    if ( r > 0 && r < 32 )
        region = regions[ r ] ;
    else
        region = regions[ 0 ];

    if ( clip ) region_union( &region, clip );
    /* Difference with draw_instance_at to here */

    /* XGRAPH does not rotate destination graphic.
       WARNING: don't remove "scalex != 100 || scaley != 100 ||" from begin the next condition */
    if ( scalex != 100 || scaley != 100 || ( LOCINT32( librender, i, ANGLE ) && !LOCDWORD( librender, i, XGRAPH ) ) )
        gr_rotated_blit( 0, &region, x, y, flags, LOCDWORD( librender, i, XGRAPH ) ? 0 : LOCINT32( librender, i, ANGLE ), scalex, scaley, map ) ;
    else
        gr_blit( 0, &region, x, y, flags, map ) ;

    if ( paletteid ) map->format->palette = palette;
    if ( blendop ) map->blend_table = blend_table;

    if ( map->modified ) map->modified = 0;
}