From e546c609483d4098301f2e3edd8845e39aa89a12 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Mar 2009 23:30:57 +0000 Subject: Further objectification of the graphics resource manager svn-id: r39499 --- engines/sci/engine/kgraphics.cpp | 15 +++++++++++++-- engines/sci/engine/scriptdebug.cpp | 13 +++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'engines/sci/engine') diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index b3957a251d..768962fa6f 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -874,7 +874,13 @@ reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv) { gfxr_view_t *res = NULL; gfx_pixmap_t *pxm = NULL; - if (!(res = gfxr_get_view(s->gfx_state->resstate, view, &loop, &cel, 0))) { + // 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; + + if (!res) { GFXWARN("Attempt to get cel parameters for invalid view %d\n", view); return make_reg(0, -1); } @@ -2348,9 +2354,14 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { s->gfx_state->options->pic_port_bounds = gfx_rect(UKPV(5), UKPV(4), UKPV(3), UKPV(2)); + // FIXME: Should really only invalidate all loaded pic resources here; // this is overkill - gfxr_free_all_resources(s->gfx_state->resstate); + // 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; break; } diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index c5c00ceff1..4a19a6ee6f 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -864,6 +864,10 @@ 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; @@ -874,10 +878,11 @@ int c_viewinfo(EngineState *s) { Common::Point mod; if (con_can_handle_pixmaps()) { - view_pixmaps = gfxr_get_view(s->gfx_state->resstate, view, &i, &j, palette); + view_pixmaps = _gfx->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); @@ -2011,7 +2016,11 @@ 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)); - gfxr_free_all_resources(s->gfx_state->resstate); + // 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->visual = NULL; return 0; -- cgit v1.2.3