aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx/gfx_pixmap_scale.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2009-09-07 16:18:05 +0000
committerFilippos Karapetis2009-09-07 16:18:05 +0000
commit8fa0b431ee64b7c9105051981c6a62f30983e6fc (patch)
treea6814e9fcf6e2bc803b1cdcf2a9c22430bc2d7b7 /engines/sci/gfx/gfx_pixmap_scale.cpp
parentbebc76b4d8fd25ef84f22a7500df7e74b9714ddc (diff)
downloadscummvm-rg350-8fa0b431ee64b7c9105051981c6a62f30983e6fc.tar.gz
scummvm-rg350-8fa0b431ee64b7c9105051981c6a62f30983e6fc.tar.bz2
scummvm-rg350-8fa0b431ee64b7c9105051981c6a62f30983e6fc.zip
Merged xfact and yfact into scaleFactor - it doesn't really make sense to multiply one dimension with an integer multiplier which is different to the multiplier of the other dimension, otherwise we'll end up with funny looking and squashed resolutions like 640x200 or 320x400. Also, removed the now-unused pixelFormat member variable of the graphics driver struct
svn-id: r44003
Diffstat (limited to 'engines/sci/gfx/gfx_pixmap_scale.cpp')
-rw-r--r--engines/sci/gfx/gfx_pixmap_scale.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp
index 9e4578a813..65a44c524f 100644
--- a/engines/sci/gfx/gfx_pixmap_scale.cpp
+++ b/engines/sci/gfx/gfx_pixmap_scale.cpp
@@ -40,10 +40,9 @@ namespace Sci {
static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {
byte result_colors[GFX_PIC_COLORS];
- int xfact = (scale) ? mode->xfact : 1;
- int yfact = (scale) ? mode->yfact : 1;
+ int scaleFactor = (scale) ? mode->scaleFactor : 1;
int widthc, heightc; // Width duplication counter
- int line_width = xfact * pxm->index_width;
+ int line_width = scaleFactor * pxm->index_width;
int x, y;
int i;
byte byte_transparent = 0;
@@ -55,7 +54,7 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in
int separate_alpha_map = using_alpha;
if (separate_alpha_map && !alpha_dest)
- alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * xfact * pxm->index_height * yfact);
+ alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * scaleFactor * pxm->index_height * scaleFactor);
// Calculate all colors
for (i = 0; i < pxm->colors_nr(); i++)
@@ -77,20 +76,20 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in
// O(n) loops. There is an O(ln(n)) algorithm for this, but its slower for small n (which we're optimizing for here).
// And, anyway, most of the time is spent in memcpy() anyway.
- for (widthc = 0; widthc < xfact; widthc++) {
+ for (widthc = 0; widthc < scaleFactor; widthc++) {
memcpy(dest, &col, 1);
dest++;
}
if (separate_alpha_map) { // Set separate alpha map
- memset(alpha_dest, (isalpha) ? byte_transparent : byte_opaque, xfact);
- alpha_dest += xfact;
+ memset(alpha_dest, (isalpha) ? byte_transparent : byte_opaque, scaleFactor);
+ alpha_dest += scaleFactor;
}
}
// Copies each line. O(n) iterations; again, this could be optimized to O(ln(n)) for very high resolutions,
// but that wouldn't really help that much, as the same amount of data still would have to be transferred.
- for (heightc = 1; heightc < yfact; heightc++) {
+ for (heightc = 1; heightc < scaleFactor; heightc++) {
memcpy(dest, prev_dest, line_width);
dest += line_width;
if (separate_alpha_map) {
@@ -104,8 +103,8 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in
pxm->width = pxm->index_width;
pxm->height = pxm->index_height;
} else {
- pxm->width = pxm->index_width * mode->xfact;
- pxm->height = pxm->index_height * mode->yfact;
+ pxm->width = pxm->index_width * mode->scaleFactor;
+ pxm->height = pxm->index_height * mode->scaleFactor;
}
}
@@ -115,13 +114,13 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) {
pxm->palette->mergeInto(mode->palette);
if (!pxm->data) {
- pxm->data = (byte*)malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height + 1);
+ pxm->data = (byte*)malloc(mode->scaleFactor * mode->scaleFactor * pxm->index_width * pxm->index_height + 1);
// +1: Eases coying on BE machines in 24 bpp packed mode
// Assume that memory, if allocated already, will be sufficient
// Allocate alpha map
if (pxm->colors_nr() < GFX_PIC_COLORS)
- pxm->alpha_map = (byte*)malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height + 1);
+ pxm->alpha_map = (byte*)malloc(mode->scaleFactor * mode->scaleFactor * pxm->index_width * pxm->index_height + 1);
}
_gfx_xlate_pixmap_unfiltered(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX));