diff options
author | Filippos Karapetis | 2009-03-22 23:11:43 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-03-22 23:11:43 +0000 |
commit | e3f9acc3e6c66ab42e6e992536c933069771c99e (patch) | |
tree | be078568570a92d40052a5149c382128684062ba /engines/sci | |
parent | 052a6ea1f904079f85854cac9d255b7934130b84 (diff) | |
download | scummvm-rg350-e3f9acc3e6c66ab42e6e992536c933069771c99e.tar.gz scummvm-rg350-e3f9acc3e6c66ab42e6e992536c933069771c99e.tar.bz2 scummvm-rg350-e3f9acc3e6c66ab42e6e992536c933069771c99e.zip |
Further objectification of the graphics resource manager
svn-id: r39621
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/game.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 38 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 13 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 182 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 62 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 113 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 4 |
7 files changed, 160 insertions, 264 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 6f2cf4b008..564bbf6598 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -125,22 +125,16 @@ int _reset_graphics_input(EngineState *s) { // Check for Amiga palette file. Common::File file; if (file.open("spal")) { - if (s->gfx_state->resstate->static_palette) - s->gfx_state->resstate->static_palette->free(); - s->gfx_state->resstate->static_palette = gfxr_read_pal1_amiga(file); - s->gfx_state->resstate->static_palette->name = "static palette"; + s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal1_amiga(file)); file.close(); _sci1_alloc_system_colors(s); } else { resource = s->resmgr->findResource(kResourceTypePalette, 999, 1); if (resource) { - if (s->gfx_state->resstate->static_palette) - s->gfx_state->resstate->static_palette->free(); if (s->version < SCI_VERSION(1, 001, 000)) - s->gfx_state->resstate->static_palette = gfxr_read_pal1(999, resource->data, resource->size); + s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal1(999, resource->data, resource->size)); else - s->gfx_state->resstate->static_palette = gfxr_read_pal11(999, resource->data, resource->size); - s->gfx_state->resstate->static_palette->name = "static palette"; + s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal11(999, resource->data, resource->size)); _sci1_alloc_system_colors(s); s->resmgr->unlockResource(resource, 999, kResourceTypePalette); } else { diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index dbda9bcd15..b4f00c77e6 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -260,28 +260,16 @@ void graph_restore_box(EngineState *s, reg_t handle) { kfree(s, handle); } -#if 0 -#define KERNEL_COLOR_PALETTE s->gfx_state->pic->visual_map->colors -#define KERNEL_COLORS_NR s->gfx_state->pic->visual_map->colors_nr -#else -#define KERNEL_COLOR_PALETTE (s->gfx_state->resstate->static_palette) -#define KERNEL_COLORS_NR (s->gfx_state->resstate->static_palette ? s->gfx_state->resstate->static_palette->size() : 0) -#endif - -//static gfx_pixmap_color_t white = {GFX_COLOR_INDEX_UNMAPPED, 255, 255, 255}; - -//PaletteEntry white(255, 255, 255); - PaletteEntry get_pic_color(EngineState *s, int color) { if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA) return s->ega_colors[color].visual; if (color == 255) return PaletteEntry(255,255,255); - else if (color < (int)KERNEL_COLORS_NR) - return KERNEL_COLOR_PALETTE->getColor(color); + else if (color < s->gfx_state->gfxResMan->getNumberOfColors()) + return s->gfx_state->gfxResMan->getStaticPalette()->getColor(color); else { - SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); + SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, s->gfx_state->gfxResMan->getNumberOfColors()); BREAKPOINT(); return PaletteEntry(0,0,0); } @@ -873,11 +861,7 @@ reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv) { gfxr_view_t *res = NULL; gfx_pixmap_t *pxm = NULL; - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate); - res = _gfx->getView(view, &loop, &cel, 0); - delete _gfx; + res = s->gfx_state->gfxResMan->getView(view, &loop, &cel, 0); if (!res) { GFXWARN("Attempt to get cel parameters for invalid view %d\n", view); @@ -1278,10 +1262,10 @@ reg_t kPalette(EngineState *s, int funct_nr, int argc, reg_t *argv) { int i, delta, bestindex = -1, bestdelta = 200000; - for (i = 0; i < (int)KERNEL_COLORS_NR; i++) { - int dr = abs(KERNEL_COLOR_PALETTE->getColor(i).r - r); - int dg = abs(KERNEL_COLOR_PALETTE->getColor(i).g - g); - int db = abs(KERNEL_COLOR_PALETTE->getColor(i).b - b); + for (i = 0; i < s->gfx_state->gfxResMan->getNumberOfColors(); i++) { + int dr = abs(s->gfx_state->gfxResMan->getStaticPalette()->getColor(i).r - r); + int dg = abs(s->gfx_state->gfxResMan->getStaticPalette()->getColor(i).g - g); + int db = abs(s->gfx_state->gfxResMan->getStaticPalette()->getColor(i).b - b); delta = dr * dr + dg * dg + db * db; @@ -2356,11 +2340,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { // FIXME: Should really only invalidate all loaded pic resources here; // this is overkill - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate); - _gfx->freeAllResources(); - delete _gfx; + s->gfx_state->gfxResMan->freeAllResources(); break; } diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index c6b1078686..69d823a369 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -864,10 +864,6 @@ int c_viewinfo(EngineState *s) { else { sciprintf("has %d loops:\n", loops); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate); - for (i = 0; i < loops; i++) { int j, cels; @@ -878,11 +874,10 @@ int c_viewinfo(EngineState *s) { Common::Point mod; if (con_can_handle_pixmaps()) { - view_pixmaps = _gfx->getView(view, &i, &j, palette); + view_pixmaps = s->gfx_state->gfxResMan->getView(view, &i, &j, palette); con_insert_pixmap(gfx_clone_pixmap(view_pixmaps->loops[i].cels[j], s->gfx_state->driver->mode)); } - delete _gfx; gfxop_get_cel_parameters(s->gfx_state, view, i, j, &width, &height, &mod); sciprintf(" cel %d: size %dx%d, adj+(%d,%d)\n", j, width, height, mod.x, mod.y); @@ -2016,11 +2011,7 @@ static int c_gfx_flush_resources(EngineState *s) { gfxop_set_pointer_cursor(s->gfx_state, GFXOP_NO_POINTER); sciprintf("Flushing resources...\n"); s->visual->widfree(GFXW(s->visual)); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate); - _gfx->freeAllResources(); - delete _gfx; + s->gfx_state->gfxResMan->freeAllResources(); s->visual = NULL; return 0; diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 890e5842d2..6ab69e6ecf 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -49,53 +49,43 @@ struct param_struct { }; #define DRAW_PIC01(pic, picStyle, isSci1) \ - gfxr_draw_pic01((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, (isSci1), state->static_palette); + gfxr_draw_pic01((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, (isSci1), _staticPalette); #define DRAW_PIC11(pic, picStyle) \ - gfxr_draw_pic11((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, state->static_palette); - -/* Calculate a picture -** Parameters: (gfx_resstate_t *) state: The resource state, containing options and version information -** (gfxr_pic_t *) scaled_pic: The pic structure that is to be written to -** (gfxr_pic_t *) unscaled_pic: The pic structure the unscaled pic is to be written to, -** or NULL if it isn't needed. -** (int) flags: Pic drawing flags (interpreter dependant) -** (int) default_palette: The default palette to use for pic drawing (interpreter dependant) -** (int) nr: pic resource number -** Returns : (int) GFX_ERROR if the resource could not be found, GFX_OK otherwise -*/ -int calculatePic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr) { - Resource *res = state->resManager->findResource(kResourceTypePic, nr, 0); + gfxr_draw_pic11((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, _staticPalette); + +int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr) { + Resource *res = _resManager->findResource(kResourceTypePic, nr, 0); int need_unscaled = unscaled_pic != NULL; gfxr_pic0_params_t style, basic_style; basic_style.line_mode = GFX_LINE_MODE_CORRECT; basic_style.brush_mode = GFX_BRUSH_MODE_SCALED; - basic_style.pic_port_bounds = state->options->pic_port_bounds; + basic_style.pic_port_bounds = _options->pic_port_bounds; - style.line_mode = state->options->pic0_line_mode; - style.brush_mode = state->options->pic0_brush_mode; - style.pic_port_bounds = state->options->pic_port_bounds; + style.line_mode = _options->pic0_line_mode; + style.brush_mode = _options->pic0_brush_mode; + style.pic_port_bounds = _options->pic_port_bounds; if (!res || !res->data) return GFX_ERROR; if (need_unscaled) { - if (state->version == SCI_VERSION_1_1) + if (_version == SCI_VERSION_1_1) DRAW_PIC11(unscaled_pic, &basic_style) else - DRAW_PIC01(unscaled_pic, &basic_style, state->version >= SCI_VERSION_01_VGA) + DRAW_PIC01(unscaled_pic, &basic_style, _version >= SCI_VERSION_01_VGA) } if (scaled_pic && scaled_pic->undithered_buffer) memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size); - if (state->version == SCI_VERSION_1_1) + if (_version == SCI_VERSION_1_1) DRAW_PIC11(scaled_pic, &style) else - DRAW_PIC01(scaled_pic, &style, state->version >= SCI_VERSION_01_VGA) + DRAW_PIC01(scaled_pic, &style, _version >= SCI_VERSION_01_VGA) - if (state->version < SCI_VERSION_01_VGA) { + if (_version < SCI_VERSION_01_VGA) { if (need_unscaled) gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic); @@ -104,7 +94,7 @@ int calculatePic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unsc memcpy(scaled_pic->undithered_buffer, scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer_size); - gfxr_dither_pic0(scaled_pic, state->options->pic0_dither_mode, state->options->pic0_dither_pattern); + gfxr_dither_pic0(scaled_pic, _options->pic0_dither_mode, _options->pic0_dither_pattern); } // Mark default palettes @@ -117,20 +107,6 @@ int calculatePic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unsc return GFX_OK; } -gfx_resstate_t *gfxr_new_resource_manager(int version, gfx_options_t *options, gfx_driver_t *driver, ResourceManager *resManager) { - gfx_resstate_t *state = new gfx_resstate_t(); - - state->version = version; - state->options = options; - state->driver = driver; - state->resManager = resManager; - state->static_palette = 0; - - state->tag_lock_counter = state->lock_counter = 0; - - return state; -} - int GfxResManager::getOptionsHash(gfx_resource_type_t type) { switch (type) { case GFX_RESOURCE_TYPE_VIEW: @@ -138,12 +114,12 @@ int GfxResManager::getOptionsHash(gfx_resource_type_t type) { error("getOptionsHash called on a VIEW resource"); case GFX_RESOURCE_TYPE_PIC: - if (_state->version >= SCI_VERSION_01_VGA) - return _state->options->pic_port_bounds.y; + if (_version >= SCI_VERSION_01_VGA) + return _options->pic_port_bounds.y; else - return (_state->options->pic0_unscaled) ? 0x10000 : (_state->options->pic0_dither_mode << 12) - | (_state->options->pic0_dither_pattern << 8) | (_state->options->pic0_brush_mode << 4) - | (_state->options->pic0_line_mode); + return (_options->pic0_unscaled) ? 0x10000 : (_options->pic0_dither_mode << 12) + | (_options->pic0_dither_pattern << 8) | (_options->pic0_brush_mode << 4) + | (_options->pic0_line_mode); case GFX_RESOURCE_TYPE_FONT: case GFX_RESOURCE_TYPE_CURSOR: @@ -195,7 +171,7 @@ void gfxr_free_resource(gfx_resource_t *resource, int type) { void GfxResManager::freeAllResources() { for (int type = 0; type < GFX_RESOURCE_TYPES_NR; ++type) { - for (IntResMap::iterator iter = _state->_resourceMaps[type].begin(); iter != _state->_resourceMaps[type].end(); ++iter) { + for (IntResMap::iterator iter = _resourceMaps[type].begin(); iter != _resourceMaps[type].end(); ++iter) { gfxr_free_resource(iter->_value, type); iter->_value = 0; } @@ -204,7 +180,7 @@ void GfxResManager::freeAllResources() { void GfxResManager::freeResManager() { freeAllResources(); - delete _state; + _lockCounter = _tagLockCounter = 0; } void GfxResManager::freeTaggedResources() { @@ -212,10 +188,10 @@ void GfxResManager::freeTaggedResources() { IntResMap::iterator iter; int type; - const int tmp = _state->tag_lock_counter; + const int tmp = _tagLockCounter; type = GFX_RESOURCE_TYPE_VIEW; - for (iter = _state->_resourceMaps[type].begin(); iter != _state->_resourceMaps[type].end(); ++iter) { + for (iter = _resourceMaps[type].begin(); iter != _resourceMaps[type].end(); ++iter) { gfx_resource_t *resource = iter->_value; if (resource) { @@ -229,7 +205,7 @@ void GfxResManager::freeTaggedResources() { } type = GFX_RESOURCE_TYPE_PIC; - for (iter = _state->_resourceMaps[type].begin(); iter != _state->_resourceMaps[type].end(); ++iter) { + for (iter = _resourceMaps[type].begin(); iter != _resourceMaps[type].end(); ++iter) { gfx_resource_t *resource = iter->_value; if (resource) { @@ -242,7 +218,7 @@ void GfxResManager::freeTaggedResources() { } } - _state->tag_lock_counter = 0; + _tagLockCounter = 0; } #define XLATE_AS_APPROPRIATE(key, entry) \ @@ -273,11 +249,11 @@ static gfxr_pic_t *gfxr_pic_xlate_common(gfx_resource_t *res, int maps, int scal gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_palette, bool scaled) { gfxr_pic_t *npic = NULL; - IntResMap &resMap = _state->_resourceMaps[GFX_RESOURCE_TYPE_PIC]; + IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_PIC]; gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); int must_post_process_pic = 0; - int need_unscaled = (_state->driver->mode->xfact != 1 || _state->driver->mode->yfact != 1); + int need_unscaled = (_driver->mode->xfact != 1 || _driver->mode->yfact != 1); hash |= (flags << 20) | ((default_palette & 0x7) << 28); @@ -287,11 +263,11 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale gfxr_pic_t *pic; gfxr_pic_t *unscaled_pic = NULL; - if (_state->options->pic0_unscaled) { + if (_options->pic0_unscaled) { need_unscaled = 0; - pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _state->version >= SCI_VERSION_01_VGA); + pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); } else - pic = gfxr_init_pic(_state->driver->mode, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _state->version >= SCI_VERSION_01_VGA); + pic = gfxr_init_pic(_driver->mode, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); if (!pic) { GFXERROR("Failed to allocate scaled pic!\n"); return NULL; @@ -300,14 +276,14 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); if (need_unscaled) { - unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _state->version >= SCI_VERSION_01_VGA); + unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); if (!unscaled_pic) { GFXERROR("Failed to allocate unscaled pic!\n"); return NULL; } gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); } - if (calculatePic(_state, pic, unscaled_pic, flags, default_palette, num)) { + if (calculatePic(pic, unscaled_pic, flags, default_palette, num)) { gfxr_free_pic(pic); if (unscaled_pic) gfxr_free_pic(unscaled_pic); @@ -316,7 +292,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale if (!res) { res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t)); res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num); - res->lock_sequence_nr = _state->options->buffer_pics_nr; + res->lock_sequence_nr = _options->buffer_pics_nr; resMap[num] = res; } else { gfxr_free_pic(res->scaled_data.pic); @@ -328,18 +304,18 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale res->scaled_data.pic = pic; res->unscaled_data.pic = unscaled_pic; } else { - res->lock_sequence_nr = _state->options->buffer_pics_nr; // Update lock counter + res->lock_sequence_nr = _options->buffer_pics_nr; // Update lock counter } must_post_process_pic = res->scaled_data.pic->visual_map->data == NULL; // If the pic was only just drawn, we'll have to endianness-adjust it now - npic = gfxr_pic_xlate_common(res, maps, scaled || _state->options->pic0_unscaled, 0, _state->driver->mode, - _state->options->pic_xlate_filter, 0, _state->options); + npic = gfxr_pic_xlate_common(res, maps, scaled || _options->pic0_unscaled, 0, _driver->mode, + _options->pic_xlate_filter, 0, _options); if (must_post_process_pic) { - gfxr_endianness_adjust(npic->visual_map, _state->driver->mode); + gfxr_endianness_adjust(npic->visual_map, _driver->mode); } return npic; @@ -393,20 +369,16 @@ static void _gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) } gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_default_palette, int default_palette) { - IntResMap &resMap = _state->_resourceMaps[GFX_RESOURCE_TYPE_PIC]; + IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_PIC]; gfxr_pic_t *pic = NULL; gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); - int need_unscaled = !(_state->options->pic0_unscaled) && (_state->driver->mode->xfact != 1 || _state->driver->mode->yfact != 1); + int need_unscaled = !(_options->pic0_unscaled) && (_driver->mode->xfact != 1 || _driver->mode->yfact != 1); res = resMap.contains(old_nr) ? resMap[old_nr] : NULL; if (!res || (res->mode != MODE_INVALID && res->mode != hash)) { - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(_state); - _gfx->getPic(old_nr, 0, flags, old_default_palette, 1); - delete _gfx; + getPic(old_nr, 0, flags, old_default_palette, 1); res = resMap.contains(old_nr) ? resMap[old_nr] : NULL; @@ -416,22 +388,22 @@ gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_d } } - if (_state->options->pic0_unscaled) // Unscale priority map, if we scaled it earlier - _gfxr_unscale_pixmap_index_data(res->scaled_data.pic->priority_map, _state->driver->mode); + if (_options->pic0_unscaled) // Unscale priority map, if we scaled it earlier + _gfxr_unscale_pixmap_index_data(res->scaled_data.pic->priority_map, _driver->mode); // The following two operations are needed when returning scaled maps (which is always the case here) - res->lock_sequence_nr = _state->options->buffer_pics_nr; - calculatePic(_state, res->scaled_data.pic, need_unscaled ? res->unscaled_data.pic : NULL, + res->lock_sequence_nr = _options->buffer_pics_nr; + 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 - if (_state->options->pic0_unscaled) // Scale priority map again, if needed - res->scaled_data.pic->priority_map = gfx_pixmap_scale_index_data(res->scaled_data.pic->priority_map, _state->driver->mode); + if (_options->pic0_unscaled) // Scale priority map again, if needed + res->scaled_data.pic->priority_map = gfx_pixmap_scale_index_data(res->scaled_data.pic->priority_map, _driver->mode); { 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 optoins work properly - pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _state->driver->mode, _state->options->pic_xlate_filter, 1, _state->options); + pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _driver->mode, _options->pic_xlate_filter, 1, _options); set_pic_id(res, old_ID); } @@ -441,7 +413,7 @@ gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_d gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size); gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { - IntResMap &resMap = _state->_resourceMaps[GFX_RESOURCE_TYPE_VIEW]; + IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_VIEW]; gfx_resource_t *res = NULL; int hash = palette; gfxr_view_t *view = NULL; @@ -451,32 +423,32 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { res = resMap.contains(nr) ? resMap[nr] : NULL; if (!res || res->mode != hash) { - Resource *viewRes = _state->resManager->findResource(kResourceTypeView, nr, 0); + Resource *viewRes = _resManager->findResource(kResourceTypeView, nr, 0); if (!viewRes || !viewRes->data) return NULL; int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); - if (_state->version < SCI_VERSION_01) + if (_version < SCI_VERSION_01) view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, -1); - else if (_state->version == SCI_VERSION_01) + else if (_version == SCI_VERSION_01) view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, palette); - else if (_state->version >= SCI_VERSION_01_VGA && _state->version <= SCI_VERSION_1_LATE) - view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, _state->static_palette); - else if (_state->version >= SCI_VERSION_1_1) + else if (_version >= SCI_VERSION_01_VGA && _version <= SCI_VERSION_1_LATE) + view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, _staticPalette); + else if (_version >= SCI_VERSION_1_1) view = gfxr_draw_view11(resid, viewRes->data, viewRes->size); - if (_state->version >= SCI_VERSION_01_VGA) { + if (_version >= SCI_VERSION_01_VGA) { if (!view->palette) { - view->palette = new Palette(_state->static_palette->size()); + view->palette = new Palette(_staticPalette->size()); view->palette->name = "interpreter_get_view"; } // Palettize view - for (unsigned i = 0; i < MIN(view->palette->size(), _state->static_palette->size()); i++) { + for (unsigned i = 0; i < MIN(view->palette->size(), _staticPalette->size()); i++) { const PaletteEntry& vc = view->palette->getColor(i); if (vc.r == 0 && vc.g == 0 && vc.b == 0) { - const PaletteEntry& sc = _state->static_palette->getColor(i); + const PaletteEntry& sc = _staticPalette->getColor(i); view->palette->setColor(i, sc.r, sc.g, sc.b); } } @@ -487,7 +459,7 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t)); res->scaled_data.view = NULL; res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); - res->lock_sequence_nr = _state->tag_lock_counter; + res->lock_sequence_nr = _tagLockCounter; res->mode = hash; resMap[nr] = res; } else { @@ -498,7 +470,7 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { res->unscaled_data.view = view; } else { - res->lock_sequence_nr = _state->tag_lock_counter; // Update lock counter + res->lock_sequence_nr = _tagLockCounter; // Update lock counter view = res->unscaled_data.view; } @@ -529,23 +501,23 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { } if (!cel_data->data) { - gfx_get_res_config(_state->options, cel_data); - gfx_xlate_pixmap(cel_data, _state->driver->mode, _state->options->view_xlate_filter); - gfxr_endianness_adjust(cel_data, _state->driver->mode); + gfx_get_res_config(_options, cel_data); + gfx_xlate_pixmap(cel_data, _driver->mode, _options->view_xlate_filter); + gfxr_endianness_adjust(cel_data, _driver->mode); } return view; } gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { - IntResMap &resMap = _state->_resourceMaps[GFX_RESOURCE_TYPE_FONT]; + IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_FONT]; gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_FONT); res = resMap.contains(num) ? resMap[num] : NULL; if (!res || res->mode != hash) { - Resource *fontRes = _state->resManager->findResource(kResourceTypeFont, num, 0); + Resource *fontRes = _resManager->findResource(kResourceTypeFont, num, 0); if (!fontRes || !fontRes->data) return NULL; @@ -555,7 +527,7 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t)); res->scaled_data.font = NULL; res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_FONT, num); - res->lock_sequence_nr = _state->tag_lock_counter; + res->lock_sequence_nr = _tagLockCounter; res->mode = hash; resMap[num] = res; } else { @@ -566,7 +538,7 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { return font; } else { - res->lock_sequence_nr = _state->tag_lock_counter; // Update lock counter + res->lock_sequence_nr = _tagLockCounter; // Update lock counter if (res->unscaled_data.pointer) return res->unscaled_data.font; else @@ -575,24 +547,24 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { } gfx_pixmap_t *GfxResManager::getCursor(int num) { - IntResMap &resMap = _state->_resourceMaps[GFX_RESOURCE_TYPE_CURSOR]; + IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_CURSOR]; gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_CURSOR); res = resMap.contains(num) ? resMap[num] : NULL; if (!res || res->mode != hash) { - Resource *cursorRes = _state->resManager->findResource(kResourceTypeCursor, num, 0); + Resource *cursorRes = _resManager->findResource(kResourceTypeCursor, num, 0); if (!cursorRes || !cursorRes->data) return NULL; - if (_state->version >= SCI_VERSION_1_1) { + if (_version >= SCI_VERSION_1_1) { GFXWARN("Attempt to retrieve cursor in SCI1.1 or later\n"); return NULL; } gfx_pixmap_t *cursor = gfxr_draw_cursor(GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, num), - cursorRes->data, cursorRes->size, _state->version != SCI_VERSION_0); + cursorRes->data, cursorRes->size, _version != SCI_VERSION_0); if (!cursor) return NULL; @@ -601,21 +573,21 @@ gfx_pixmap_t *GfxResManager::getCursor(int num) { res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t)); res->scaled_data.pointer = NULL; res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, num); - res->lock_sequence_nr = _state->tag_lock_counter; + res->lock_sequence_nr = _tagLockCounter; res->mode = hash; resMap[num] = res; } else { gfx_free_pixmap(res->unscaled_data.pointer); } - gfx_get_res_config(_state->options, cursor); - gfx_xlate_pixmap(cursor, _state->driver->mode, _state->options->cursor_xlate_filter); - gfxr_endianness_adjust(cursor, _state->driver->mode); + gfx_get_res_config(_options, cursor); + gfx_xlate_pixmap(cursor, _driver->mode, _options->cursor_xlate_filter); + gfxr_endianness_adjust(cursor, _driver->mode); res->unscaled_data.pointer = cursor; return cursor; } else { - res->lock_sequence_nr = _state->tag_lock_counter; // Update lock counter + res->lock_sequence_nr = _tagLockCounter; // Update lock counter return res->unscaled_data.pointer; } } diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index d54163ae01..6d303dfaf4 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -102,7 +102,9 @@ struct gfx_resstate_t { class GfxResManager { public: - GfxResManager(gfx_resstate_t *state) : _state(state) {} + GfxResManager(int version, gfx_options_t *options, gfx_driver_t *driver, Palette *staticPalette, ResourceManager *resManager) : + _version(version), _options(options), _driver(driver), _resManager(resManager), + _staticPalette(staticPalette), _lockCounter(0), _tagLockCounter(0) {} ~GfxResManager() {} @@ -125,7 +127,7 @@ public: ** Returns : (void) ** Tagged resources are untagged if they are referenced. */ - void tagResources() { (_state->tag_lock_counter)++; } + void tagResources() { _tagLockCounter++; } /* Retreives an SCI0/SCI01 mouse cursor @@ -194,12 +196,23 @@ public: */ gfxr_pic_t *addToPic(int old_nr, int new_nr, int flags, int old_default_palette, int default_palette); + /* Calculate a picture + ** Parameters: (gfx_resstate_t *) state: The resource state, containing options and version information + ** (gfxr_pic_t *) scaled_pic: The pic structure that is to be written to + ** (gfxr_pic_t *) unscaled_pic: The pic structure the unscaled pic is to be written to, + ** or NULL if it isn't needed. + ** (int) flags: Pic drawing flags (interpreter dependant) + ** (int) default_palette: The default palette to use for pic drawing (interpreter dependant) + ** (int) nr: pic resource number + ** Returns : (int) GFX_ERROR if the resource could not be found, GFX_OK otherwise + */ + int calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr); /* Determines whether support for pointers with more than two colors is required ** Returns : (bool) false if no support for multi-colored pointers is required, true ** otherwise */ - bool multicoloredPointers() { return _state->version > SCI_VERSION_1; } + bool multicoloredPointers() { return _version > SCI_VERSION_1; } /* Frees all resources currently allocated @@ -227,24 +240,35 @@ public: */ void freeResManager(); -private: - gfx_resstate_t *_state; -}; + Palette *getStaticPalette() { return _staticPalette; } + + void setStaticPalette(Palette *newPalette) { + freeStaticPalette(); + _staticPalette = newPalette; + _staticPalette->name = "static palette"; + } + + void freeStaticPalette() { + if (_staticPalette) + _staticPalette->free(); + } + + int getNumberOfColors() { return _staticPalette ? _staticPalette->size() : 0; } +private: + int _version; + gfx_options_t *_options; + gfx_driver_t *_driver; + Palette *_staticPalette; + int _lockCounter; /* Global lock counter; increased for each new resource allocated. + ** The newly allocated resource will then be assigned the new value + ** of the lock_counter, as will any resources referenced afterwards. + */ + int _tagLockCounter; /* lock counter value at tag time */ -// FIXME: get rid of this -gfx_resstate_t *gfxr_new_resource_manager(int version, gfx_options_t *options, - gfx_driver_t *driver, ResourceManager *resManager); -/* Allocates and initializes a new resource manager -** Parameters: (int) version: Interpreter version -** (gfx_options_t *): Pointer to all relevant drawing options -** (gfx_driver_t *): The graphics driver (needed for capability flags and the mode -** structure) -** (void *) misc_payload: Additional information for the interpreter's -** resource loaders -** Returns : (gfx_resstate_t *): A newly allocated resource manager -** The options are considered to be read-only, as they belong to the overlying state object. -*/ + IntResMap _resourceMaps[GFX_RESOURCE_TYPES_NR]; + ResourceManager *_resManager; +}; } // End of namespace Sci diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index da5f4bdc02..75b57dc4df 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -262,11 +262,7 @@ static void _gfxop_full_pointer_refresh(gfx_state_t *state) { static int _gfxop_buffer_propagate_box(gfx_state_t *state, rect_t box, gfx_buffer_t buffer); gfx_pixmap_t *_gfxr_get_cel(gfx_state_t *state, int nr, int *loop, int *cel, int palette) { - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - gfxr_view_t *view = _gfx->getView(nr, loop, cel, palette); - delete _gfx; + gfxr_view_t *view = state->gfxResMan->getView(nr, loop, cel, palette); gfxr_loop_t *indexed_loop; @@ -422,6 +418,7 @@ int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resM int xfact, int yfact, gfx_color_mode_t bpp) { int color_depth = bpp ? bpp : 1; int initialized = 0; + Palette *staticPalette = NULL; /* Null for dynamic palettes */ BASIC_CHECKS(GFX_FATAL); @@ -435,7 +432,6 @@ int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resM state->pic_nr = -1; // Set background pic number to an invalid value state->tag_mode = 0; state->dirty_rects = NULL; - state->static_palette = NULL; do { if (!state->driver->init(state->driver, xfact, yfact, color_depth)) @@ -449,21 +445,18 @@ int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resM gfxr_init_static_palette(); - if (!((state->resstate = gfxr_new_resource_manager(state->version, state->options, state->driver, resManager)))) { - GFXERROR("Failed to initialize resource manager!\n"); - return GFX_FATAL; - } - if (state->version < SCI_VERSION_01_VGA) { - state->static_palette = gfx_sci0_pic_colors->getref(); + staticPalette = gfx_sci0_pic_colors->getref(); } else if (state->version == SCI_VERSION_1_1 || state->version == SCI_VERSION_32) { GFXDEBUG("Palettes are not yet supported in this SCI version\n"); } else { - Resource *res = state->resstate->resManager->findResource(kResourceTypePalette, 999, 0); + Resource *res = resManager->findResource(kResourceTypePalette, 999, 0); if (res && res->data) - state->static_palette = gfxr_read_pal1(res->id, res->data, res->size); + staticPalette = gfxr_read_pal1(res->id, res->data, res->size); } + state->gfxResMan = new GfxResManager(state->version, state->options, state->driver, staticPalette, resManager); + gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200)); init_aux_pixmap(&(state->control_map)); @@ -482,11 +475,7 @@ int gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value) { int gfxop_exit(gfx_state_t *state) { BASIC_CHECKS(GFX_ERROR); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - _gfx->freeResManager(); - delete _gfx; + state->gfxResMan->freeResManager(); if (state->control_map) { gfx_free_pixmap(state->control_map); @@ -1144,11 +1133,7 @@ int gfxop_update(gfx_state_t *state) { if (state->tag_mode) { // This usually happens after a pic and all resources have been drawn - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - _gfx->freeTaggedResources(); - delete _gfx; + state->gfxResMan->freeTaggedResources(); state->tag_mode = 0; } @@ -1224,11 +1209,7 @@ int gfxop_set_pointer_cursor(gfx_state_t *state, int nr) { if (nr == GFXOP_NO_POINTER) new_pointer = NULL; else { - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - new_pointer = _gfx->getCursor(nr); - delete _gfx; + new_pointer = state->gfxResMan->getCursor(nr); if (!new_pointer) { GFXWARN("Attempt to set invalid pointer #%d\n", nr); @@ -1691,11 +1672,7 @@ int gfxop_lookup_view_get_loops(gfx_state_t *state, int nr) { BASIC_CHECKS(GFX_ERROR); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - view = _gfx->getView(nr, &loop, &cel, 0); - delete _gfx; + view = state->gfxResMan->getView(nr, &loop, &cel, 0); if (!view) { GFXWARN("Attempt to retrieve number of loops from invalid view %d\n", nr); @@ -1711,11 +1688,7 @@ int gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop) { BASIC_CHECKS(GFX_ERROR); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - view = _gfx->getView(nr, &real_loop, &cel, 0); - delete _gfx; + view = state->gfxResMan->getView(nr, &real_loop, &cel, 0); if (!view) { GFXWARN("Attempt to retrieve number of cels from invalid/broken view %d\n", nr); @@ -1730,11 +1703,7 @@ int gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop) { int gfxop_check_cel(gfx_state_t *state, int nr, int *loop, int *cel) { BASIC_CHECKS(GFX_ERROR); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - gfxr_view_t *testView = _gfx->getView(nr, loop, cel, 0); - delete _gfx; + gfxr_view_t *testView = state->gfxResMan->getView(nr, loop, cel, 0); if (!testView) { GFXWARN("Attempt to verify loop/cel values for invalid view %d\n", nr); @@ -1749,11 +1718,7 @@ int gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel) { int cel_v = *cel; BASIC_CHECKS(GFX_ERROR); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - gfxr_view_t *testView = _gfx->getView(nr, &loop_v, &cel_v, 0); - delete _gfx; + gfxr_view_t *testView = state->gfxResMan->getView(nr, &loop_v, &cel_v, 0); if (!testView) { GFXWARN("Attempt to verify loop/cel values for invalid view %d\n", nr); @@ -1775,11 +1740,7 @@ int gfxop_get_cel_parameters(gfx_state_t *state, int nr, int loop, int cel, int gfx_pixmap_t *pxm = NULL; BASIC_CHECKS(GFX_ERROR); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - view = _gfx->getView(nr, &loop, &cel, 0); - delete _gfx; + view = state->gfxResMan->getView(nr, &loop, &cel, 0); if (!view) { GFXWARN("Attempt to get cel parameters for invalid view %d\n", nr); @@ -1803,11 +1764,7 @@ static int _gfxop_draw_cel_buffer(gfx_state_t *state, int nr, int loop, int cel, int old_x, old_y; BASIC_CHECKS(GFX_FATAL); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - view = _gfx->getView(nr, &loop, &cel, palette); - delete _gfx; + view = state->gfxResMan->getView(nr, &loop, &cel, palette); if (!view) { GFXWARN("Attempt to draw loop/cel %d/%d in invalid view %d\n", loop, cel, nr); @@ -1871,22 +1828,17 @@ int *gfxop_get_pic_metainfo(gfx_state_t *state) { int gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) { BASIC_CHECKS(GFX_FATAL); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - _gfx->tagResources(); + state->gfxResMan->tagResources(); state->tag_mode = 1; state->palette_nr = default_palette; - state->pic = _gfx->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); + state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); if (state->driver->mode->xfact == 1 && state->driver->mode->yfact == 1) { state->pic_unscaled = state->pic; } else { - state->pic = _gfx->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, false); + state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, false); } - delete _gfx; - if (!state->pic || !state->pic_unscaled) { GFXERROR("Could not retrieve background pic %d!\n", nr); if (state->pic) { @@ -1914,19 +1866,14 @@ int gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) return GFX_ERROR; } - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - state->pic = _gfx->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); + state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); if (!state->pic) { GFXERROR("Could not add pic #%d to pic #%d!\n", state->pic_nr, nr); - delete _gfx; return GFX_ERROR; } - state->pic_unscaled = _gfx->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - delete _gfx; + state->pic_unscaled = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); return _gfxop_set_pic(state); } @@ -1939,11 +1886,7 @@ int gfxop_get_font_height(gfx_state_t *state, int font_nr) { gfx_bitmap_font_t *font; BASIC_CHECKS(GFX_FATAL); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - font = _gfx->getFont(font_nr); - delete _gfx; + font = state->gfxResMan->getFont(font_nr); if (!font) return GFX_ERROR; @@ -1958,11 +1901,7 @@ int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, int BASIC_CHECKS(GFX_FATAL); - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - font = _gfx->getFont(font_nr); - delete _gfx; + font = state->gfxResMan->getFont(font_nr); if (!font) { GFXERROR("Attempt to calculate text size with invalid font #%d\n", font_nr); @@ -2000,11 +1939,7 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i return NULL; } - // FIXME: the initialization of the GFX resource manager should - // be pushed up, and it shouldn't occur here - GfxResManager *_gfx = new GfxResManager(state->resstate); - font = _gfx->getFont(font_nr); - delete _gfx; + font = state->gfxResMan->getFont(font_nr); if (!font) { GFXERROR("Attempt to draw text with invalid font #%d\n", font_nr); diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 6a5965d9bc..30dce1afa0 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -102,11 +102,11 @@ struct gfx_state_t { rect_t clip_zone; /* The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */ gfx_driver_t *driver; - Palette *static_palette; /* Null for dynamic palettes */ int visible_map; - gfx_resstate_t *resstate; /* Resource state */ + //gfx_resstate_t *resstate; /* Resource state */ + GfxResManager *gfxResMan; gfx_pixmap_t *priority_map; /* back buffer priority map (unscaled) */ gfx_pixmap_t *static_priority_map; /* static buffer priority map (unscaled) */ |