[Scummvm-cvs-logs] SF.net SVN: scummvm:[39492] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Mar 17 22:08:34 CET 2009


Revision: 39492
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39492&view=rev
Author:   thebluegr
Date:     2009-03-17 21:08:33 +0000 (Tue, 17 Mar 2009)

Log Message:
-----------
Started objectifying the graphics resource manager (refer to patch #2689887)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
    scummvm/trunk/engines/sci/gfx/gfx_resource.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/resmgr.cpp
    scummvm/trunk/engines/sci/gfx/resource/res_manager.cpp
    scummvm/trunk/engines/sci/gfx/resource/res_pic.cpp
    scummvm/trunk/engines/sci/gfx/resource/res_view0.cpp
    scummvm/trunk/engines/sci/gfx/resource/res_view1.cpp

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -2350,7 +2350,7 @@
 		        UKPV(3), UKPV(2));
 		// FIXME: Should really only invalidate all loaded pic resources here;
 		// this is overkill
-		gfxr_free_all_resources(s->gfx_state->driver, s->gfx_state->resstate);
+		gfxr_free_all_resources(s->gfx_state->resstate);
 
 		break;
 	}

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -2011,7 +2011,7 @@
 	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->driver, s->gfx_state->resstate);
+	gfxr_free_all_resources(s->gfx_state->resstate);
 	s->visual = NULL;
 
 	return 0;

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -94,7 +94,7 @@
 	int i;
 	if (S) {
 		for (i = 0; i < 2; i++) {
-			gfx_free_pixmap(drv, S->priority[i]);
+			gfx_free_pixmap(S->priority[i]);
 			S->priority[i] = NULL;
 		}
 

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-03-17 21:08:33 UTC (rev 39492)
@@ -114,34 +114,22 @@
 ** The options are considered to be read-only, as they belong to the overlying state object.
 */
 
-void gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state);
+void gfxr_free_resource_manager(gfx_resstate_t *state);
 /* Frees a previously allocated resource manager, and all allocated resources.
-** Parameters: (gfx_driver_t *) driver: The graphics driver; used to free pixmaps that
-**                                      are installed in a driver-specific registry
-**             (gfx_resstate_t *) state: The state manager to free
+** Parameters: (gfx_resstate_t *) state: The state manager to free
 ** Return    : (void)
 */
 
-void gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state);
+void gfxr_free_all_resources(gfx_resstate_t *state);
 /* Frees all resources currently allocated
-** Parameter: (gfx_driver_t *) driver: The driver to free with
-**            (gfx_resstate_t *) state: The state to do this on
+** Parameter: (gfx_resstate_t *) state: The state to do this on
 ** Returns  : (void)
 ** This function is intended to be used primarily for debugging.
 */
 
-void gfxr_tag_resources(gfx_resstate_t *state);
-/* 'Tags' all resources for deletion
-** Paramters: (gfx_resstate_t *) state: The resource state to modify
-** Returns  : (void)
-** Tagged resources are untagged if they are referenced.
-*/
-
-void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state);
+void gfxr_free_tagged_resources(gfx_resstate_t *state);
 /* Frees all tagged resources.
-** Parameters: (gfx_driver_t *) driver: The graphics driver the pixmaps are potentially
-**                                      registered in
-**             (gfx_resstate_t *) state: The state to alter
+** Parameters: (gfx_resstate_t *) state: The state to alter
 ** Returns   : (void)
 ** Resources are tagged by calling gfx_tag_resources(), and untagged by calling the
 ** approprate dereferenciation function.
@@ -150,20 +138,65 @@
 */
 
 
-gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags,
-	int default_palette, int scaled);
-/* Retreives a displayable (translated) pic resource
-** Parameters: (gfx_resstate_t *) state: The resource state
-**             (int) nr: Number of the pic resource
-**             (int) maps: The maps to translate (ORred GFX_MASK_*)
-**             (int) flags: Interpreter-dependant pic flags
-**             (int) default_palette: The default palette to use for drawing (if applicable)
-**             (int) scaled: Whether to return the scaled maps, or the unscaled
-**                           ones (which may be identical) for some special operations.
-** Returns   : (gfx_pic_t *) The appropriate pic resource with all maps as index (but not
-**                           neccessarily translated) data.
-*/
+class GfxResManager {
+public:
+	GfxResManager(gfx_resstate_t *state) : _state(state) {}
+	~GfxResManager() {}
 
+	/* 'Tags' all resources for deletion
+	** Paramters: (void)
+	** Returns  : (void)
+	** Tagged resources are untagged if they are referenced.
+	*/
+	void tagResources() { (_state->tag_lock_counter)++; }
+
+	/* Retreives an SCI0/SCI01 mouse cursor
+	** Parameters: (int) num: The cursor number
+	** Returns   : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error
+	*/
+	gfx_pixmap_t *getCursor(int num);
+
+
+	/* Retreives the static palette from the interpreter-specific code
+	** Parameters: (int *) colors_nr: Number of colors to use
+	**             (int) nr: The palette to read
+	** Returns   : (gfx_pixmap_color_t *) *colors_nr static color entries
+	**             if a static palette must be used, NULL otherwise
+	*/
+	Palette *getPalette(int *colors_nr, int num = 999);
+
+
+	/* Retreives a font
+	** Parameters: (int) nr: The font number
+	**             (int) scaled: Whether the font should be font-scaled
+	** Returns   : (gfx_font_t *) The appropriate font, or NULL on error
+	*/
+	gfx_bitmap_font_t *getFont(int num, bool scaled = false);
+
+
+	/* Retreives a displayable (translated) pic resource
+	** Parameters: (int) nr: Number of the pic resource
+	**             (int) maps: The maps to translate (ORred GFX_MASK_*)
+	**             (int) flags: Interpreter-dependant pic flags
+	**             (int) default_palette: The default palette to use for drawing (if applicable)
+	**             (bool) scaled: Whether to return the scaled maps, or the unscaled
+	**                           ones (which may be identical) for some special operations.
+	** Returns   : (gfx_pic_t *) The appropriate pic resource with all maps as index (but not
+	**                           neccessarily translated) data.
+	*/
+	gfxr_pic_t *getPic(int num, int maps, int flags, int default_palette, bool scaled = false);
+
+
+	/* 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; }
+
+private:
+	gfx_resstate_t *_state;
+};
+
 gfxr_pic_t *gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int flags,
 	int old_default_palette, int default_palette, int scaled);
 /* Retreives a displayable (translated) pic resource written ontop of an existing pic
@@ -195,30 +228,6 @@
 ** loop and cel numbers have to be interpreted as 'maximum' or 'minimum' by the interpreter)
 */
 
-gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_t *state, int nr, int scaled);
-/* Retreives a font
-** Parameters: (ResourceManager&) resourceManager: supplies the resource repository capability
-** 			   (gfx_resstate_t *) state: The relevant resource state
-**             (int) nr: The font number
-**             (int) scaled: Whether the font should be font-scaled
-** Returns   : (gfx_font_t *) The appropriate font, or NULL on error
-*/
-
-gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr);
-/* Retreives an SCI0/SCI01 mouse cursor
-** Parameters: (gfx_resstate_t *) state: The resource state
-**             (int) nr: The cursour number
-** Returns   : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error
-*/
-
-gfx_pixmap_color_t *gfxr_get_palette(gfx_resstate_t *state, int nr);
-/* Retreives a palette
-** Parameters: (gfx_resstate_t *) state: The resource state
-**             (int) nr: The cursour number
-** Returns   : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error
-*/
-
-
 /* =========================== */
 /* Interpreter-dependant stuff */
 /* =========================== */
@@ -241,23 +250,6 @@
 ** (Yes, this isn't really a "hash" in the traditional sense...)
 */
 
-gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID);
-/* Initializes a pic
-** Parameters: (int) version: Interpreter version to use
-**             (gfx_mode_t *) mode: The graphics mode the pic will be using
-**             (int) ID: The ID to assign to the gfxr_pic_t structure
-** Returns   : (gfxr_pic_t *) A newly allocated pic
-** This function is typically called befode gfxr_interpreter_clear_pic().
-*/
-
-void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic);
-/* Clears a previously allocated pic
-** Parameters: (int) version: Interpreter version
-**             (gfxr_pic_t *) pic: The pic to clear
-** Returns  :  (void)
-** This function is called in preparation for the pic to be drawn with gfxr_interpreter_calculate_pic.
-*/
-
 int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic,
 	int flags, int default_palette, int nr);
 /* Instructs the interpreter-specific code to calculate a picture
@@ -281,47 +273,6 @@
 ** Returns   : (gfx_view_t *) The appropriate view, or NULL on error
 */
 
-gfx_bitmap_font_t *gfxr_interpreter_get_font(ResourceManager& resourceManager, int nr);
-/* Instructs the interpreter-specific code to calculate a font
-** Parameters: (ResourceManager& ) resourceManager: The resource manager
-**             (int) nr: The font resource number
-** Returns   : (gfx_font_t *) The newly calculated font, or NULL on error
-*/
-
-gfx_pixmap_t *gfxr_interpreter_get_cursor(ResourceManager& resourceManager, int nr, int version);
-/* Instructs the interpreter-specific code to calculate a cursor
-** Parameters: (ResourceManager& ) state: The resource manager
-**             (int nr): The cursor resource number
-**             (int version): The SCI version used
-** Returns   : (gfx_pixmap_t *) The cursor pixmap, or NULL on error
-*/
-
-Palette *gfxr_interpreter_get_static_palette(ResourceManager& resourceManager, int version, int *colors_nr);
-/* Retreives the static palette (palette 999) from the interpreter-specific code
-** Parameters: (ResourceManager& ) state: The resource manager
-**             (int) version: Interpreter version to use
-**             (int *) colors_nr: Number of colors to use
-** Returns   : (gfx_pixmap_color_t *) *colors_nr static color entries
-**             if a static palette must be used, NULL otherwise
-*/
-
-Palette *gfxr_interpreter_get_palette(ResourceManager& resourceManager, int version, int *colors_nr, int nr);
-/* Retreives the static palette from the interpreter-specific code
-** Parameters: (ResourceManager& ) state: The resource manager
-**             (int) version: Interpreter version to use
-**             (int *) colors_nr: Number of colors to use
-**             (int) nr: The palette to read
-** Returns   : (gfx_pixmap_color_t *) *colors_nr static color entries
-**             if a static palette must be used, NULL otherwise
-*/
-
-int gfxr_interpreter_needs_multicolored_pointers(int version);
-/* Determines whether support for pointers with more than two colors is required
-** Parameters: (int) version: Interpreter version to test for
-** Returns   : (int) 0 if no support for multi-colored pointers is required, non-0
-**                   otherwise
-*/
-
 } // End of namespace Sci
 
 #endif // SCI_GFX_GFX_RSMGR_H

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -40,19 +40,19 @@
 };
 
 
