Beispiel #1
0
void OpenVG_SVGHandler::optimize() {

    if( _batch ) {
        vgDestroyBatchMNK( _batch );
        _batch = 0;
    }
    // use the monkvg batch extension to greatly optimize rendering.  don't need this for
    // other OpenVG implementations
    _batch = vgCreateBatchMNK();

    vgBeginBatchMNK( _batch );
    { // draw

        // clear out the transform stack
        _transform_stack.clear();

        float m[9];
        vgGetMatrix( m );
        // assume the current openvg matrix is like the camera matrix and should always be applied first
        Transform2d top;
        Transform2d::multiply( top, Transform2d(m), rootTransform() );	// multiply by the root transform
        pushTransform( top );

        // SVG is origin at the top, left (openvg is origin at the bottom, left)
        // so need to flip
        //		Transform2d flip;
        //		flip.setScale( 1, -1 );
        //		pushTransform( flip );

        draw_recursive( _root_group );

        vgLoadMatrix( m );	// restore matrix
        _transform_stack.clear();


    }
    vgEndBatchMNK( _batch );

}
Beispiel #2
0
    void OpenVG_SVGHandler::dump(void **vertices, size_t *size) {
        
        VGBatchMNK temp;
        temp = vgCreateBatchMNK();
		
		vgBeginBatchMNK( temp ); 
        
        {
            
			// clear the transform stack
			_transform_stack.clear();
            
            // save matrix
			VGfloat m[9];
			vgGetMatrix( m );
            
			// assume the current openvg matrix is like the camera matrix and should always be applied first
			Transform2d top;
			Transform2d::multiply( top, Transform2d(m), rootTransform() );	// multiply by the root transform
			pushTransform( top );
			
            // draw
			draw_recursive( _root_group );
			
            // restore matrix
			vgLoadMatrix( m );
            
            // clear the transform stack
            _transform_stack.clear();
            
		} 
        
        vgDumpBatchMNK( temp, vertices, size );
        vgEndBatchMNK( temp );
        vgDestroyBatchMNK( temp );
        
    }