aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/gfx/gfx_resmgr.h28
-rw-r--r--engines/sci/gfx/operations.cpp22
-rw-r--r--engines/sci/gfx/resmgr.cpp10
-rw-r--r--engines/sci/gfx/resource/res_manager.cpp27
4 files changed, 45 insertions, 42 deletions
diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h
index 0be816dd26..21bbf517b8 100644
--- a/engines/sci/gfx/gfx_resmgr.h
+++ b/engines/sci/gfx/gfx_resmgr.h
@@ -37,6 +37,7 @@
namespace Sci {
struct gfx_bitmap_font_t;
+class ResourceManager;
enum gfx_resource_type_t {
GFX_RESOURCE_TYPE_VIEW = 0,
@@ -191,9 +192,10 @@ gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, i
** loop and cel numbers have to be interpreted as 'maximum' or 'minimum' by the interpreter)
*/
-gfx_bitmap_font_t *gfxr_get_font(gfx_resstate_t *state, int nr, int scaled);
+gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_t *state, int nr, int scaled);
/* Retreives a font
-** Parameters: (gfx_resstate_t *) state: The relevant resource state
+** 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
@@ -236,7 +238,7 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version,
** (Yes, this isn't really a "hash" in the traditional sense...)
*/
-int *gfxr_interpreter_get_resources(ResourceManager *resourceManager, gfx_resource_type_t type,
+int *gfxr_interpreter_get_resources(ResourceManager& resourceManager, gfx_resource_type_t type,
int version, int *entries_nr);
/* Retreives all resources of a specified type that are available from the interpreter
** Parameters: (gfx_resstate_t *) state: The relevant resource state
@@ -279,9 +281,9 @@ int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic
** Returns : (int) GFX_ERROR if the resource could not be found, GFX_OK otherwise
*/
-gfxr_view_t *gfxr_interpreter_get_view(ResourceManager* resourceManager, int nr, int palette, Palette* staticPalette, int version);
+gfxr_view_t *gfxr_interpreter_get_view(ResourceManager& resourceManager, int nr, int palette, Palette* staticPalette, int version);
/* Instructs the interpreter-specific code to calculate a view
-** Parameters: (ResourceManager *) resourceManager: The resource manager
+** Parameters: (ResourceManager& ) resourceManager: The resource manager
** (int) nr: The view resource number
** (int) palette: The palette number to use
** (Palette*) staticPalette: The static palette to use in VGA games
@@ -289,33 +291,33 @@ gfxr_view_t *gfxr_interpreter_get_view(ResourceManager* resourceManager, int nr,
** Returns : (gfx_view_t *) The appropriate view, or NULL on error
*/
-gfx_bitmap_font_t *gfxr_interpreter_get_font(ResourceManager *resourceManager, int nr);
+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
+** 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);
+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
+** 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);
+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
+** 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);
+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
+** 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
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index 481076aec4..ae1bfd81b8 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -205,7 +205,7 @@ DRAW_LOOP(map->index_data[offset] < color) // Draw only lower priority
static int _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) {
if (!driver->mode->palette) return GFX_OK;
if (!pxm->palette) return GFX_OK;
-
+
assert(pxm->palette->getParent() == driver->mode->palette);
if (!driver->mode->palette->isDirty()) return GFX_OK;
@@ -428,7 +428,7 @@ static int _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, Resour
}
int size;
- state->static_palette = gfxr_interpreter_get_static_palette(state->resstate->resManager, state->version, &size);
+ state->static_palette = gfxr_interpreter_get_static_palette(*(state->resstate->resManager), state->version, &size);
state->visible_map = GFX_MASK_VISUAL;
state->fullscreen_override = NULL; // No magical override
@@ -627,10 +627,10 @@ int gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b,
// Wrapper for gfxop_set_color
int gfxop_set_color(gfx_state_t *state, gfx_color_t *colorOut, gfx_color_t &colorIn) {
if (colorIn.mask & GFX_MASK_VISUAL)
- return gfxop_set_color(state, colorOut, colorIn.visual.r, colorIn.visual.g, colorIn.visual.b,
+ return gfxop_set_color(state, colorOut, colorIn.visual.r, colorIn.visual.g, colorIn.visual.b,
colorIn.alpha, colorIn.priority, colorIn.control);
else
- return gfxop_set_color(state, colorOut, -1, -1, -1, colorIn.alpha,
+ return gfxop_set_color(state, colorOut, -1, -1, -1, colorIn.alpha,
colorIn.priority, colorIn.control);
}
@@ -885,7 +885,7 @@ int gfxop_draw_line(gfx_state_t *state, Common::Point start, Common::Point end,
end.x += xfact >> 1;
end.y += yfact >> 1;
}
-
+
if (color.visual.parent_index == GFX_COLOR_INDEX_UNMAPPED)
gfxop_set_color(state, &color, color);
return _gfxop_draw_line_clipped(state, start, end, color, line_mode, line_style);
@@ -1892,11 +1892,13 @@ int gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette)
// Text operations
+// FIXME: only the resstate member of state is used -- inline the reference by:
+// replacing gfx_state_t* state parameter with gfx_resstate_t* gfxResourceState and adjust callers accordingly
int gfxop_get_font_height(gfx_state_t *state, int font_nr) {
gfx_bitmap_font_t *font;
BASIC_CHECKS(GFX_FATAL);
- font = gfxr_get_font(state->resstate, font_nr, 0);
+ font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
if (!font)
return GFX_ERROR;
@@ -1910,7 +1912,7 @@ int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, int
BASIC_CHECKS(GFX_FATAL);
- font = gfxr_get_font(state->resstate, font_nr, 0);
+ font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
if (!font) {
GFXERROR("Attempt to calculate text size with invalid font #%d\n", font_nr);
@@ -1945,10 +1947,10 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i
error |= gfxop_set_color(state, &bg_color, bg_color);
if (error) {
GFXERROR("Unable to set up colors");
- return NULL;
+ return NULL;
}
-
- font = gfxr_get_font(state->resstate, font_nr, 0);
+
+ font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
if (!font) {
GFXERROR("Attempt to draw text with invalid font #%d\n", font_nr);
diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp
index 6ddd89bb18..82af489874 100644
--- a/engines/sci/gfx/resmgr.cpp
+++ b/engines/sci/gfx/resmgr.cpp
@@ -65,7 +65,7 @@ gfx_resstate_t *gfxr_new_resource_manager(int version, gfx_options_t *options, g
gfx_resource_type_t i = (gfx_resource_type_t) ii;
sbtree_t *tree;
int entries_nr;
- int *resources = gfxr_interpreter_get_resources(state->resManager, i, version, &entries_nr);
+ int *resources = gfxr_interpreter_get_resources(*(state->resManager), i, version, &entries_nr);
if (!resources)
state->resource_trees[i] = NULL;
@@ -459,7 +459,7 @@ gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, i
res = (gfx_resource_t *) sbtree_get(tree, nr);
if (!res || res->mode != hash) {
- view = gfxr_interpreter_get_view(state->resManager, nr, palette, state->static_palette, state->version);
+ view = gfxr_interpreter_get_view(*(state->resManager), nr, palette, state->static_palette, state->version);
if (!view)
return NULL;
@@ -527,7 +527,7 @@ gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, i
return view;
}
-gfx_bitmap_font_t *gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) {
+gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_t *state, int nr, int scaled) {
gfx_resource_type_t restype = GFX_RESOURCE_TYPE_FONT;
sbtree_t *tree = NULL;
gfx_resource_t *res = NULL;
@@ -543,7 +543,7 @@ gfx_bitmap_font_t *gfxr_get_font(gfx_resstate_t *state, int nr, int scaled) {
res = (gfx_resource_t *)sbtree_get(tree, nr);
if (!res || res->mode != hash) {
- gfx_bitmap_font_t *font = gfxr_interpreter_get_font(state->resManager, nr);
+ gfx_bitmap_font_t *font = gfxr_interpreter_get_font(resourceManager, nr);
if (!font)
return NULL;
@@ -583,7 +583,7 @@ gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr) {
res = (gfx_resource_t *)sbtree_get(tree, nr);
if (!res || res->mode != hash) {
- gfx_pixmap_t *cursor = gfxr_interpreter_get_cursor(state->resManager, nr, state->version);
+ gfx_pixmap_t *cursor = gfxr_interpreter_get_cursor(*(state->resManager), nr, state->version);
if (!cursor)
return NULL;
diff --git a/engines/sci/gfx/resource/res_manager.cpp b/engines/sci/gfx/resource/res_manager.cpp
index ae7fb2f785..dc264b74fd 100644
--- a/engines/sci/gfx/resource/res_manager.cpp
+++ b/engines/sci/gfx/resource/res_manager.cpp
@@ -71,8 +71,8 @@ void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *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) {
- ResourceManager *resmgr = state->resManager;
- Resource *res = resmgr->findResource(kResourceTypePic, nr, 0);
+ ResourceManager& resourceManager = *(state->resManager);
+ Resource *res = resourceManager.findResource(kResourceTypePic, nr, 0);
int need_unscaled = unscaled_pic != NULL;
gfxr_pic0_params_t style, basic_style;
@@ -142,8 +142,8 @@ void gfxr_palettize_view(gfxr_view_t *view, Palette *source) {
gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size);
-gfxr_view_t *gfxr_interpreter_get_view(ResourceManager* resourceManager, int nr, int palette, Palette* staticPalette, int version) {
- Resource *res = resourceManager->findResource(kResourceTypeView, nr, 0);
+gfxr_view_t *gfxr_interpreter_get_view(ResourceManager& resourceManager, int nr, int palette, Palette* staticPalette, int version) {
+ Resource *res = resourceManager.findResource(kResourceTypeView, nr, 0);
int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr);
gfxr_view_t *result = 0;
@@ -179,17 +179,16 @@ gfxr_view_t *gfxr_interpreter_get_view(ResourceManager* resourceManager, int nr,
return result;
}
-gfx_bitmap_font_t *gfxr_interpreter_get_font(ResourceManager* resourceManager, int nr) {
- Resource *res = resourceManager->findResource(kResourceTypeFont, nr, 0);
-
+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);
+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)
@@ -203,7 +202,7 @@ gfx_pixmap_t *gfxr_interpreter_get_cursor(ResourceManager* resourceManager, int
return gfxr_draw_cursor(resid, res->data, res->size, version != SCI_VERSION_0);
}
-int *gfxr_interpreter_get_resources(ResourceManager* resourceManager, gfx_resource_type_t type, int version, int *entries_nr) {
+int *gfxr_interpreter_get_resources(ResourceManager& resourceManager, gfx_resource_type_t type, int version, int *entries_nr) {
ResourceType restype;
int *resources;
int count = 0;
@@ -235,7 +234,7 @@ int *gfxr_interpreter_get_resources(ResourceManager* resourceManager, gfx_resour
resources = (int *)sci_malloc(sizeof(int) * top);
for (i = 0; i < top; i++)
- if (resourceManager->testResource(restype, i))
+ if (resourceManager.testResource(restype, i))
resources[count++] = i;
*entries_nr = count;
@@ -243,7 +242,7 @@ int *gfxr_interpreter_get_resources(ResourceManager* resourceManager, gfx_resour
return resources;
}
-Palette *gfxr_interpreter_get_static_palette(ResourceManager *resourceManager, int version, int *colors_nr) {
+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);
@@ -251,13 +250,13 @@ Palette *gfxr_interpreter_get_static_palette(ResourceManager *resourceManager, i
return gfx_sci0_pic_colors->getref();
}
-Palette *gfxr_interpreter_get_palette(ResourceManager *resourceManager, int version, int *colors_nr, int nr) {
+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);
+ res = resourceManager.findResource(kResourceTypePalette, nr, 0);
if (!res || !res->data)
return NULL;