[Scummvm-cvs-logs] SF.net SVN: scummvm:[40389] scummvm/trunk/engines/sci/gfx

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri May 8 18:03:55 CEST 2009


Revision: 40389
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40389&view=rev
Author:   fingolfin
Date:     2009-05-08 16:03:55 +0000 (Fri, 08 May 2009)

Log Message:
-----------
SCI: Folded line.h and crossblit.h into gfx_support.cpp

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_support.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.h

Removed Paths:
-------------
    scummvm/trunk/engines/sci/gfx/crossblit.h
    scummvm/trunk/engines/sci/gfx/line.h

Deleted: scummvm/trunk/engines/sci/gfx/crossblit.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/crossblit.h	2009-05-08 16:03:14 UTC (rev 40388)
+++ scummvm/trunk/engines/sci/gfx/crossblit.h	2009-05-08 16:03:55 UTC (rev 40389)
@@ -1,76 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/scummsys.h"
-
-namespace Sci {
-
-/* Config parameters:
-** FUNCTION_NAME: Name of the blitter function
-** USE_PRIORITY: Whether to care about the priority buffer
-** BYTESPP: Bytes per pixel
-*/
-template <int BYTESPP, bool USE_PRIORITY, bool REVERSE_ALPHA>
-void _gfx_crossblit(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_line,
-	int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel,
-	unsigned int alpha_test_mask, unsigned int alpha_min,
-	byte *priority_buffer, int bytes_per_priority_line, int bytes_per_priority_pixel, int priority
-	) {
-	int x, y;
-	int alpha_end = xl * bytes_per_alpha_pixel;
-
-	for (y = 0; y < yl; y++) {
-		int pixel_offset = 0;
-		int alpha_offset = 0;
-		int priority_offset = 0;
-
-		for (x = 0; x < alpha_end; x += bytes_per_alpha_pixel) {
-			if (((alpha_test_mask & alpha[x]) < alpha_min) ^ REVERSE_ALPHA) {
-
-				if (USE_PRIORITY) {
-					if (priority_buffer[priority_offset] <= priority) {
-						priority_buffer[priority_offset] = priority;
-						memcpy(dest + pixel_offset, src + pixel_offset, BYTESPP);
-					}
-				} else {
-					memcpy(dest + pixel_offset, src + pixel_offset, BYTESPP);
-				}
-			}
-
-			pixel_offset += BYTESPP;
-			alpha_offset += bytes_per_alpha_pixel;
-			if (USE_PRIORITY)
-				priority_offset += bytes_per_priority_pixel;
-		}
-
-		dest += bytes_per_dest_line;
-		src += bytes_per_src_line;
-		alpha += bytes_per_alpha_line;
-		if (USE_PRIORITY)
-			priority_buffer += bytes_per_priority_line;
-	}
-}
-
-} // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/gfx_support.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_support.cpp	2009-05-08 16:03:14 UTC (rev 40388)
+++ scummvm/trunk/engines/sci/gfx/gfx_support.cpp	2009-05-08 16:03:55 UTC (rev 40389)
@@ -29,13 +29,53 @@
 
 #include "sci/gfx/gfx_system.h"
 #include "sci/gfx/gfx_tools.h"