-static void gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) {
+static void gfxr_free_loop(gfxr_loop_t *loop) {
 	int i;
 
 	if (loop->cels) {
 		for (i = 0; i < loop->cels_nr; i++)
 			if (loop->cels[i])
-				gfx_free_pixmap(driver, loop->cels[i]);
+				gfx_free_pixmap(loop->cels[i]);
 
 		free(loop->cels);
 	}
 }
 
-void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) {
+void gfxr_free_view(gfxr_view_t *view) {
 	int i;
 
 	if (view->palette)
@@ -60,7 +60,7 @@
 
 	if (view->loops) {
 		for (i = 0; i < view->loops_nr; i++)
-			gfxr_free_loop(driver, view->loops + i);
+			gfxr_free_loop(view->loops + i);
 
 		free(view->loops);
 	}
@@ -393,10 +393,10 @@
 	}
 }
 
-void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) {
-	gfx_free_pixmap(driver, pic->visual_map);
-	gfx_free_pixmap(driver, pic->priority_map);
-	gfx_free_pixmap(driver, pic->control_map);
+void gfxr_free_pic(gfxr_pic_t *pic) {
+	gfx_free_pixmap(pic->visual_map);
+	gfx_free_pixmap(pic->priority_map);
+	gfx_free_pixmap(pic->control_map);
 	pic->visual_map = NULL;
 	pic->priority_map = NULL;
 	pic->control_map = NULL;

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-03-17 21:08:33 UTC (rev 39492)
@@ -140,17 +140,15 @@
 ** This function allocates memory for use by resource drawer functions.
 */
 
-void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic);
+void gfxr_free_pic(gfxr_pic_t *pic);
 /* Uninitializes a pic resource
-** Parameters: (gfx_driver_t *) driver: The driver the pic should be removed from
-**             (gfxr_pic_t *) pic: The pic to free
+** Parameters: (gfxr_pic_t *) pic: The pic to free
 ** Returns   : (void)
 */
 
-void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view);
+void gfxr_free_view(gfxr_view_t *view);
 /* Frees all memory associated with a view
-** Paremeters: (gfx_driver_t *) driver: The driver the view should be removed from
-**             (gfxr_view_t *) view: The view to free
+** Paremeters: (gfxr_view_t *) view: The view to free
 ** Returns   : (void)
 */
 

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -81,6 +81,7 @@
 	if (mode->palette)
 		mode->palette->free();
 	free(mode);
+	mode = NULL;
 }
 
 void gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) {
@@ -146,13 +147,9 @@
 	return pxm;
 }
 
-void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) {
-	if (driver) {
-		if (driver->mode->palette) {
-			if (pxm->palette)
-				pxm->palette->free();
-		}
-	}
+void gfx_free_pixmap(gfx_pixmap_t *pxm) {
+	if (pxm->palette)
+		pxm->palette->free();
 
 	free(pxm->index_data);
 	free(pxm->alpha_map);

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-03-17 21:08:33 UTC (rev 39492)
@@ -118,10 +118,9 @@
 ** Returns   : (gfx_pixmap_t *) pixmap
 */
 
-void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm);
+void gfx_free_pixmap(gfx_pixmap_t *pxm);
 /* Frees all memory associated with a pixmap
-** Parameters: (gfx_driver_t *) driver: The driver the pixmap is to be removed from
-**             (gfx_pixmap_t *) pxm: The pixmap to free
+** Parameters: (gfx_pixmap_t *) pxm: The pixmap to free
 ** Returns   : (void)
 */
 

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -433,9 +433,18 @@
 		return GFX_FATAL;
 	}
 
-	int size;
-	state->static_palette = gfxr_interpreter_get_static_palette(*(state->resstate->resManager), state->version, &size);
+	state->static_palette = NULL;
 
