/*
 *			GPAC - MPEG-4 Systems C Development Kit
 *
 *			Copyright (c) Jean Le Feuvre 2000-2005
 *					All rights reserved
 *
 *  This file is part of GPAC / software 2D rasterizer plugin
 *
 *  GPAC is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  GPAC is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *
 *		
 */

#include "m4_rend.h"

/*we don't need any private context*/
Raster2D *M4_LoadRenderer()
{
	Raster2D *dr = malloc(sizeof(Raster2D));
	memset(dr, 0, sizeof(Raster2D));
	M4_REG_PLUG(dr, M4_RASTER_2D_INTERFACE, "GPAC 2D Raster", "gpac distribution", 0)


	dr->stencil_new = m4_stencil_new;
	dr->stencil_delete = m4_stencil_delete;
	dr->stencil_set_matrix = m4_stencil_set_matrix;
	dr->stencil_set_brush_color = m4_stencil_set_brush_color;
	dr->stencil_set_gradient_mode = m4_stencil_set_gradient_mode;
	dr->stencil_set_linear_gradient = m4_stencil_set_linear_gradient;
	dr->stencil_set_radial_gradient = m4_stencil_set_radial_gradient;
	dr->stencil_set_gradient_interpolation = m4_stencil_set_gradient_interpolation;
	dr->stencil_set_texture = m4_stencil_set_texture;
	dr->stencil_set_tiling = m4_stencil_set_tiling;
	dr->stencil_set_filter = m4_stencil_set_filter;
	dr->stencil_set_color_matrix = m4_stencil_set_color_matrix;
	dr->stencil_reset_color_matrix = m4_stencil_reset_color_matrix;
	dr->stencil_set_texture_alpha = m4_stencil_set_texture_alpha;
	dr->stencil_create_texture = m4_stencil_create_texture;
	dr->stencil_texture_modified = NULL;

	dr->surface_new = m4_surface_new;
	dr->surface_delete = m4_surface_delete;
	dr->surface_attach_to_device = NULL;
	dr->surface_attach_to_texture = m4_surface_attach_to_texture;
	dr->surface_attach_to_buffer = m4_surface_attach_to_buffer;
	dr->surface_detach = m4_surface_detach;
	dr->surface_set_raster_level = m4_surface_set_raster_level;
	dr->surface_set_matrix = m4_surface_set_matrix;
	dr->surface_set_clipper = m4_surface_set_clipper;
	dr->surface_set_path = m4_surface_set_path;
	dr->surface_fill = m4_surface_fill;
	dr->surface_flush = NULL;
	dr->surface_clear = m4_surface_clear;
	return dr;
}

void M4_ShutdownRenderer(Raster2D *dr)
{
	free(dr);
}

#ifndef USE_M4_REND_AS_LIB

Bool QueryInterface(u32 InterfaceType)
{
	if (InterfaceType == M4_RASTER_2D_INTERFACE) return 1;
	return 0;
}

void *LoadInterface(u32 InterfaceType)
{
	if (InterfaceType==M4_RASTER_2D_INTERFACE) {
		return M4_LoadRenderer();
	}
	return NULL;
}

void ShutdownInterface(void *ifce)
{
	Raster2D *dr = (Raster2D *)ifce;
	if (dr->InterfaceType == M4_RASTER_2D_INTERFACE) {
		M4_ShutdownRenderer(dr);
	}
}

#endif
