comparison engine/core/video/animation.h @ 150:6e7d228def30

Lazy loading for animations. Uses a Resource-Pointer class that behaves like a pointer to an IResource, but only loads the resource on demand. There's a slight change of API, which is already adapted to in the XML loaders. If you use Animation.addFrame directly, either adapt to the change or wait a few hours for a backwards compatibility solution.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 11 Oct 2008 12:03:59 +0000
parents 90005975cdbb
children 3804348fe3fb
comparison
equal deleted inserted replaced
149:823544621b5b 150:6e7d228def30
35 // FIFE includes 35 // FIFE includes
36 // These includes are split up in two parts, separated by one empty line 36 // These includes are split up in two parts, separated by one empty line
37 // First block: files included from the FIFE root src directory 37 // First block: files included from the FIFE root src directory
38 // Second block: files included from the same folder 38 // Second block: files included from the same folder
39 #include "util/base/resourceclass.h" 39 #include "util/base/resourceclass.h"
40 #include "util/resource/resource_ptr.h"
40 41
41 namespace FIFE { 42 namespace FIFE {
42 43
43 class Image; 44 class Image;
44 45
70 * Frames must be added starting from first frame. Increases the reference 71 * Frames must be added starting from first frame. Increases the reference
71 * count of the given image. 72 * count of the given image.
72 * @param image Pointer to Image. Does not transfer the ownership 73 * @param image Pointer to Image. Does not transfer the ownership
73 * @param duration Duration for given frame in the animation 74 * @param duration Duration for given frame in the animation
74 */ 75 */
75 void addFrame(Image* image, unsigned int duration); 76 void addFrame(ResourcePtr image, unsigned int duration);
76 77
77 /** Get the frame index that matches given timestamp. In case there is no exact match, 78 /** Get the frame index that matches given timestamp. In case there is no exact match,
78 * correct frame is calculated. E.g. if there are frames for timestamps 50 and 100 79 * correct frame is calculated. E.g. if there are frames for timestamps 50 and 100
79 * and frame for 75 is asked, frame associated with value 50 is given back. 80 * and frame for 75 is asked, frame associated with value 50 is given back.
80 * In case the timestamp is past the sequence, negative value is returned 81 * In case the timestamp is past the sequence, negative value is returned
135 /** Contains information about one animation frame (duration + frame index + frame pointer) 136 /** Contains information about one animation frame (duration + frame index + frame pointer)
136 */ 137 */
137 struct FrameInfo { 138 struct FrameInfo {
138 unsigned int index; 139 unsigned int index;
139 unsigned int duration; 140 unsigned int duration;
140 Image* img; 141 ResourcePtr image;
141 }; 142 };
142 143
143 ResourceLocation m_location; 144 ResourceLocation m_location;
144 145
145 /** Checks for animation frame index overflows 146 /** Checks for animation frame index overflows