[php-directfb-cvs] PHP-DirectFB/src datatypes.c,1.7,1.8 isurface.c,1.6,1.7
Status: Pre-Alpha
Brought to you by:
klan
From: Claudio C. <kl...@us...> - 2005-01-30 11:03:12
|
Update of /cvsroot/php-directfb/PHP-DirectFB/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11182 Modified Files: datatypes.c isurface.c Log Message: Added missing IDirectFBSurface method BatchBlit(). Fixed NV12/NV16 surface's size calculation. Index: isurface.c =================================================================== RCS file: /cvsroot/php-directfb/PHP-DirectFB/src/isurface.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- isurface.c 2 Jan 2005 16:27:08 -0000 1.6 +++ isurface.c 30 Jan 2005 11:02:47 -0000 1.7 @@ -151,7 +151,7 @@ { IDirectFBSurface *surface; DFBRegion reg; - DFBSurfaceFlipFlags flags = 0; + DFBSurfaceFlipFlags flags = DSFLIP_NONE; zval *r = NULL; DIRECTFB_GET_THIS( surface ); @@ -479,6 +479,77 @@ } static +INTERFACE_METHOD( BatchBlit ) +{ + IDirectFBSurface *surface; + IDirectFBSurface *source; + DFBRectangle *source_rects = NULL; + DFBPoint *dest_points = NULL; + int i, num = 0; + zval *src; + zval *rects; + zval *points; + + DIRECTFB_GET_THIS( surface ); + + if (zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "Oaa|l", + &src, IDirectFBSurface_ce, &rects, + &points, &num ) != SUCCESS) + INVARG(); + + DIRECTFB_GET_INTERFACE( src, IDirectFBSurface, source ); + + if (num > 0) { + source_rects = (DFBRectangle*) emalloc( num * sizeof(DFBRectangle) ); + dest_points = (DFBPoint*) emalloc( num * sizeof(DFBPoint) ); + + for (i = 0; i < num; i++) { + zval **r, **p; + + if (zend_hash_index_find( Z_ARRVAL_P( rects ), + i, (void*) &r ) != SUCCESS || + zend_hash_index_find( Z_ARRVAL_P( points ), + i, (void*) &p ) != SUCCESS) { + efree( source_rects ); + efree( dest_points ); + source_rects = NULL; + dest_points = NULL; + break; + } + + DIRECTFB_TRANSLATE_DATA( DFBRectangle, *r, &source_rects[i] ); + DIRECTFB_TRANSLATE_DATA( DFBPoint, *p, &dest_points[i] ); + } + } + else { + zval **r, **p; + + while (zend_hash_index_find( Z_ARRVAL_P( rects ), + num, (void*) &r ) == SUCCESS && + zend_hash_index_find( Z_ARRVAL_P( points ), + num, (void*) &p ) == SUCCESS) { + ++num; + source_rects = (DFBRectangle*) erealloc( source_rects, + num*sizeof(DFBRectangle) ); + dest_points = (DFBPoint*) erealloc( dest_points, + num*sizeof(DFBPoint) ); + + DIRECTFB_TRANSLATE_DATA( DFBRectangle, *r, &source_rects[num-1] ); + DIRECTFB_TRANSLATE_DATA( DFBPoint, *p, &dest_points[num-1] ); + } + } + + dfb_errno = surface->BatchBlit( surface, source, + source_rects, dest_points, num ); + + if (source_rects) + efree( source_rects ); + + if (dest_points) + efree( dest_points ); +} + +static INTERFACE_METHOD( StretchBlit ) { IDirectFBSurface *surface; @@ -973,6 +1044,7 @@ METHOD( SetBlittingFlags ) METHOD( Blit ) METHOD( TileBlit ) + METHOD( BatchBlit ) METHOD( StretchBlit ) METHOD( TextureTriangles ) METHOD( SetDrawingFlags ) Index: datatypes.c =================================================================== RCS file: /cvsroot/php-directfb/PHP-DirectFB/src/datatypes.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- datatypes.c 2 Jan 2005 16:27:08 -0000 1.7 +++ datatypes.c 30 Jan 2005 11:02:47 -0000 1.8 @@ -791,9 +791,18 @@ dsc->preallocated[0].pitch > 0 && dsc->height > 0 && dsc->pixelformat) { int size = dsc->preallocated[0].pitch * dsc->height; - if (dsc->pixelformat == DSPF_YV12 || - dsc->pixelformat == DSPF_I420) + switch (dsc->pixelformat) { + case DSPF_NV16: + size += size & ~1; + break; + case DSPF_YV12: + case DSPF_I420: + case DSPF_NV12: size += (size >> 1) & ~1; + break; + default: + break; + } add_property_stringl( ret, "preallocated_data", dsc->preallocated[0].data, size, 1 ); |