[Scummvm-cvs-logs] SF.net SVN: scummvm:[38907] scummvm/trunk/engines/sci/gfx
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Feb 26 17:16:38 CET 2009
Revision: 38907
http://scummvm.svn.sourceforge.net/scummvm/?rev=38907&view=rev
Author: fingolfin
Date: 2009-02-26 16:16:38 +0000 (Thu, 26 Feb 2009)
Log Message:
-----------
SCI: Turned the crossblit code into a template
Modified Paths:
--------------
scummvm/trunk/engines/sci/gfx/gfx_support.cpp
Added Paths:
-----------
scummvm/trunk/engines/sci/gfx/crossblit.h
Removed Paths:
-------------
scummvm/trunk/engines/sci/gfx/gfx_crossblit.cpp
Copied: scummvm/trunk/engines/sci/gfx/crossblit.h (from rev 38906, scummvm/trunk/engines/sci/gfx/gfx_crossblit.cpp)
===================================================================
--- scummvm/trunk/engines/sci/gfx/crossblit.h (rev 0)
+++ scummvm/trunk/engines/sci/gfx/crossblit.h 2009-02-26 16:16:38 UTC (rev 38907)
@@ -0,0 +1,76 @@
+/* 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
Property changes on: scummvm/trunk/engines/sci/gfx/crossblit.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Deleted: scummvm/trunk/engines/sci/gfx/gfx_crossblit.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_crossblit.cpp 2009-02-26 16:16:30 UTC (rev 38906)
+++ scummvm/trunk/engines/sci/gfx/gfx_crossblit.cpp 2009-02-26 16:16:38 UTC (rev 38907)
@@ -1,110 +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$
- *
- */
-
-/* This file isn't used directly; rather, it's included by a different file. */
-/* Note that memcpy() is assumed to be an inlineable built-in. If it isn't,
-** performance will suck... badly.
-*/
-/* Config parameters:
-** FUNCTION_NAME: Name of the blitter function
-** USE_PRIORITY: Whether to care about the priority buffer
-** BYTESPP: Bytes per pixel
-*/
-
-#include "common/scummsys.h"
-
-/* set optimisations for Win32: */
-/* g on: enable global optimizations */
-/* t on: use fast code */
-/* y on: suppress creation of frame pointers on stack */
-/* s off: disable minimize size code */
-#ifdef WIN32
-# include <memory.h>
-# ifndef SATISFY_PURIFY
-# pragma optimize( "s", off )
-# pragma optimize( "gty", on )
-# pragma intrinsic( memcpy, memset )
-# endif
-#endif
-
-namespace Sci {
-
-static void FUNCTION_NAME(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
-#ifdef USE_PRIORITY
- , byte *priority_buffer, int bytes_per_priority_line, int bytes_per_priority_pixel, int priority
-#endif /* USE_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;
-#ifdef USE_PRIORITY
- int priority_offset = 0;
-#endif /* USE_PRIORITY */
-
- for (x = 0; x < alpha_end; x += bytes_per_alpha_pixel) {
- if ((alpha_test_mask & alpha[x])
-#ifdef REVERSE_ALPHA
- >=
-#else
- <
-#endif
- alpha_min)
-#ifdef USE_PRIORITY
- if (priority_buffer[priority_offset] <= priority) {
- priority_buffer[priority_offset] = priority;
-#endif /* USE_PRIORITY */
- memcpy(dest + pixel_offset, src + pixel_offset, BYTESPP);
-#ifdef USE_PRIORITY
- }
-#endif /* USE_PRIORITY */
-
- pixel_offset += BYTESPP;
- alpha_offset += bytes_per_alpha_pixel;
-#ifdef USE_PRIORITY
- priority_offset += bytes_per_priority_pixel;
-#endif /* USE_PRIORITY */
- }
-
- dest += bytes_per_dest_line;
- src += bytes_per_src_line;
- alpha += bytes_per_alpha_line;
-#ifdef USE_PRIORITY
- priority_buffer += bytes_per_priority_line;
-#endif /* USE_PRIORITY */
- }
-}
-
-} // End of namespace Sci
-
-/* reset to original optimisations for Win32: */
-/* (does not reset intrinsics) */
-#ifdef WIN32
-# pragma optimize( "", on )
-#endif
Modified: scummvm/trunk/engines/sci/gfx/gfx_support.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_support.cpp 2009-02-26 16:16:30 UTC (rev 38906)
+++ scummvm/trunk/engines/sci/gfx/gfx_support.cpp 2009-02-26 16:16:38 UTC (rev 38907)
@@ -30,6 +30,7 @@
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_tools.h"
#include "sci/gfx/line.h"
+#include "sci/gfx/crossblit.h"
namespace Sci {
@@ -84,153 +85,32 @@
gfx_draw_box_buffer(pxm->index_data, pxm->index_xl, box, color);
}
-} // End of namespace Sci
-
-// Import various crossblit functions
-#undef USE_PRIORITY
-#undef FUNCTION_NAME
-#undef BYTESPP
-
-# define FUNCTION_NAME _gfx_crossblit_8
-# define BYTESPP 1
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_16
-# define BYTESPP 2
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_24
-# define BYTESPP 3
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_32
-# define BYTESPP 4
-# include "gfx_crossblit.cpp"
-
-#define USE_PRIORITY
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_8_P
-# define BYTESPP 1
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_16_P
-# define BYTESPP 2
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_24_P
-# define BYTESPP 3
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_32_P
-# define BYTESPP 4
-# include "gfx_crossblit.cpp"
-
-#undef USE_PRIORITY
-#undef FUNCTION_NAME
-#undef BYTESPP
-
-// Reverse alpha versions
-#undef USE_PRIORITY
-#undef FUNCTION_NAME
-#undef BYTESPP
-#undef REVERSE_ALPHA
-
-#define REVERSE_ALPHA
-# define FUNCTION_NAME _gfx_crossblit_8_RA
-# define BYTESPP 1
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_16_RA
-# define BYTESPP 2
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_24_RA
-# define BYTESPP 3
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_32_RA
-# define BYTESPP 4
-# include "gfx_crossblit.cpp"
-
-#define USE_PRIORITY
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_8_P_RA
-# define BYTESPP 1
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_16_P_RA
-# define BYTESPP 2
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_24_P_RA
-# define BYTESPP 3
-# include "gfx_crossblit.cpp"
-
-# undef FUNCTION_NAME
-# undef BYTESPP
-# define FUNCTION_NAME _gfx_crossblit_32_P_RA
-# define BYTESPP 4
-# include "gfx_crossblit.cpp"
-
-#undef USE_PRIORITY
-#undef FUNCTION_NAME
-#undef BYTESPP
-#undef REVERSE_ALPHA
-
-namespace Sci {
-
-static void (*crossblit_fns[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = { NULL,
- _gfx_crossblit_8,
- _gfx_crossblit_16,
- _gfx_crossblit_24,
- _gfx_crossblit_32
+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>,
+ _gfx_crossblit<3, false, false>,
+ _gfx_crossblit<4, false, false>
};
static void (*crossblit_fns_P[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL,
- _gfx_crossblit_8_P,
- _gfx_crossblit_16_P,
- _gfx_crossblit_24_P,
- _gfx_crossblit_32_P
+ _gfx_crossblit<1, true, false>,
+ _gfx_crossblit<2, true, false>,
+ _gfx_crossblit<3, true, false>,
+ _gfx_crossblit<4, true, false>
};
-static void (*crossblit_fns_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = { NULL,
- _gfx_crossblit_8_RA,
- _gfx_crossblit_16_RA,
- _gfx_crossblit_24_RA,
- _gfx_crossblit_32_RA
+static void (*crossblit_fns_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL,
+ _gfx_crossblit<1, false, true>,
+ _gfx_crossblit<2, false, true>,
+ _gfx_crossblit<3, false, true>,
+ _gfx_crossblit<4, false, true>
};
static void (*crossblit_fns_P_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL,
- _gfx_crossblit_8_P_RA,
- _gfx_crossblit_16_P_RA,
- _gfx_crossblit_24_P_RA,
- _gfx_crossblit_32_P_RA
+ _gfx_crossblit<1, true, true>,
+ _gfx_crossblit<2, true, true>,
+ _gfx_crossblit<3, true, true>,
+ _gfx_crossblit<4, true, true>
};
void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp) {
@@ -361,7 +241,8 @@
if (priority == GFX_NO_PRIORITY) {
if (bpp > 0 && bpp < 5)
((revalpha) ? crossblit_fns_RA : crossblit_fns)[bpp](dest, src, dest_line_width, pxm->xl * bpp,
- xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min);
+ xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min,
+ 0, 0, 0, 0);
else {
GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp);
return GFX_ERROR;
@@ -369,8 +250,8 @@
} else { // priority
if (bpp > 0 && bpp < 5)
((revalpha) ? crossblit_fns_P_RA : crossblit_fns_P)[bpp](dest, src, dest_line_width, pxm->xl * bpp,
- xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel,
- alpha_mask, alpha_min, priority_pos, priority_line_width, priority_skip, priority);
+ xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min,
+ priority_pos, priority_line_width, priority_skip, priority);
else {
GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp);
return GFX_ERROR;
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