diff options
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/gfx_options.h | 63 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_pixmap_scale.cpp | 11 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_res_options.cpp | 140 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_res_options.h | 91 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 136 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 23 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_state_internal.h | 1 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_system.h | 3 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.cpp | 70 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.h | 9 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 11 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 7 |
12 files changed, 18 insertions, 547 deletions
diff --git a/engines/sci/gfx/gfx_options.h b/engines/sci/gfx/gfx_options.h deleted file mode 100644 index 398cb379c9..0000000000 --- a/engines/sci/gfx/gfx_options.h +++ /dev/null @@ -1,63 +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$ - * - */ - - -#ifndef SCI_GFX_GFX_OPTIONS_H -#define SCI_GFX_GFX_OPTIONS_H - -#include "sci/gfx/gfx_resource.h" -#include "sci/gfx/gfx_tools.h" - -// Define this to enable user-defined custom graphics options -#define CUSTOM_GRAPHICS_OPTIONS - -#ifdef CUSTOM_GRAPHICS_OPTIONS -#include "sci/gfx/gfx_res_options.h" -#endif - -namespace Sci { - -/** - * All user options to the rendering pipeline - * - * See note in sci_conf.h for config_entry_t before changing types of - * variables - */ -struct gfx_options_t { -#ifdef CUSTOM_GRAPHICS_OPTIONS - /* SCI0 pic resource options */ - int pic0_unscaled; /* Don't draw scaled SCI0 pics */ - DitherMode pic0_dither_mode; /* Mode to use for pic0 dithering, defined in gfx_resource.h */ - - gfx_brush_mode_t pic0_brush_mode; - gfx_line_mode_t pic0_line_mode; - - gfx_res_fullconf_t res_conf; /* Resource customisation: Per-resource palettes etc. */ -#endif -}; - -} // End of namespace Sci - -#endif // SCI_GFX_GFX_OPTIONS_H diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 5681bdac1c..5b126f71d2 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -99,13 +99,8 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in } } - if (pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX) { - pxm->width = pxm->index_width; - pxm->height = pxm->index_height; - } else { - pxm->width = pxm->index_width * mode->scaleFactor; - pxm->height = pxm->index_height * mode->scaleFactor; - } + pxm->width = pxm->index_width; + pxm->height = pxm->index_height; } @@ -123,7 +118,7 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { 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)); + _gfx_xlate_pixmap_unfiltered(mode, pxm, false); if (pxm->palette) pxm->palette_revision = pxm->palette->getRevision(); diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp deleted file mode 100644 index 8a8637bf48..0000000000 --- a/engines/sci/gfx/gfx_res_options.cpp +++ /dev/null @@ -1,140 +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 "sci/sci.h" -#include "sci/gfx/gfx_system.h" -#include "sci/gfx/gfx_options.h" -#include "sci/gfx/gfx_resmgr.h" - -#ifdef CUSTOM_GRAPHICS_OPTIONS - -namespace Sci { - -static bool matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) { - for (int i = 0; i < nr; i++) - if (patterns[i].min <= val && patterns[i].max >= val) - return true; - - return false; -} - -static bool resource_matches_patternlists(gfx_res_conf_t *conf, int type, int nr, int loop, int cel) { - int loc; - if (conf->patterns_nr && !matches_patternlist(conf->patterns, conf->patterns_nr, nr)) - return false; - - if (type == GFX_RESOURCE_TYPE_CURSOR) - return true; - - /* Otherwise, we must match at least the loop (pic) - ** and, for views, the cel as well */ - loc = conf->patterns_nr; - if (conf->loops_nr && - !matches_patternlist(conf->patterns + loc, - conf->loops_nr, - loop)) - return false; - - if (type != GFX_RESOURCE_TYPE_VIEW) - return true; - - loc += conf->loops_nr; - - if (!conf->cels_nr) - return true; - - return matches_patternlist(conf->patterns + loc, conf->cels_nr, cel); -} - -static gfx_res_conf_t *find_match(gfx_res_conf_t *conflist, int type, int nr, int loop, int cel) { - while (conflist) { - if (resource_matches_patternlists(conflist, type, nr, loop, cel)) - return conflist; - - conflist = conflist->next; - } - - return NULL; -} - -void apply_mod(byte rFactor, byte gFactor, byte bFactor, gfx_pixmap_t *pxm) { - Palette *pal = pxm->palette; - int i, pal_size = pal ? pal->size() : 0; - - // Id the pixmap's palette is shared, duplicate it - if (pal && pal->isShared()) { - pal = pxm->palette->copy(); - pxm->palette->free(); - pxm->palette = pal; - } - - for (i = 0; i < pal_size; i++) { - PaletteEntry c = pal->getColor(i); - c.r = CLIP<int>((c.r * rFactor) >> 4, 0, 255); - c.g = CLIP<int>((c.g * gFactor) >> 4, 0, 255); - c.b = CLIP<int>((c.b * bFactor) >> 4, 0, 255); - pal->setColor(i, c.r, c.g, c.b); - } -} - -int gfx_get_res_config(gfx_res_fullconf_t res_conf, gfx_pixmap_t *pxm) { - int restype = GFXR_RES_TYPE(pxm->ID); - int nr = GFXR_RES_NR(pxm->ID); - int loop = pxm->loop; - int cel = pxm->cel; - - gfx_res_conf_t *conf; - - if (pxm->ID < 0 || restype < 0 || restype >= GFX_RESOURCE_TYPES_NR) - return 1; // Not appropriate - - // Find assignment config, if available - conf = find_match(res_conf.assign[restype], restype, nr, loop, cel); - if (conf) { - // Assign palette - if (pxm->palette) - pxm->palette->free(); - - pxm->palette = new Palette(conf->colors, - conf->colors_nr); - pxm->palette->name = "res"; - } - - // Find mod config, if available - conf = res_conf.mod[restype]; - while (conf) { - conf = find_match(conf, restype, nr, loop, cel); - if (conf) { - apply_mod(conf->rFactor, conf->gFactor, conf->bFactor, pxm); - conf = conf->next; - } - } - - return 0; -} - -} // End of namespace Sci - -#endif diff --git a/engines/sci/gfx/gfx_res_options.h b/engines/sci/gfx/gfx_res_options.h deleted file mode 100644 index 97347d3427..0000000000 --- a/engines/sci/gfx/gfx_res_options.h +++ /dev/null @@ -1,91 +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$ - * - */ - -#ifndef SCI_GFX_GFX_RES_OPTIONS_H -#define SCI_GFX_GFX_RES_OPTIONS_H - -#ifdef CUSTOM_GRAPHICS_OPTIONS - -#include "sci/sci.h" -#include "sci/gfx/gfx_resource.h" -#include "sci/gfx/gfx_resmgr.h" - -namespace Sci { -/** @name Configuration options for per-resource customisations */ -/** @{ */ - -struct gfx_res_pattern_t { - int min, max; -}; - -/** - * GFX resource modifications/ - */ -struct gfx_res_conf_t { - int type; /**< Resource type-- only one allowed */ - - /* If any of the following is 0, it means that there is no restriction. - ** Otherwise, one of the patterns associated with them must match. */ - int patterns_nr; /**< Number of patterns (only 'view' patterns for views) */ - int loops_nr, cels_nr; /**< Number of loop/cel patterns, for views only. - ** For pics, loops_nr identifies the palette. */ - - gfx_res_pattern_t *patterns; - - int colors_nr; - PaletteEntry *colors; - byte rFactor, gFactor, bFactor; - - gfx_res_conf_t *next; -}; - - -struct gfx_res_fullconf_t { - gfx_res_conf_t *assign[GFX_RESOURCE_TYPES_NR]; - gfx_res_conf_t *mod[GFX_RESOURCE_TYPES_NR]; -}; - - -struct gfx_options_t; - -/** - * Configures a graphical pixmap according to config options. - * - * Modifies pxm as considered appropriate by configuration options. Does - * not do anything in colour index mode. - * - * @param[in] res_conf The resource options according to which modifications - * should be performed - * @param[in] pxm The pixmap to configure - * @return 0 on success, non-zero otherwise - */ -int gfx_get_res_config(gfx_res_fullconf_t res_conf, gfx_pixmap_t *pxm); - -/** @} */ -} // End of namespace Sci - -#endif - -#endif // SCI_GFX_GFX_RES_OPTIONS_H diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 9b94ab6a4b..b53aa419fb 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -44,16 +44,13 @@ namespace Sci { -// Invalid hash mode: Used to invalidate modified pics -#define MODE_INVALID -1 - struct param_struct { int args[4]; GfxDriver *driver; }; -GfxResManager::GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette) : - _options(options), _driver(driver), _resMan(resMan), _screen(screen), _palette(palette), +GfxResManager::GfxResManager(GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette) : + _driver(driver), _resMan(resMan), _screen(screen), _palette(palette), _lockCounter(0), _tagLockCounter(0), _staticPalette(0) { gfxr_init_static_palette(); @@ -86,14 +83,8 @@ void GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pi basic_style.line_mode = GFX_LINE_MODE_CORRECT; basic_style.brush_mode = GFX_BRUSH_MODE_SCALED; - -#ifdef CUSTOM_GRAPHICS_OPTIONS - style.line_mode = _options->pic0_line_mode; - style.brush_mode = _options->pic0_brush_mode; -#else style.line_mode = GFX_LINE_MODE_CORRECT; style.brush_mode = GFX_BRUSH_MODE_RANDOM_ELLIPSES; -#endif if (!res || !res->data) error("calculatePic(): pic number %d not found", nr); @@ -122,11 +113,7 @@ void GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pi memcpy(scaled_pic->undithered_buffer, scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer_size); -#ifdef CUSTOM_GRAPHICS_OPTIONS - gfxr_dither_pic0(scaled_pic, _options->pic0_dither_mode); -#else gfxr_dither_pic0(scaled_pic, kDitherNone); -#endif } // Mark default palettes @@ -137,41 +124,6 @@ void GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pi unscaled_pic->visual_map->loop = default_palette; } -int GfxResManager::getOptionsHash(gfx_resource_type_t type) { - switch (type) { - case GFX_RESOURCE_TYPE_VIEW: - // This should never happen - error("getOptionsHash called on a VIEW resource"); - - case GFX_RESOURCE_TYPE_PIC: -#ifdef CUSTOM_GRAPHICS_OPTIONS - if (_resMan->isVGA()) - // NOTE: here, it is assumed that the upper port bound is always 10, but this doesn't seem to matter for the - // generated options hash anyway - return 10; - else - return (_options->pic0_unscaled) ? 0x10000 : - (_options->pic0_dither_mode << 12) | - (_options->pic0_brush_mode << 4) | - (_options->pic0_line_mode); -#else - if (_resMan->isVGA()) - return 10; - else - return 0x10000 | (GFX_BRUSH_MODE_RANDOM_ELLIPSES << 4) | GFX_LINE_MODE_CORRECT; -#endif - - case GFX_RESOURCE_TYPE_FONT: - case GFX_RESOURCE_TYPE_CURSOR: - return 0; - - case GFX_RESOURCE_TYPES_NR: - default: - error("Invalid resource type: %d", type); - return -1; - } -} - #define FREEALL(freecmd, type) \ if (resource->scaled_data.type) \ freecmd(resource->scaled_data.type); \ @@ -299,8 +251,7 @@ void GfxResManager::setStaticPalette(Palette *newPalette) } \ } -static gfxr_pic_t *gfxr_pic_xlate_common(gfx_resource_t *res, int maps, int scaled, int force, gfx_mode_t *mode, - gfx_options_t *options) { +static gfxr_pic_t *gfxr_pic_xlate_common(gfx_resource_t *res, int maps, int scaled, int force, gfx_mode_t *mode) { XLATE_AS_APPROPRIATE(GFX_MASK_VISUAL, visual_map); XLATE_AS_APPROPRIATE(GFX_MASK_PRIORITY, priority_map); @@ -324,27 +275,16 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale gfxr_pic_t *npic = NULL; IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_PIC]; gfx_resource_t *res = NULL; - int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); int need_unscaled = (_driver->getMode()->scaleFactor != 1); - hash |= (flags << 20) | ((default_palette & 0x7) << 28); - res = resMap.contains(num) ? resMap[num] : NULL; - if (!res || res->mode != hash) { + if (!res) { gfxr_pic_t *pic = NULL; gfxr_pic_t *unscaled_pic = NULL; -#ifdef CUSTOM_GRAPHICS_OPTIONS - if (_options->pic0_unscaled) { - need_unscaled = 0; - pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resMan->isVGA()); - } else - pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resMan->isVGA()); -#else need_unscaled = 0; pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resMan->isVGA()); -#endif if (!pic) { error("Failed to allocate scaled pic"); @@ -375,21 +315,13 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale gfxr_free_pic(res->unscaled_data.pic); } - res->mode = hash; res->scaled_data.pic = pic; res->unscaled_data.pic = unscaled_pic; } else { res->lock_sequence_nr = 0; } -#ifdef CUSTOM_GRAPHICS_OPTIONS - npic = gfxr_pic_xlate_common(res, maps, scaled || _options->pic0_unscaled, 0, _driver->getMode(), - _options); -#else - npic = gfxr_pic_xlate_common(res, maps, 1, 0, _driver->getMode(), - _options); -#endif - + npic = gfxr_pic_xlate_common(res, maps, 1, 0, _driver->getMode()); return npic; } @@ -417,44 +349,15 @@ static int get_pic_id(gfx_resource_t *res) { return res->unscaled_data.pic->visual_map->ID; } -static void _gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) { - int xmod = mode->scaleFactor; // Step size horizontally - int ymod = pxm->index_width * mode->scaleFactor; // Vertical step size - int maxpos = pxm->index_width * pxm->index_height; - int pos; - byte *dest = pxm->index_data; - - if (!(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)) - return; // It's not scaled! - - for (pos = 0; pos < maxpos; pos += ymod) { - int c; - - for (c = 0; c < pxm->index_width; c += xmod) - *dest++ = pxm->index_data[pos + c]; - // No overwrite since line and offset readers move much faster (proof by in-duction, trivial - // and left to the reader) - } - - pxm->index_width /= mode->scaleFactor; - pxm->index_height /= mode->scaleFactor; - pxm->flags &= ~GFX_PIXMAP_FLAG_SCALED_INDEX; -} - gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_default_palette, int default_palette) { IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_PIC]; gfxr_pic_t *pic = NULL; gfx_resource_t *res = NULL; - int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); -#ifdef CUSTOM_GRAPHICS_OPTIONS - int need_unscaled = !(_options->pic0_unscaled) && (_driver->getMode()->scaleFactor != 1 || _driver->getMode()->scaleFactor != 1); -#else int need_unscaled = 1; -#endif res = resMap.contains(old_nr) ? resMap[old_nr] : NULL; - if (!res || (res->mode != MODE_INVALID && res->mode != hash)) { + if (!res) { getPic(old_nr, 0, flags, old_default_palette, 1); res = resMap.contains(old_nr) ? resMap[old_nr] : NULL; @@ -465,31 +368,15 @@ gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_d } } -#ifdef CUSTOM_GRAPHICS_OPTIONS - if (_options->pic0_unscaled) // Unscale priority map, if we scaled it earlier -#endif - _gfxr_unscale_pixmap_index_data(res->scaled_data.pic->priority_map, _driver->getMode()); - // The following two operations are needed when returning scaled maps (which is always the case here) res->lock_sequence_nr = 0; calculatePic(res->scaled_data.pic, need_unscaled ? res->unscaled_data.pic : NULL, flags | DRAWPIC01_FLAG_OVERLAID_PIC, default_palette, new_nr); - res->mode = MODE_INVALID; // Invalidate - -#ifdef CUSTOM_GRAPHICS_OPTIONS - if (_options->pic0_unscaled) // Scale priority map again, if needed -#endif - res->scaled_data.pic->priority_map = gfx_pixmap_scale_index_data(res->scaled_data.pic->priority_map, _driver->getMode()); - { int old_ID = get_pic_id(res); set_pic_id(res, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, new_nr)); // To ensure that our graphical translation options work properly -#ifdef CUSTOM_GRAPHICS_OPTIONS - pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _driver->getMode(), _options); -#else - pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _driver->getMode(), _options); -#endif + pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _driver->getMode()); set_pic_id(res, old_ID); } @@ -506,7 +393,7 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { gfxr_loop_t *loop_data = NULL; gfx_pixmap_t *cel_data = NULL; - if (!res || res->mode != hash) { + if (!res) { // Wrapper code for the new view decoder view = (gfxr_view_t *)malloc(sizeof(gfxr_view_t)); @@ -575,13 +462,11 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { res->scaled_data.view = NULL; res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); res->lock_sequence_nr = _tagLockCounter; - res->mode = hash; resMap[nr] = res; } else { gfxr_free_view(res->unscaled_data.view); } - res->mode = hash; res->unscaled_data.view = view; } else { @@ -595,7 +480,6 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { cel_data = loop_data->cels[*cel]; if (!cel_data->data) { - gfx_get_res_config(_options->res_conf, cel_data); gfx_xlate_pixmap(cel_data, _driver->getMode()); } @@ -605,7 +489,6 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_FONT]; gfx_resource_t *res = NULL; - int hash = getOptionsHash(GFX_RESOURCE_TYPE_FONT); // Workaround: lsl1sci mixes its own internal fonts with the global // SCI ones, so we translate them here, by removing their extra bits @@ -614,7 +497,7 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { res = resMap.contains(num) ? resMap[num] : NULL; - if (!res || res->mode != hash) { + if (!res) { Resource *fontRes = _resMan->findResource(ResourceId(kResourceTypeFont, num), 0); if (!fontRes || !fontRes->data) return NULL; @@ -626,7 +509,6 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { res->scaled_data.font = NULL; res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_FONT, num); res->lock_sequence_nr = _tagLockCounter; - res->mode = hash; resMap[num] = res; } else { gfxr_free_font(res->unscaled_data.font); diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 1f03af0818..b6dea1a8e2 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -64,7 +64,6 @@ enum gfx_resource_type_t { struct gfx_resource_t { int ID; /**< Resource ID */ int lock_sequence_nr; /**< See description of lock_counter in GfxResManager */ - int mode; /**< A mode type hash */ /** Scaled pic */ union { @@ -92,28 +91,9 @@ typedef Common::HashMap<int, gfx_resource_t *> IntResMap; /** Graphics resource manager */ class GfxResManager { public: - GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette); + GfxResManager(GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette); ~GfxResManager(); - /** - * Calculates a unique hash value for the specified options/type - * setup. - * - * Covering more entries than relevant may slow down the system when - * options are changed, while covering less may result in invalid - * cached data being used. - * Only positive values may be returned, as negative values are used - * internally by the generic resource manager code. - * Also, only the lower 20 bits are available to the interpreter. - * (Yes, this isn't really a "hash" in the traditional sense...) - * - * @param[in] type The type the hash is to be generated for - * @return A hash over the values of the options entries, - * covering entries iff they are relevant for the - * specified type. - */ - int getOptionsHash(gfx_resource_type_t type); - /** * 'Tags' all resources for deletion. @@ -284,7 +264,6 @@ public: } private: - gfx_options_t *_options; GfxDriver *_driver; Palette *_staticPalette; int _lockCounter; /**< Global lock counter; increased for each new diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h index aeb3b05cd4..5334971e23 100644 --- a/engines/sci/gfx/gfx_state_internal.h +++ b/engines/sci/gfx/gfx_state_internal.h @@ -28,7 +28,6 @@ #include "sci/engine/vm.h" #include "sci/gfx/gfx_tools.h" -#include "sci/gfx/gfx_options.h" #include "sci/gfx/operations.h" #include "sci/gfx/gfx_resmgr.h" #include "sci/gfx/gfx_system.h" diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 7dd779ca01..31b799b8fe 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -130,9 +130,6 @@ extern rect_t gfx_rect_fullscreen; #define GFX_PIC_COLORS 256 -#define GFX_PIXMAP_FLAG_SCALED_INDEX (1<<0) /* Index data is scaled already */ -#define GFX_PIXMAP_FLAG_INSTALLED (1<<2) /* Pixmap has been registered */ - #define GFX_PIXMAP_COLOR_KEY_NONE -1 /* No transpacency colour key */ #define GFX_CURSOR_TRANSPARENT 255 // Cursor colour key diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index aa98d44332..eef89ded1b 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -144,13 +144,8 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { return pixmap; } - if (pixmap->flags & GFX_PIXMAP_FLAG_SCALED_INDEX) { - pixmap->width = pixmap->index_width; - pixmap->height = pixmap->index_height; - } else { - pixmap->width = pixmap->index_width * mode->scaleFactor; - pixmap->height = pixmap->index_height * mode->scaleFactor; - } + pixmap->width = pixmap->index_width; + pixmap->height = pixmap->index_height; size = pixmap->width * pixmap->height; if (!size) @@ -160,65 +155,4 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { return pixmap; } -gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { - byte *old_data, *new_data, *initial_new_data; - byte *linestart; - int linewidth; - int xl, yl; - int i, yc; - int xfact = mode->scaleFactor; - int yfact = mode->scaleFactor; - - if (xfact == 1 && yfact == 1) - return pixmap; - - if (!pixmap) - return NULL; - - if (pixmap->flags & GFX_PIXMAP_FLAG_SCALED_INDEX) - return pixmap; // Already done - - old_data = pixmap->index_data; - - if (!old_data) { - error("Attempt to scale index data without index data!\n"); - return pixmap; - } - - xl = pixmap->index_width; - yl = pixmap->index_height; - linewidth = xfact * xl; - initial_new_data = new_data = (byte *)malloc(linewidth * yfact * yl); - - for (yc = 0; yc < yl; yc++) { - - linestart = new_data; - - if (xfact == 1) { - memcpy(new_data, old_data, linewidth); - new_data += linewidth; - old_data += linewidth; - } else for (i = 0; i < xl; i++) { - byte fillc = *old_data++; - memset(new_data, fillc, xfact); - new_data += xfact; - } - - for (i = 1; i < yfact; i++) { - memcpy(new_data, linestart, linewidth); - new_data += linewidth; - } - } - - free(pixmap->index_data); - pixmap->index_data = initial_new_data; - - pixmap->flags |= GFX_PIXMAP_FLAG_SCALED_INDEX; - - pixmap->index_width = linewidth; - pixmap->index_height *= yfact; - - return pixmap; -} - } // End of namespace Sci diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h index 57a70f50ad..2d15b51022 100644 --- a/engines/sci/gfx/gfx_tools.h +++ b/engines/sci/gfx/gfx_tools.h @@ -180,15 +180,6 @@ void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, byte *priority_dest, int priority_line_width, int priority_skip); -/** - * Scales the index data associated with a pixmap - * - * @param[in] pixmap The pixmap whose index data should be scaled - * @param[in] mode The mode to scale it to - * @return The pixmap - */ -gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode); - /** @} */ } // End of namespace Sci diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 0a51004f1d..9edba13ae8 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -354,12 +354,9 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) { (*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR); } -void gfxop_init(GfxState *state, - gfx_options_t *options, ResourceManager *resMan, +void gfxop_init(GfxState *state, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette, int scaleFactor) { - state->options = options; state->visible_map = GFX_MASK_VISUAL; - state->options = options; state->disable_dirty = 0; state->_events.clear(); state->pic = state->pic_unscaled = NULL; @@ -370,7 +367,7 @@ void gfxop_init(GfxState *state, state->driver = new GfxDriver(screen, scaleFactor); - state->gfxResMan = new GfxResManager(state->options, state->driver, resMan, screen, palette); + state->gfxResMan = new GfxResManager(state->driver, resMan, screen, palette); gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200)); @@ -1382,10 +1379,6 @@ static void _gfxop_set_pic(GfxState *state) { _gfxop_install_pixmap(state->driver, state->pic->visual_map); } -#ifdef CUSTOM_GRAPHICS_OPTIONS - if (state->options->pic0_unscaled) -#endif - state->pic->priority_map = gfx_pixmap_scale_index_data(state->pic->priority_map, state->driver->getMode()); state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); } diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 0255130b37..6e6ff938e5 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -30,7 +30,6 @@ #include "sci/gfx/gfx_resmgr.h" #include "sci/gfx/gfx_tools.h" -#include "sci/gfx/gfx_options.h" #include "sci/gfx/gfx_system.h" #include "sci/uinput.h" @@ -89,8 +88,6 @@ typedef Common::List<rect_t> DirtyRectList; struct GfxState { - gfx_options_t *options; - rect_t clip_zone_unscaled; /**< The current UNSCALED clipping zone */ rect_t clip_zone; /**< The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */ @@ -131,11 +128,9 @@ struct GfxState { * @param[in] state The state to initialize * @param[in] scaleFactor Scale factor * @param[in] mode Graphics mode to use - * @param[in] options Rendering options * @param[in] resMan Resource manager to use */ -void gfxop_init(GfxState *state, - gfx_options_t *options, ResourceManager *resMan, +void gfxop_init(GfxState *state, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette, int scaleFactor = 1); /** |