+	if (state->version < SCI_VERSION_01_VGA) {
+		state->static_palette = 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);
+		if (res && res->data)
+			state->static_palette = gfxr_read_pal1(res->id, res->data, res->size);
+	}
+
 	state->visible_map = GFX_MASK_VISUAL;
 	state->fullscreen_override = NULL; // No magical override
 	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
@@ -495,20 +504,20 @@
 
 int gfxop_exit(gfx_state_t *state) {
 	BASIC_CHECKS(GFX_ERROR);
-	gfxr_free_resource_manager(state->driver, state->resstate);
+	gfxr_free_resource_manager(state->resstate);
 
 	if (state->control_map) {
-		gfx_free_pixmap(state->driver, state->control_map);
+		gfx_free_pixmap(state->control_map);
 		state->control_map = NULL;
 	}
 
 	if (state->priority_map) {
-		gfx_free_pixmap(state->driver, state->priority_map);
+		gfx_free_pixmap(state->priority_map);
 		state->priority_map = NULL;
 	}
 
 	if (state->static_priority_map) {
-		gfx_free_pixmap(state->driver, state->static_priority_map);
+		gfx_free_pixmap(state->static_priority_map);
 		state->static_priority_map = NULL;
 	}
 
@@ -1162,7 +1171,7 @@
 
 	if (state->tag_mode) {
 		// This usually happens after a pic and all resources have been drawn
-		gfxr_free_tagged_resources(state->driver, state->resstate);
+		gfxr_free_tagged_resources(state->resstate);
 		state->tag_mode = 0;
 	}
 
@@ -1237,7 +1246,11 @@
 	if (nr == GFXOP_NO_POINTER)
 		new_pointer = NULL;
 	else {
-		new_pointer = gfxr_get_cursor(state->resstate, nr);
+		// 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;
 
 		if (!new_pointer) {
 			GFXWARN("Attempt to set invalid pointer #%d\n", nr);
@@ -1848,16 +1861,24 @@
 int gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) {
 	BASIC_CHECKS(GFX_FATAL);
 
-	gfxr_tag_resources(state->resstate);
+	// 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->tag_mode = 1;
 	state->palette_nr = default_palette;
+	state->pic = _gfx->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true);
+	delete _gfx;
 
-	state->pic = gfxr_get_pic(state->resstate, nr, GFX_MASK_VISUAL, flags, default_palette, 1);
-
-	if (state->driver->mode->xfact == 1 && state->driver->mode->yfact == 1)
+	if (state->driver->mode->xfact == 1 && state->driver->mode->yfact == 1) {
 		state->pic_unscaled = state->pic;
-	else
-		state->pic_unscaled = gfxr_get_pic(state->resstate, nr, GFX_MASK_VISUAL, flags, default_palette, 0);
+	} 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);
+		state->pic = _gfx->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);
@@ -1904,7 +1925,12 @@
 	gfx_bitmap_font_t *font;
 	BASIC_CHECKS(GFX_FATAL);
 
-	font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
+	// 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;
+
 	if (!font)
 		return GFX_ERROR;
 
@@ -1918,7 +1944,11 @@
 
 	BASIC_CHECKS(GFX_FATAL);
 
-	font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
+	// 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;
 
 	if (!font) {
 		GFXERROR("Attempt to calculate text size with invalid font #%d\n", font_nr);
@@ -1956,7 +1986,11 @@
 		return NULL;
 	}
 
-	font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
+	// 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;
 
 	if (!font) {
 		GFXERROR("Attempt to draw text with invalid font #%d\n", font_nr);
@@ -2001,7 +2035,7 @@
 			int j;
 
 			for (j = 0; j < i; j++)
-				gfx_free_pixmap(state->driver, handle->text_pixmaps[j]);
+				gfx_free_pixmap(handle->text_pixmaps[j]);
 
 			free(handle->text_pixmaps);
 			free(handle->text);
@@ -2027,7 +2061,7 @@
 
 	if (handle->text_pixmaps) {
 		for (j = 0; j < handle->lines_nr; j++)
-			gfx_free_pixmap(state->driver, handle->text_pixmaps[j]);
+			gfx_free_pixmap(handle->text_pixmaps[j]);
 		free(handle->text_pixmaps);
 	}
 
@@ -2167,7 +2201,7 @@
 
 int gfxop_free_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm) {
 	BASIC_CHECKS(GFX_ERROR);
-	gfx_free_pixmap(state->driver, pxm);
+	gfx_free_pixmap(pxm);
 	return GFX_OK;
 }
 

Modified: scummvm/trunk/engines/sci/gfx/resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resmgr.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/resmgr.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -40,8 +40,6 @@
 
 namespace Sci {
 
-#undef TIME_PICDRAWING
-
 // Invalid hash mode: Used to invalidate modified pics
 #define MODE_INVALID -1
 
@@ -66,21 +64,13 @@
 
 #define FREEALL(freecmd, type) \
 	if (resource->scaled_data.type) \
-		freecmd(driver, resource->scaled_data.type); \
-	resource->scaled_data.type = NULL; \
-	if (resource->unscaled_data.type) \
-		freecmd(driver, resource->unscaled_data.type); \
-	resource->unscaled_data.type = NULL;
-
-#define FREEALL_SIMPLE(freecmd, type) \
-	if (resource->scaled_data.type) \
 		freecmd(resource->scaled_data.type); \
 	resource->scaled_data.type = NULL; \
 	if (resource->unscaled_data.type) \
 		freecmd(resource->unscaled_data.type); \
 	resource->unscaled_data.type = NULL;
 
-void gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type) {
+void gfxr_free_resource(gfx_resource_t *resource, int type) {
 	if (!resource)
 		return;
 
@@ -95,7 +85,7 @@
 		break;
 
 	case GFX_RESOURCE_TYPE_FONT:
-		FREEALL_SIMPLE(gfxr_free_font, font);
+		FREEALL(gfxr_free_font, font);
 		break;
 
 	case GFX_RESOURCE_TYPE_CURSOR:
@@ -109,25 +99,21 @@
 	free(resource);
 }
 
-void gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state) {
+void gfxr_free_all_resources(gfx_resstate_t *state) {
 	for (int type = 0; type < GFX_RESOURCE_TYPES_NR; ++type) {
 		for (IntResMap::iterator iter = state->_resourceMaps[type].begin(); iter != state->_resourceMaps[type].end(); ++iter) {
-			gfxr_free_resource(driver, iter->_value, type);
+			gfxr_free_resource(iter->_value, type);
 			iter->_value = 0;
 		}
 	}
 }
 
-void gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state) {
-	gfxr_free_all_resources(driver, state);
+void gfxr_free_resource_manager(gfx_resstate_t *state) {
+	gfxr_free_all_resources(state);
 	delete state;
 }
 
-void gfxr_tag_resources(gfx_resstate_t *state) {
-	(state->tag_lock_counter)++;
-}
-
-void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) {
+void gfxr_free_tagged_resources(gfx_resstate_t *state) {
 	// Current heuristics: free tagged views and old pics
 
 	IntResMap::iterator iter;
@@ -140,7 +126,7 @@
 
 		if (resource) {
 			if (resource->lock_sequence_nr < tmp) {
-				gfxr_free_resource(driver, resource, type);
+				gfxr_free_resource(resource, type);
 				iter->_value = 0;
 			} else {
 				resource->lock_sequence_nr = 0;
@@ -154,7 +140,7 @@
 
 		if (resource) {
 			if (resource->lock_sequence_nr < 0) {
-				gfxr_free_resource(driver, resource, type);
+				gfxr_free_resource(resource, type);
 				iter->_value = 0;
 			} else {
 				resource->lock_sequence_nr--;
@@ -191,89 +177,76 @@
 }
 #undef XLATE_AS_APPROPRIATE
 
-gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_palette, int scaled) {
+gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_palette, bool scaled) {
 	gfxr_pic_t *npic = NULL;
 	gfx_resource_type_t restype = GFX_RESOURCE_TYPE_PIC;
-	IntResMap &resMap = state->_resourceMaps[restype];
+	IntResMap &resMap = _state->_resourceMaps[restype];
 	gfx_resource_t *res = NULL;
-	int hash = gfxr_interpreter_options_hash(restype, state->version, state->options, 0);
+	int hash = gfxr_interpreter_options_hash(restype, _state->version, _state->options, 0);
 	int must_post_process_pic = 0;
-	int need_unscaled = (state->driver->mode->xfact != 1 || state->driver->mode->yfact != 1);
+	int need_unscaled = (_state->driver->mode->xfact != 1 || _state->driver->mode->yfact != 1);
 
 	hash |= (flags << 20) | ((default_palette & 0x7) << 28);
 
-	res = resMap.contains(nr) ? resMap[nr] : NULL;
+	res = resMap.contains(num) ? resMap[num] : NULL;
 
 	if (!res || res->mode != hash) {
 		gfxr_pic_t *pic;
 		gfxr_pic_t *unscaled_pic = NULL;
 
-		if (state->options->pic0_unscaled) {
+		if (_state->options->pic0_unscaled) {
 			need_unscaled = 0;
-			pic = gfxr_interpreter_init_pic(state->version, &mode_1x1_color_index, GFXR_RES_ID(restype, nr));
+			pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(restype, num), _state->version >= SCI_VERSION_01_VGA);
 		} else
-			pic = gfxr_interpreter_init_pic(state->version, state->driver->mode, GFXR_RES_ID(restype, nr));
-
+			pic = gfxr_init_pic(_state->driver->mode, GFXR_RES_ID(restype, num), _state->version >= SCI_VERSION_01_VGA);
 		if (!pic) {
 			GFXERROR("Failed to allocate scaled pic!\n");
 			return NULL;
 		}
 
-		gfxr_interpreter_clear_pic(state->version, pic);
+		gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
 
 		if (need_unscaled) {
-			unscaled_pic = gfxr_interpreter_init_pic(state->version, &mode_1x1_color_index, GFXR_RES_ID(restype, nr));
+			unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(restype, num), _state->version >= SCI_VERSION_01_VGA);
 			if (!unscaled_pic) {
 				GFXERROR("Failed to allocate unscaled pic!\n");
 				return NULL;
 			}
-			gfxr_interpreter_clear_pic(state->version, unscaled_pic);
+			gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
 		}
-#ifdef TIME_PICDRAWING
-		{
-			uint32 start_msec, end_msec;
-			start_msec = g_system->getMillis();
-#endif
-			if (gfxr_interpreter_calculate_pic(state, pic, unscaled_pic, flags, default_palette, nr)) {
-				gfxr_free_pic(state->driver, pic);
-				if (unscaled_pic)
-					gfxr_free_pic(state->driver, unscaled_pic);
-
-				return NULL;
-			}
-#ifdef TIME_PICDRAWING
-			end_msec = g_system->getMillis();
-			printf("\nTIME:	%d	ms for drawing pic.%03d\n", end_msec - start_msec, nr);
+		if (gfxr_interpreter_calculate_pic(_state, pic, unscaled_pic, flags, default_palette, num)) {
+			gfxr_free_pic(pic);
+			if (unscaled_pic)
+				gfxr_free_pic(unscaled_pic);
+			return NULL;
 		}
-#endif
-
 		if (!res) {
 			res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
-			res->ID = GFXR_RES_ID(restype, nr);
-			res->lock_sequence_nr = state->options->buffer_pics_nr;
-			resMap[nr] = res;
+			res->ID = GFXR_RES_ID(restype, num);
+			res->lock_sequence_nr = _state->options->buffer_pics_nr;
+			resMap[num] = res;
 		} else {
-			gfxr_free_pic(state->driver, res->scaled_data.pic);
+			gfxr_free_pic(res->scaled_data.pic);
 			if (res->unscaled_data.pic)
-				gfxr_free_pic(state->driver, res->unscaled_data.pic);
+				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 = state->options->buffer_pics_nr; // Update lock counter
+		res->lock_sequence_nr = _state->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 || _state->options->pic0_unscaled, 0, _state->driver->mode,
+	                             _state->options->pic_xlate_filter, 0, _state->options);
 
 
 	if (must_post_process_pic) {
-		gfxr_endianness_adjust(npic->visual_map, state->driver->mode);
+		gfxr_endianness_adjust(npic->visual_map, _state->driver->mode);
 	}
 
 	return npic;
@@ -338,7 +311,11 @@
 	res = resMap.contains(old_nr) ? resMap[old_nr] : NULL;
 
 	if (!res || (res->mode != MODE_INVALID && res->mode != hash)) {
-		gfxr_get_pic(state, old_nr, 0, flags, old_default_palette, scaled);
+		// 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, scaled);
+		delete _gfx;
 
 		res = resMap.contains(old_nr) ? resMap[old_nr] : NULL;
 
@@ -398,7 +375,7 @@
 			res->mode = hash;
 			resMap[nr] = res;
 		} else {
-			gfxr_free_view(state->driver, res->unscaled_data.view);
+			gfxr_free_view(res->unscaled_data.view);
 		}
 
 		res->mode = hash;
@@ -453,29 +430,30 @@
 	return view;
 }
 
-gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_t *state, int nr, int scaled) {
+gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) {
 	gfx_resource_type_t restype = GFX_RESOURCE_TYPE_FONT;
-	IntResMap &resMap = state->_resourceMaps[restype];
+	IntResMap &resMap = _state->_resourceMaps[restype];
 	gfx_resource_t *res = NULL;
 	int hash;
 
-	hash = gfxr_interpreter_options_hash(restype, state->version, state->options, 0);
+	hash = gfxr_interpreter_options_hash(restype, _state->version, _state->options, 0);
 
-	res = resMap.contains(nr) ? resMap[nr] : NULL;
+	res = resMap.contains(num) ? resMap[num] : NULL;
 
 	if (!res || res->mode != hash) {
-		gfx_bitmap_font_t *font = gfxr_interpreter_get_font(resourceManager, nr);
-
-		if (!font)
+		Resource *fontRes = _state->resManager->findResource(kResourceTypeFont, num, 0);
+		if (!fontRes || !fontRes->data)
 			return NULL;
 
+		gfx_bitmap_font_t *font = gfxr_read_font(fontRes->id, fontRes->data, fontRes->size);
+
 		if (!res) {
 			res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
 			res->scaled_data.font = NULL;
-			res->ID = GFXR_RES_ID(restype, nr);
-			res->lock_sequence_nr = state->tag_lock_counter;
+			res->ID = GFXR_RES_ID(restype, num);
+			res->lock_sequence_nr = _state->tag_lock_counter;
 			res->mode = hash;
-			resMap[nr] = res;
+			resMap[num] = res;
 		} else {
 			gfxr_free_font(res->unscaled_data.font);
 		}
@@ -484,7 +462,7 @@
 
 		return font;
 	} else {
-		res->lock_sequence_nr = state->tag_lock_counter; // Update lock counter
+		res->lock_sequence_nr = _state->tag_lock_counter; // Update lock counter
 		if (res->unscaled_data.pointer)
 			return res->unscaled_data.font;
 		else
@@ -492,39 +470,49 @@
 	}
 }
 
-gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr) {
+gfx_pixmap_t *GfxResManager::getCursor(int num) {
 	gfx_resource_type_t restype = GFX_RESOURCE_TYPE_CURSOR;
-	IntResMap &resMap = state->_resourceMaps[restype];
+	IntResMap &resMap = _state->_resourceMaps[restype];
 	gfx_resource_t *res = NULL;
-	int hash = gfxr_interpreter_options_hash(restype, state->version, state->options, 0);
+	int hash = gfxr_interpreter_options_hash(restype, _state->version, _state->options, 0);
 
-	res = resMap.contains(nr) ? resMap[nr] : NULL;
+	res = resMap.contains(num) ? resMap[num] : NULL;
 
 	if (!res || res->mode != hash) {
-		gfx_pixmap_t *cursor = gfxr_interpreter_get_cursor(*(state->resManager), nr, state->version);
+		Resource *cursorRes = _state->resManager->findResource(kResourceTypeCursor, num, 0);
+		if (!cursorRes || !cursorRes->data)
+			return NULL;
 
+		if (_state->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);
+
 		if (!cursor)
 			return NULL;
 
 		if (!res) {
 			res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
 			res->scaled_data.pointer = NULL;
-			res->ID = GFXR_RES_ID(restype, nr);
-			res->lock_sequence_nr = state->tag_lock_counter;
+			res->ID = GFXR_RES_ID(restype, num);
+			res->lock_sequence_nr = _state->tag_lock_counter;
 			res->mode = hash;
-			resMap[nr] = res;
+			resMap[num] = res;
 		} else {
-			gfx_free_pixmap(state->driver, res->unscaled_data.pointer);
+			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(_state->options, cursor);
+		gfx_xlate_pixmap(cursor, _state->driver->mode, _state->options->cursor_xlate_filter);
+		gfxr_endianness_adjust(cursor, _state->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 = _state->tag_lock_counter; // Update lock counter
 		return res->unscaled_data.pointer;
 	}
 }

Modified: scummvm/trunk/engines/sci/gfx/resource/res_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/res_manager.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/resource/res_manager.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -49,8 +49,6 @@
 			       | (options->pic0_dither_pattern << 8) | (options->pic0_brush_mode << 4) | (options->pic0_line_mode);
 
 	case GFX_RESOURCE_TYPE_FONT:
-		return 0;
-
 	case GFX_RESOURCE_TYPE_CURSOR:
 		return 0;
 
@@ -61,14 +59,6 @@
 	}
 }
 
-gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID) {
-	return gfxr_init_pic(mode, ID, version >= SCI_VERSION_01_VGA);
-}
-
-void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic) {
-	gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
-}
-
 int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic,
 	int flags, int default_palette, int nr) {
 	ResourceManager& resourceManager = *(state->resManager);
@@ -152,22 +142,12 @@
 
 	if (version < SCI_VERSION_01) palette = -1;
 
-	switch (version) {
-	case SCI_VERSION_0:
-	case SCI_VERSION_01:
+	if (version <= SCI_VERSION_01)
 		result = gfxr_draw_view0(resid, res->data, res->size, palette);
-		break;
-	case SCI_VERSION_01_VGA:
-	case SCI_VERSION_01_VGA_ODD:
-	case SCI_VERSION_1_EARLY:
-	case SCI_VERSION_1_LATE:
+	else if (version >= SCI_VERSION_01_VGA && version <= SCI_VERSION_1_LATE)
 		result = gfxr_draw_view1(resid, res->data, res->size, staticPalette);
-		break;
-	case SCI_VERSION_1_1:
-	case SCI_VERSION_32:
+	else if (version >= SCI_VERSION_1_1)
 		result = gfxr_draw_view11(resid, res->data, res->size);
-		break;
-	}
 
 	if (version >= SCI_VERSION_01_VGA) {
 		if (!result->palette) {
@@ -179,66 +159,4 @@
 	return result;
 }
 
-gfx_bitmap_font_t *gfxr_interpreter_get_font(ResourceManager& resourceManager, int nr) {
-	Resource *res = resourceManager.findResource(kResourceTypeFont, nr, 0);
-	if (!res || !res->data)
-		return NULL;
-
-	return gfxr_read_font(res->id, res->data, res->size);
-}
-
-gfx_pixmap_t *gfxr_interpreter_get_cursor(ResourceManager& resourceManager, int nr, int version) {
-	Resource *res = resourceManager.findResource(kResourceTypeCursor, nr, 0);
-	int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr);
-
-	if (!res || !res->data)
-		return NULL;
-
-	if (version >= SCI_VERSION_1_1) {
-		GFXWARN("Attempt to retrieve cursor in SCI1.1 or later\n");
-		return NULL;
-	}
-
-	return gfxr_draw_cursor(resid, res->data, res->size, version != SCI_VERSION_0);
-}
-
-Palette *gfxr_interpreter_get_static_palette(ResourceManager& resourceManager, int version, int *colors_nr) {
-	if (version >= SCI_VERSION_01_VGA)
-		return gfxr_interpreter_get_palette(resourceManager, version, colors_nr, 999);
-
-	*colors_nr = GFX_SCI0_PIC_COLORS_NR;
-	return gfx_sci0_pic_colors->getref();
-}
-
-Palette *gfxr_interpreter_get_palette(ResourceManager& resourceManager, int version, int *colors_nr, int nr) {
-	Resource *res;
-
-	if (version < SCI_VERSION_01_VGA)
-		return NULL;
-
-	res = resourceManager.findResource(kResourceTypePalette, nr, 0);
-	if (!res || !res->data)
-		return NULL;
-
-	switch (version) {
-	case SCI_VERSION_01_VGA :
-	case SCI_VERSION_01_VGA_ODD :
-	case SCI_VERSION_1_EARLY :
-	case SCI_VERSION_1_LATE :
-		return gfxr_read_pal1(res->id, res->data, res->size);
-	case SCI_VERSION_1_1 :
-	case SCI_VERSION_32 :
-		GFXDEBUG("Palettes are not yet supported in this SCI version\n");
-		return NULL;
-
-	default:
-		BREAKPOINT();
-		return NULL;
-	}
-}
-
-int gfxr_interpreter_needs_multicolored_pointers(int version) {
-	return (version > SCI_VERSION_1);
-}
-
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/resource/res_pic.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/res_pic.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/resource/res_pic.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -1699,6 +1699,9 @@
 
 				gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE);
 				gfx_free_mode(mode);
+				// When the mode is freed, the associated view 
+				// palette is freed too, so set it to NULL
+				view->palette = NULL;
 
 				if (flags & DRAWPIC01_FLAG_OVERLAID_PIC)
 					view_transparentize(view, pic->visual_map, posx, sci_titlebar_size + posy,
@@ -1708,7 +1711,8 @@
 				                      view->index_data, pic->visual_map->index_width, view->index_width,
 				                      view->index_width, view->index_height, 1);
 
-				gfx_free_pixmap(NULL, view);
+				gfx_free_pixmap(view);
+				view = NULL;
 			}
 			goto end_op_loop;
 

