ui.images: use MEMO: instead of explicit cache
parent
628c219495
commit
0bbc63f865
|
@ -1,28 +1,18 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: namespaces cache images images.loader accessors assocs
|
USING: namespaces cache images images.loader accessors assocs
|
||||||
kernel opengl opengl.gl opengl.textures ui.gadgets.worlds ;
|
kernel opengl opengl.gl opengl.textures ui.gadgets.worlds
|
||||||
|
memoize ;
|
||||||
IN: ui.images
|
IN: ui.images
|
||||||
|
|
||||||
TUPLE: image-name path ;
|
TUPLE: image-name path ;
|
||||||
|
|
||||||
C: <image-name> image-name
|
C: <image-name> image-name
|
||||||
|
|
||||||
<PRIVATE
|
MEMO: cached-image ( image-name -- image ) path>> load-image ;
|
||||||
|
|
||||||
SYMBOL: image-cache
|
|
||||||
|
|
||||||
image-cache [ <cache-assoc> ] initialize
|
|
||||||
|
|
||||||
PRIVATE>
|
|
||||||
|
|
||||||
: cached-image ( image-name -- image )
|
|
||||||
path>> image-cache get [ load-image ] cache ;
|
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
SLOT: images
|
|
||||||
|
|
||||||
: image-texture-cache ( world -- texture-cache )
|
: image-texture-cache ( world -- texture-cache )
|
||||||
[ [ <cache-assoc> ] unless* ] change-images images>> ;
|
[ [ <cache-assoc> ] unless* ] change-images images>> ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue