/*
 * This program 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 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */


#ifndef __OVERLAYDIRECT_H__
#define __OVERLAYDIRECT_H__
#include "overlayframe.h"

#define XBLEND(FN, temp_type, type, max, components, ofs, round) { \
	temp_type opcty = fade * max + round, trnsp = max - opcty; \
	type** output_rows = (type**)output->get_rows(); \
	type** input_rows = (type**)input->get_rows(); \
	ix *= components;  ox *= components; \
 \
	for( int i=pkg->out_row1; i<pkg->out_row2; ++i ) { \
		type* in_row = input_rows[i + iy] + ix; \
		type* output = output_rows[i] + ox; \
		for( int j=ow; --j>=0; ) { \
			if( components == 4 ) { \
				temp_type r, g, b, a; \
				ALPHA4_BLEND(FN, temp_type, in_row, output, max, ofs, ofs, round); \
				ALPHA4_STORE(output, ofs, max); \
			} \
			else { \
				temp_type r, g, b; \
				ALPHA3_BLEND(FN, temp_type, in_row, output, max, ofs, ofs, round); \
				ALPHA3_STORE(output, ofs, max); \
			} \
			in_row += components;  output += components; \
		} \
	} \
} break

#endif