-#include "sci/gfx/line.h"
-#include "sci/gfx/crossblit.h"
 
 namespace Sci {
 
 int gfx_crossblit_alpha_threshold = 128;
 
+
+#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \
+                  linearend, nonlinearstart, linearmod, nonlinearmod) \
+	incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \
+	incrNE <<= 1; \
+	deltanonlinear <<= 1; \
+	incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear);  \
+	d = nonlinearstart - 1;  \
+	while (linearvar != (linearend)) { \
+		memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH); \
+		linearvar += linearmod; \
+		if ((d += incrE) < 0) { \
+			d += incrNE; \
+			nonlinearvar += nonlinearmod; \
+		}; \
+	}; \
+	memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH);
+
+
+template <int PIXELWIDTH>
+void _gfx_draw_line_buffer(byte *buffer, int linewidth, Common::Point start, Common::Point end, unsigned int color) {
+	int incrE, incrNE, d;
+	int dx = ABS(end.x - start.x);
+	int dy = ABS(end.y - start.y);
+#ifdef SCUMM_BIG_ENDIAN
+	color = SWAP_BYTES_32(color);
+#endif
+
+	if (dx > dy) {
+		int sign1 = (end.x < start.x) ? -1 : 1;
+		int sign2 = (end.y < start.y) ? -1 : 1;
+		LINEMACRO(start.x, start.y, dx, dy, start.x, start.y, end.x, dx, sign1 * PIXELWIDTH, sign2);
+	} else { // dx <= dy
+		int sign1 = (end.y < start.y) ? -1 : 1;
+		int sign2 = (end.x < start.x) ? -1 : 1;
+		LINEMACRO(start.x, start.y, dy, dx, start.y, start.x, end.y, dy, sign1, sign2 * PIXELWIDTH);
+	}
+}
+
+#undef LINEMACRO
+
+
 static void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth,
 			Common::Point start, Common::Point end, unsigned int color) {
 	switch (pixelwidth) {
@@ -86,6 +126,53 @@
 	gfx_draw_box_buffer(pxm->index_data, pxm->index_width, box, color);
 }
 
+
+/* Template parameters:
+ * BYTESPP: Bytes per pixel
+ * USE_PRIORITY: Whether to care about the priority buffer
+ */
+template <int BYTESPP, bool USE_PRIORITY, bool REVERSE_ALPHA>
+void _gfx_crossblit(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_line,
+	int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel,
+	unsigned int alpha_test_mask, unsigned int alpha_min,
+	byte *priority_buffer, int bytes_per_priority_line, int bytes_per_priority_pixel, int priority
+	) {
+	int x, y;
+	int alpha_end = xl * bytes_per_alpha_pixel;
+
+	for (y = 0; y < yl; y++) {
+		int pixel_offset = 0;
+		int alpha_offset = 0;
+		int priority_offset = 0;
+
+		for (x = 0; x < alpha_end; x += bytes_per_alpha_pixel) {
+			if (((alpha_test_mask & alpha[x]) < alpha_min) ^ REVERSE_ALPHA) {
+
+				if (USE_PRIORITY) {
+					if (priority_buffer[priority_offset] <= priority) {
+						priority_buffer[priority_offset] = priority;
+						memcpy(dest + pixel_offset, src + pixel_offset, BYTESPP);
+					}
+				} else {
+					memcpy(dest + pixel_offset, src + pixel_offset, BYTESPP);
+				}
+			}
+
+			pixel_offset += BYTESPP;
+			alpha_offset += bytes_per_alpha_pixel;
+			if (USE_PRIORITY)
+				priority_offset += bytes_per_priority_pixel;
+		}
+
+		dest += bytes_per_dest_line;
+		src += bytes_per_src_line;
+		alpha += bytes_per_alpha_line;
+		if (USE_PRIORITY)
+			priority_buffer += bytes_per_priority_line;
+	}
+}
+
+
 static void (*crossblit_fns[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL,
 	_gfx_crossblit<1, false, false>,
 	_gfx_crossblit<2, false, false>,

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-05-08 16:03:14 UTC (rev 40388)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-05-08 16:03:55 UTC (rev 40389)
@@ -43,9 +43,11 @@
 };
 
 
-extern int gfx_crossblit_alpha_threshold; /* Crossblitting functions use this value as threshold
-					  ** for distinguishing between transparent and opaque
-					  ** wrt alpha values */
+/**
+ * Crossblitting functions use this value as threshold for distinguishing
+ * between transparent and opaque wrt alpha values.
+ */
+extern int gfx_crossblit_alpha_threshold;
 
 gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, Palette *palette, int flags);
 /* Allocates a new gfx_mode_t structure with the specified parameters

Deleted: scummvm/trunk/engines/sci/gfx/line.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/line.h	2009-05-08 16:03:14 UTC (rev 40388)
+++ scummvm/trunk/engines/sci/gfx/line.h	2009-05-08 16:03:55 UTC (rev 40389)
@@ -1,69 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-namespace Sci {
-
-#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \
-                  linearend, nonlinearstart, linearmod, nonlinearmod) \
-	incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \
-	incrNE <<= 1; \
-	deltanonlinear <<= 1; \
-	incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear);  \
-	d = nonlinearstart - 1;  \
-	while (linearvar != (linearend)) { \
-		memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH); \
-		linearvar += linearmod; \
-		if ((d += incrE) < 0) { \
-			d += incrNE; \
-			nonlinearvar += nonlinearmod; \
-		}; \
-	}; \
-	memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH);
-
-
-template <int PIXELWIDTH>
-void _gfx_draw_line_buffer(byte *buffer, int linewidth, Common::Point start, Common::Point end, unsigned int color) {
-	int incrE, incrNE, d;
-	int dx = ABS(end.x - start.x);
-	int dy = ABS(end.y - start.y);
-#ifdef SCUMM_BIG_ENDIAN
-	color = SWAP_BYTES_32(color);
-#endif
-
-	if (dx > dy) {
-		int sign1 = (end.x < start.x) ? -1 : 1;
-		int sign2 = (end.y < start.y) ? -1 : 1;
-		LINEMACRO(start.x, start.y, dx, dy, start.x, start.y, end.x, dx, sign1 * PIXELWIDTH, sign2);
-	} else { // dx <= dy
-		int sign1 = (end.y < start.y) ? -1 : 1;
-		int sign2 = (end.x < start.x) ? -1 : 1;
-		LINEMACRO(start.x, start.y, dy, dx, start.y, start.x, end.y, dy, sign1, sign2 * PIXELWIDTH);
-	}
-}
-
-
-#undef LINEMACRO
-
-} // End of namespace Sci


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list