Example #1
0
void fill_buffer( buffer_t *buffer )
{
    int32 i;
    framebuffer_t *frame;

    printf( "Filling start thread's input buffer...\n" );
    for( i = 0; i < buffer->size; i++ )
    {
        // Allocate a new frame 
        frame = (framebuffer_t*)malloc( sizeof(framebuffer_t) );
        if( frame != NULL )
        {
            framebuffer_create( frame, INPUT_WIDTH, INPUT_HEIGHT );
        }

        // Insert the frame into the buffer
        buffer_insert( buffer, frame );
    }
}
Example #2
0
framebuffer_t* tgainput_next_frame( stream_node_t *node, framebuffer_t *copy )
{
    framebuffer_t *frame;

    if( node->input == NULL )
    {
        frame = (framebuffer_t*)malloc( sizeof(framebuffer_t) );
        if( frame != NULL )
        {
            framebuffer_create( frame, INPUT_WIDTH, INPUT_HEIGHT );
        }
    }
    else
    {
        frame = buffer_remove( node->input );
    }

    return frame;
}
Example #3
0
void* rotate_thread( void *arg )
{
    int res;
    framebuffer_t *dst;
    framebuffer_t *frame;
    stream_node_t *node;

    // Get the argument to the thread
    node = (stream_node_t*)arg;

    // Make sure that the input buffer is valid
    if( node->input == NULL )
    {
        fprintf(stderr,"sobel node must be used with a valid input buffer\n");
        exit(1 );
    }

    // Make sure that the output buffer is valid
    if( node->output == NULL )
    {
        fprintf(stderr,"sobel node must be used with a valid output buffer\n");
        exit(1 );
    }

    // By default we have no frame for the destination image
    dst = NULL;

    // Run the sobel thread
    while( 1 )
    {
        process_keys();

        // Get an image from the input buffer
        frame = buffer_remove( node->input );

        // Determine if we should stop processing
        if( frame == NULL ) break;

        // Create a destination image if needed
        if( dst == NULL )
        {
            dst = (framebuffer_t*)malloc( sizeof(framebuffer_t) );

            if( dst != NULL )
            {
                res = framebuffer_create( dst, frame->width, frame->height );
                if( res != 0 )
                {
                    free(dst);
                    dst = NULL;
                }
            }
        }

        // Process the image if we can otherwise pass on the input image
        if( dst != NULL && rotate_run )
        {
            // Perform the filter
            framebuffer_rotate( dst, frame );

            // Place the image on the output buffer
            buffer_insert( node->output, dst );

            // Store the current frame for use as the destination next time
            dst = frame;
        }
        else
        {
            // Place the image on the output buffer unmodified
            buffer_insert( node->output, frame );
        }

    }

    // Destroy our temporary storage
    free( dst );

    // Finish running the thread
    return NULL;
}
Example #4
0
bool
hsp_make_current(Bitmap *bitmap, uint64 ctxId)
{
	TRACE("%s(bitmap: %p ctxId: %d)\n", __FUNCTION__, bitmap, ctxId);
	struct hsp_context *ctx = NULL;
	GET_CURRENT_CONTEXT(glcurctx);
	GLuint width = 0;
	GLuint height = 0;
	struct hsp_context *curctx;

	if (!hsp_dev) {
		TRACE("%s> there's no hsp_dev so nothing to do\n",
			__FUNCTION__);
		return false;
	}

	pipe_mutex_lock(hsp_dev->mutex);
	ctx = hsp_lookup_context(ctxId);
	pipe_mutex_unlock(hsp_dev->mutex);

	if (ctx == NULL) {
		TRACE("%s> context not found\n", __FUNCTION__);
		return false;
	}

	current_bitmap = bitmap;
	current_ctx_id = ctxId;

	if (glcurctx != NULL) {
		curctx = (struct hsp_context*) glcurctx->DriverCtx;

		if (curctx != ctx)
			st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
	}

	if (!bitmap || ctxId == 0) {
		st_make_current(NULL, NULL, NULL);
		return true;
	}

	if (glcurctx != NULL) {
		struct hsp_context *curctx = (struct hsp_context*) glcurctx->DriverCtx;
		if (curctx != NULL && curctx == ctx && ctx->bitmap == bitmap)
			return true;
	}

	if (bitmap != NULL) {
		get_bitmap_size(bitmap, &width, &height);
		TRACE("%s> found bitmap: %p with size: %dx%d\n", __FUNCTION__,
			bitmap, width, height);
	}

	if (ctx != NULL && bitmap != NULL ) {
		GLvisual *visual = &ctx->st->ctx->Visual;
		if (ctx->draw == NULL) {
			ctx->draw = framebuffer_create(bitmap, visual, width /*+ 1*/, height /*+ 1*/);
		}
		if ((hsp_dev->options & BGL_DOUBLE) == BGL_DOUBLE && ctx->read == NULL) {
			ctx->read = framebuffer_create(bitmap, visual, width /*+ 1*/, height /*+ 1*/);
		}
	}

	if (ctx) {
		if (ctx->draw && ctx->read == NULL) {
			st_make_current(ctx->st, ctx->draw->stfb, ctx->draw->stfb);
			framebuffer_resize(ctx->draw, width /*+ 1*/, height /*+ 1*/);
		} else if (ctx && ctx->draw && ctx->read) {
			st_make_current(ctx->st, ctx->draw->stfb, ctx->read->stfb);
			framebuffer_resize(ctx->draw, width /*+ 1*/, height /*+ 1*/);
			framebuffer_resize(ctx->read, width /*+ 1*/, height /*+ 1*/);
		}
		ctx->bitmap = bitmap;
		ctx->st->pipe->priv = bitmap;
	} else {
		st_make_current(NULL, NULL, NULL);
	}

	return true;
}