aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-05-08 16:03:55 +0000
committerMax Horn2009-05-08 16:03:55 +0000
commite933c02fd2b622bb79dcac520e045b405bcb81c8 (patch)
tree5cfeab90402d18294066af1cbb64cc9be7e1788f
parent0ebd41ac5964d1852ccf48f4766e9270fa5756af (diff)
downloadscummvm-rg350-e933c02fd2b622bb79dcac520e045b405bcb81c8.tar.gz
scummvm-rg350-e933c02fd2b622bb79dcac520e045b405bcb81c8.tar.bz2
scummvm-rg350-e933c02fd2b622bb79dcac520e045b405bcb81c8.zip
SCI: Folded line.h and crossblit.h into gfx_support.cpp
svn-id: r40389
-rw-r--r--engines/sci/gfx/crossblit.h76
-rw-r--r--engines/sci/gfx/gfx_support.cpp91
-rw-r--r--engines/sci/gfx/gfx_tools.h8
-rw-r--r--engines/sci/gfx/line.h69
4 files changed, 94 insertions, 150 deletions
diff --git a/engines/sci/gfx/crossblit.h b/engines/sci/gfx/crossblit.h
deleted file mode 100644
index bd9cf29fff..0000000000
--- a/engines/sci/gfx/crossblit.h
+++ /dev/null
@@ -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
diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp
index 555bfaa268..fd62cf8e73 100644
--- a/engines/sci/gfx/gfx_support.cpp
+++ b/engines/sci/gfx/gfx_support.cpp
@@ -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 @@ void gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) {
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>,
diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h
index 97c599d94b..50ecb70783 100644
--- a/engines/sci/gfx/gfx_tools.h
+++ b/engines/sci/gfx/gfx_tools.h
@@ -43,9 +43,11 @@ enum gfx_xlate_filter_t {
};
-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
diff --git a/engines/sci/gfx/line.h b/engines/sci/gfx/line.h
deleted file mode 100644
index e839bb46f0..0000000000
--- a/engines/sci/gfx/line.h
+++ /dev/null
@@ -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