Remove LOW_MEM compile-time option

Per @Vultraz
This commit is contained in:
Gregory A Lundberg 2016-11-11 09:19:50 -06:00
parent bd2d040f2a
commit f23127e65a
18 changed files with 3 additions and 114 deletions

View file

@ -51,7 +51,6 @@ option(ENABLE_TOOLS "Enable building and installation of tools for artists and W
option(ENABLE_SDL2_TOOLS "Enable building and installation of tools for testing with SDL2" OFF)
option(ENABLE_TESTS "Build unit tests")
option(ENABLE_NLS "Enable building of translations" ON)
option(ENABLE_LOW_MEM "Reduce memory usage by removing extra functionality" OFF)
option(ENABLE_OMP "Enables OpenMP, and has additional dependencies" OFF)
option(ENABLE_LIBPNG "Enable support for writing png files (screenshots, images)" ON)
option(ENABLE_LIBINTL "Enable using libintl for translations instead of Boost.Locale library (not recommended)" OFF)
@ -534,10 +533,6 @@ if(DEFAULT_PREFS_FILE)
endif(NOT DEFAULT_PREFS_FILE MATCHES "^/")
endif(DEFAULT_PREFS_FILE)
if(ENABLE_LOW_MEM)
add_definitions(-DLOW_MEM)
endif(ENABLE_LOW_MEM)
if(ENABLE_OMP)
find_package(OpenMP REQUIRED)
set(CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${CMAKE_C_FLAGS}")

View file

@ -70,7 +70,6 @@ opts.AddVariables(
PathVariable('mandir', 'sets the man pages directory to a non-default location', "$datarootdir/man", PathVariable.PathAccept),
PathVariable('docdir', 'sets the doc directory to a non-default location', "$datarootdir/doc/wesnoth", PathVariable.PathAccept),
PathVariable('python_site_packages_dir', 'sets the directory where python modules are installed', "lib/python/site-packages/wesnoth", PathVariable.PathAccept),
BoolVariable('lowmem', 'Set to reduce memory usage by removing extra functionality', False),
BoolVariable('notifications', 'Enable support for desktop notifications', True),
BoolVariable('nls','enable compile/install of gettext message catalogs',True),
BoolVariable('libintl', 'Use lib intl for translations, instead of boost locale', False),
@ -513,9 +512,6 @@ for env in [test_env, client_env, env]:
env["OPT_FLAGS"] = "-g0"
env["DEBUG_FLAGS"] = "-g"
if env['lowmem']:
env.Append(CPPDEFINES = "LOW_MEM")
if env['internal_data']:
env.Append(CPPDEFINES = "USE_INTERNAL_DATA")

View file

@ -1,6 +1,8 @@
Version 1.13.6+dev:
* Language and i18n:
* Updated translations: British English
* WML Engine:
* Removed LOW_MEM option when building.
Version 1.13.6:
* AI:

View file

@ -75,10 +75,6 @@ void config_cache::clear_defines()
// Set-up default defines map.
//
#ifdef LOW_MEM
defines_map_["LOW_MEM"] = preproc_define();
#endif
#ifdef __APPLE__
defines_map_["APPLE"] = preproc_define();
#endif

View file

@ -29,18 +29,11 @@ static lg::log_domain log_mp_connect_engine("mp/connect/engine");
namespace ng {
#ifdef LOW_MEM
std::string get_RC_suffix(const std::string&, const int)
{
return "";
}
#else
std::string get_RC_suffix(const std::string& unit_color, const std::string& color)
{
return "~RC(" + unit_color + ">" + color +
")";
}
#endif
flg_manager::flg_manager(const std::vector<const config*>& era_factions,

View file

@ -407,15 +407,11 @@ void wait::generate_menu()
const unit_type &utg = ut->get_gender_unit_type(gender_id);
leader_name = utg.type_name();
#ifdef LOW_MEM
leader_image = utg.image();
#else
std::string RCcolor = sd["color"];
if (RCcolor.empty())
RCcolor = sd["side"].str();
leader_image = utg.image() + std::string("~RC(") + utg.flag_rgb() + ">" + RCcolor + ")";
#endif
} else {
leader_image = ng::random_enemy_picture;
}

View file

@ -134,10 +134,8 @@ window* build(CVideo& video, const std::string& type)
builder_widget::builder_widget(const config& cfg)
: id(cfg["id"])
, linked_group(cfg["linked_group"])
#ifndef LOW_MEM
, debug_border_mode(cfg["debug_border_mode"])
, debug_border_color(decode_color(cfg["debug_border_color"]))
#endif
{
}

View file

@ -65,10 +65,8 @@ public:
std::string id;
std::string linked_group;
#ifndef LOW_MEM
int debug_border_mode;
unsigned debug_border_color;
#endif
};
typedef std::shared_ptr<builder_widget> builder_widget_ptr;

View file

@ -683,10 +683,8 @@ void builder_styled_widget::init_control(styled_widget* control) const
control->set_help_message(help);
control->set_use_tooltip_on_label_overflow(use_tooltip_on_label_overflow);
control->set_use_markup(use_markup);
#ifndef LOW_MEM
control->set_debug_border_mode(debug_border_mode);
control->set_debug_border_colour(debug_border_color);
#endif
}
widget* builder_styled_widget::build(const replacements_map& /*replacements*/) const

View file

@ -108,21 +108,12 @@ struct value_type
unsigned age;
};
#ifdef LOW_MEM
/**
* Maximum number of items in the cache (multiple of 4).
*
* As small as possible for low mem.
*/
static const size_t cache_max_size = 4;
#else
/**
* Maximum number of items in the cache (multiple of 4).
*
* No testing on the optimal number is done, just seems a nice number.
*/
static const size_t cache_max_size = 100;
#endif
/**
* The terrain used to create the cache.

View file

@ -41,10 +41,8 @@ widget::widget()
, visible_(visibility::visible)
, redraw_action_(redraw_action::full)
, clipping_rectangle_()
#ifndef LOW_MEM
, debug_border_mode_(0)
, debug_border_colour_(0)
#endif
{
DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
}
@ -65,10 +63,8 @@ widget::widget(const builder_widget& builder)
, visible_(visibility::visible)
, redraw_action_(redraw_action::full)
, clipping_rectangle_()
#ifndef LOW_MEM
, debug_border_mode_(builder.debug_border_mode)
, debug_border_colour_(builder.debug_border_color)
#endif
{
DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
}
@ -479,8 +475,6 @@ widget::redraw_action widget::get_drawing_action() const
: redraw_action_;
}
#ifndef LOW_MEM
void widget::set_debug_border_mode(const unsigned debug_border_mode)
{
debug_border_mode_ = debug_border_mode;
@ -540,8 +534,6 @@ widget::draw_debug_border(surface& frame_buffer, int x_offset, int y_offset)
}
}
#endif
/***** ***** ***** ***** Query functions ***** ***** ***** *****/
widget* widget::find_at(const point& coordinate, const bool must_be_active)

View file

@ -664,14 +664,10 @@ public:
redraw_action get_drawing_action() const;
#ifndef LOW_MEM
void set_debug_border_mode(const unsigned debug_border_mode);
void set_debug_border_colour(const unsigned debug_border_colour);
#endif
/*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
private:
@ -695,8 +691,6 @@ private:
/** The clipping rectangle if a widget is partly visible. */
SDL_Rect clipping_rectangle_;
#ifndef LOW_MEM
/**
* Mode for drawing the debug border.
*
@ -716,18 +710,6 @@ private:
void draw_debug_border(surface& frame_buffer);
void draw_debug_border(surface& frame_buffer, int x_offset, int y_offset);
#else
void draw_debug_border(surface&)
{
}
void draw_debug_border(surface&, int, int)
{
}
#endif
/***** ***** ***** ***** Query functions ***** ***** ***** *****/
public:

View file

@ -245,18 +245,14 @@ std::string unit_topic_generator::operator()() const {
ss << "\n\n";
ss << "<img>src='" << male_type.image();
#ifndef LOW_MEM
ss << "~RC(" << male_type.flag_rgb() << ">red)";
#endif
if (screen_width >= 1600) ss << "~XBRZ(2)";
ss << "' box='no'</img> ";
if (&female_type != &male_type) {
ss << "<img>src='" << female_type.image();
#ifndef LOW_MEM
ss << "~RC(" << female_type.flag_rgb() << ">red)";
#endif
if (screen_width >= 1600) ss << "~XBRZ(2)";
ss << "' box='no'</img> ";
}

View file

@ -81,11 +81,7 @@ const size_t n_reserved_channels = UI_sound_channel_last + 1; // sources, bell,
// Max number of sound chunks that we want to cache
// Keep this above number of available channels to avoid busy-looping
#ifdef LOW_MEM
unsigned max_cached_chunks = 64;
#else
unsigned max_cached_chunks = 256;
#endif
std::map< Mix_Chunk*, int > chunk_usage;
@ -263,11 +259,6 @@ static std::string pick_one(const std::string &files)
if (ids.size() == 1)
return ids[0];
#ifdef LOW_MEM
// We're memory constrained, so we shouldn't cache too many chunks
return ids[0];
#endif
// We avoid returning same choice twice if we can avoid it.
static std::map<std::string,unsigned int> prev_choices;
unsigned int choice;

View file

@ -29,11 +29,7 @@ static const int BUTTON_TOGGLE = 102;
namespace {
#ifdef LOW_MEM
std::vector<std::string> create_unit_table(const statistics::stats::str_int_map& m, unsigned int /*team*/)
#else
std::vector<std::string> create_unit_table(const statistics::stats::str_int_map& m, unsigned int team)
#endif
{
std::vector<std::string> table;
for(statistics::stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) {
@ -43,9 +39,7 @@ std::vector<std::string> create_unit_table(const statistics::stats::str_int_map&
std::stringstream str;
str << IMAGE_PREFIX << type->image();
#ifndef LOW_MEM
str << "~RC(" << type->flag_rgb() << ">" << team << ")";
#endif
str << COLUMN_SEPARATOR << type->type_name() << COLUMN_SEPARATOR << i->second << "\n";
table.push_back(str.str());
}

View file

@ -157,14 +157,12 @@ STORY_RESULT controller::show(START_POSITION startpos)
// Build renderer cache unless built for a low-memory environment;
// caching the scaled backgrounds can take over a decent amount of memory.
#ifndef LOW_MEM
std::vector< render_pointer_type > uis_;
for(part_pointer_type p : parts_) {
assert(p != nullptr && "Ouch: hit nullptr storyscreen part in collection");
render_pointer_type const rpt(new part_ui(*p, video_, next_button, back_button, play_button));
uis_.push_back(rpt);
}
#endif
size_t k = 0;
switch(startpos) {
@ -179,11 +177,7 @@ STORY_RESULT controller::show(START_POSITION startpos)
}
while(k < parts_.size()) {
#ifndef LOW_MEM
part_ui &render_interface = *uis_[k];
#else
part_ui render_interface(*parts_[k], video_, next_button, back_button, play_button);
#endif
LOG_NG << "displaying storyscreen part " << k+1 << " of " << parts_.size() << '\n';

View file

@ -60,7 +60,6 @@ namespace {
const Uint32 titlebox_font_color = 0xFFFFFFFF;
const Uint32 storybox_font_color = 0xDDDDDDFF;
#ifndef LOW_MEM
// Hard-coded path to a suitable (tileable) pic for the storytxt box border.
const std::string storybox_top_border_path = "dialogs/translucent54-border-top.png";
const std::string storybox_bottom_border_path = "dialogs/translucent54-border-bottom.png";
@ -71,7 +70,6 @@ namespace {
blur = blur_surface(blur, 1, false);
video.blit_surface(0, y, blur);
}
#endif
}
namespace storyscreen {
@ -354,10 +352,6 @@ void part_ui::render_title_box()
}
#ifdef LOW_MEM
void part_ui::render_story_box_borders(SDL_Rect& /*update_area*/)
{}
#else
void part_ui::render_story_box_borders(SDL_Rect& update_area)
{
const part::BLOCK_LOCATION tbl = p_.story_text_location();
@ -404,7 +398,6 @@ void part_ui::render_story_box_borders(SDL_Rect& update_area)
}
}
}
#endif
void part_ui::render_story_box()
{
@ -528,11 +521,9 @@ void part_ui::render_story_box()
back_button_.hide();
play_button_.hide();
#ifndef LOW_MEM
if (dirty_ || first) {
blur_area(video_, fix_text_y, fix_text_h);
}
#endif
if (dirty_ || first) {
sdl::draw_solid_tinted_rectangle(
0, fix_text_y, screen_area().w, fix_text_h,
@ -542,7 +533,7 @@ void part_ui::render_story_box()
);
}
render_story_box_borders(update_area); // no-op if LOW_MEM is defined
render_story_box_borders(update_area);
next_button_.hide(false);
back_button_.hide(false);

View file

@ -698,11 +698,7 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
const int x = static_cast<int>(tmp_offset * xdst + (1.0-tmp_offset) * xsrc) + d2;
const int y = static_cast<int>(tmp_offset * ydst + (1.0-tmp_offset) * ysrc) + d2;
if (image != nullptr) {
#ifdef LOW_MEM
bool facing_west = false;
#else
bool facing_west = direction == map_location::NORTH_WEST || direction == map_location::SOUTH_WEST;
#endif
bool facing_north = direction == map_location::NORTH_WEST || direction == map_location::NORTH || direction == map_location::NORTH_EAST;
if(!current_data.auto_hflip) facing_west = false;
if(!current_data.auto_vflip) facing_north = true;
@ -842,11 +838,7 @@ std::set<map_location> unit_frame::get_overlaped_hex(const int frame_time,const
if (w != 0 || h != 0) {
const int x = static_cast<int>(tmp_offset * xdst + (1.0-tmp_offset) * xsrc);
const int y = static_cast<int>(tmp_offset * ydst + (1.0-tmp_offset) * ysrc);
#ifdef LOW_MEM
bool facing_west = false;
#else
bool facing_west = direction == map_location::NORTH_WEST || direction == map_location::SOUTH_WEST;
#endif
bool facing_north = direction == map_location::NORTH_WEST || direction == map_location::NORTH || direction == map_location::NORTH_EAST;
if(!current_data.auto_vflip) facing_north = true;
if(!current_data.auto_hflip) facing_west = false;
@ -1003,11 +995,5 @@ const frame_parameters unit_frame::merge_parameters(int current_time,const frame
if(primary) result.auto_vflip=t_false;
else result.auto_vflip = t_true;
}
#ifdef LOW_MEM
if(primary) {
result.image= engine_val.image;
result.image_diagonal= engine_val.image;
}
#endif
return result;
}