Misc. Optimizations (#3993)

changes:

Overlays now creates less temporary lists.
Falling no longer queues unsimulated atoms that wouldn't fall anyways (incl. LOs).
Pixel-shifted AO is now cached too.
Changed some references to get_map_cell() to macro equivalents in random maps.
Added smoothing hinting to the icon smoother, allowing for major performance improvements in common cases.
Space initialization no longer involves appearance churn (and is much faster as a result).
This commit is contained in:
Lohikar
2017-12-23 21:27:51 +02:00
committed by Erki
parent 64d24c6979
commit bb5a34eaf8
12 changed files with 213 additions and 131 deletions
+30 -1
View File
@@ -2,7 +2,8 @@
/datum/controller/subsystem/icon_cache
name = "Icon Cache"
flags = SS_NO_FIRE | SS_NO_INIT
flags = SS_NO_FIRE
init_order = SS_INIT_MISC_FIRST
// Cached bloody overlays, key is object type.
var/list/bloody_cache = list()
@@ -67,9 +68,20 @@
var/list/rgb_blend_cache = list() // not an icon per-se, but this proc could be expensive so we might as well cache it.
var/list/space_dust_cache = list()
var/list/space_cache = list()
/datum/controller/subsystem/icon_cache/New()
NEW_SS_GLOBAL(SSicon_cache)
/datum/controller/subsystem/icon_cache/Initialize()
build_dust_cache()
build_space_cache()
setup_collar_mappings()
setup_uniform_mappings()
..()
/datum/controller/subsystem/icon_cache/proc/setup_collar_mappings()
collar_states = list()
for (var/i in icon_states('icons/mob/collar.dmi'))
@@ -94,3 +106,20 @@
var/image/I = new(icon, icon_state)
I.color = color
return I
/datum/controller/subsystem/icon_cache/proc/build_dust_cache()
for (var/i in 0 to 25)
var/image/im = image('icons/turf/space_parallax1.dmi',"[i]")
im.plane = PLANE_SPACE_DUST
im.alpha = 80
im.blend_mode = BLEND_ADD
space_dust_cache["[i]"] = im
/datum/controller/subsystem/icon_cache/proc/build_space_cache()
for (var/i in 0 to 25)
var/image/I = new()
I.appearance = /turf/space
var/istr = "[i]"
I.icon_state = istr
I.overlays += space_dust_cache[istr]
space_cache[istr] = I
@@ -8,6 +8,7 @@ var/datum/controller/subsystem/icon_smooth/SSicon_smooth
flags = SS_TICKER | SS_FIRE_IN_LOBBY
var/list/smooth_queue = list()
var/list/typecachecache = list()
var/explosion_in_progress = FALSE
+27 -19
View File
@@ -102,25 +102,33 @@ var/datum/controller/subsystem/overlays/SSoverlays
. = iconbro.appearance
icon_cache[icon] = .
/atom/proc/build_appearance_list(new_overlays)
var/static/image/appearance_bro = new()
if (!islist(new_overlays))
new_overlays = list(new_overlays)
else
listclearnulls(new_overlays)
for (var/i in 1 to length(new_overlays))
var/image/cached_overlay = new_overlays[i]
if (istext(cached_overlay))
new_overlays[i] = iconstate2appearance(icon, cached_overlay)
else if(isicon(cached_overlay))
new_overlays[i] = icon2appearance(cached_overlay)
else //image probable
appearance_bro.appearance = cached_overlay
if(!ispath(cached_overlay))
appearance_bro.dir = cached_overlay.dir
new_overlays[i] = appearance_bro.appearance
return new_overlays
#define APPEARANCEIFY(origin, target) \
if (istext(origin)) { \
target = iconstate2appearance(icon, origin); \
} \
else if (isicon(origin)) { \
target = icon2appearance(origin); \
} \
else { \
appearance_bro.appearance = origin; \
if (!ispath(origin)) { \
appearance_bro.dir = origin.dir; \
} \
target = appearance_bro.appearance; \
}
/atom/proc/build_appearance_list(atom/new_overlays)
var/static/image/appearance_bro = new
if (islist(new_overlays))
listclearnulls(new_overlays)
for (var/i in 1 to length(new_overlays))
var/image/cached_overlay = new_overlays[i]
APPEARANCEIFY(cached_overlay, new_overlays[i])
return new_overlays
else
APPEARANCEIFY(new_overlays, .)
#undef APPEARANCEIFY
#define NOT_QUEUED_ALREADY (!(overlay_queued))
#define QUEUE_FOR_COMPILE overlay_queued = TRUE; SSoverlays.processing += src;
@@ -165,7 +173,7 @@ var/datum/controller/subsystem/overlays/SSoverlays
overlays = build_appearance_list(overlays)
if (!overlays.len)
if (!overlays || (islist(overlays) && !overlays.len))
// No point trying to compile if we don't have any overlays.
return