summaryrefslogtreecommitdiff
path: root/src/media.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/media.c')
-rw-r--r--src/media.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/media.c b/src/media.c
index 180c28e6..eb4a8311 100644
--- a/src/media.c
+++ b/src/media.c
@@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
24#include "gmdocument.h" 24#include "gmdocument.h"
25#include "gmrequest.h" 25#include "gmrequest.h"
26#include "ui/window.h" 26#include "ui/window.h"
27#include "ui/paint.h" /* size_SDLTexture */
27#include "audio/player.h" 28#include "audio/player.h"
28#include "app.h" 29#include "app.h"
29#include "stb_image.h" 30#include "stb_image.h"
@@ -262,8 +263,28 @@ void clear_Media(iMedia *d) {
262} 263}
263 264
264size_t memorySize_Media(const iMedia *d) { 265size_t memorySize_Media(const iMedia *d) {
265 /* TODO: Calculate the actual memory use. */ 266 size_t memSize = 0;
266 return 0; 267 iConstForEach(PtrArray, i, &d->images) {
268 const iGmImage *img = i.ptr;
269 if (img->texture) {
270 const iInt2 texSize = size_SDLTexture(img->texture);
271 memSize += 4 * texSize.x * texSize.y; /* RGBA */
272 }
273 else {
274 memSize += size_Block(&img->partialData);
275 }
276 }
277 iConstForEach(PtrArray, a, &d->audio) {
278 const iGmAudio *audio = a.ptr;
279 if (audio->player) {
280 memSize += sourceDataSize_Player(audio->player);
281 }
282 }
283 iConstForEach(PtrArray, n, &d->downloads) {
284 const iGmDownload *down = n.ptr;
285 memSize += down->numBytes;
286 }
287 return memSize;
267} 288}
268 289
269iBool setDownloadUrl_Media(iMedia *d, iGmLinkId linkId, const iString *url) { 290iBool setDownloadUrl_Media(iMedia *d, iGmLinkId linkId, const iString *url) {