Modified: scummvm/trunk/engines/sci/gfx/resource/res_view0.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/res_view0.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/resource/res_view0.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -57,7 +57,7 @@
 	}
 
 	if (xl <= 0 || yl <= 0) {
-		gfx_free_pixmap(NULL, retval);
+		gfx_free_pixmap(retval);
 		GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
 		return NULL;
 	}
@@ -218,7 +218,7 @@
 		if (error_token || gfxr_draw_loop0(view->loops + i, id, i, resource, loop_offset, size, view, mirrored)) {
 			// An error occured
 			view->loops_nr = i;
-			gfxr_free_view(NULL, view);
+			gfxr_free_view(view);
 			return NULL;
 		}
 	}

Modified: scummvm/trunk/engines/sci/gfx/resource/res_view1.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/res_view1.cpp	2009-03-17 19:36:38 UTC (rev 39491)
+++ scummvm/trunk/engines/sci/gfx/resource/res_view1.cpp	2009-03-17 21:08:33 UTC (rev 39492)
@@ -246,9 +246,11 @@
 
 	if (view)
 		retval->palette = view->palette->getref();
+	else
+		retval->palette = NULL;
 
 	if (xl <= 0 || yl <= 0) {
-		gfx_free_pixmap(NULL, retval);
+		gfx_free_pixmap(retval);
 		GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
 		return NULL;
 	}
@@ -261,7 +263,7 @@
 		                                        pos, xl, yl, retval->color_key);
 
 	if (decompress_failed) {
-		gfx_free_pixmap(NULL, retval);
+		gfx_free_pixmap(retval);
 		return NULL;
 	}
 
@@ -381,7 +383,7 @@
 		if (error_token || gfxr_draw_loop1(view->loops + i, id, i, mirror_mask & (1 << i), resource, loop_offset, size, view, amiga_game)) {
 			// An error occured
 			view->loops_nr = i;
-			gfxr_free_view(NULL, view);
+			gfxr_free_view(view);
 			return NULL;
 		}
 	}
@@ -429,7 +431,7 @@
 		retval->palette = view->palette->getref();
 
 	if (xl <= 0 || yl <= 0) {
-		gfx_free_pixmap(NULL, retval);
+		gfx_free_pixmap(retval);
 		GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
 		return NULL;
 	}
@@ -438,7 +440,7 @@
 	                                        runlength_offset, literal_offset, xl, yl, retval->color_key);
 
 	if (decompress_failed) {
-		gfx_free_pixmap(NULL, retval);
+		gfx_free_pixmap(retval);
 		return NULL;
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list