From 389f629649dbe680193b18decc13cce31824172c Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Sun, 28 Jun 2020 03:47:14 +0200 Subject: [PATCH] proper destruction and dirty reporting for mng and movie guichan images --- src/include/movie.h | 2 +- src/include/video.h | 2 ++ src/video/mng.cpp | 5 ++++- src/video/movie.cpp | 12 +++++++----- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/include/movie.h b/src/include/movie.h index 52bc9c68c..fa28d46e9 100644 --- a/src/include/movie.h +++ b/src/include/movie.h @@ -87,7 +87,7 @@ class Movie : public gcn::Image { public: Movie() : rect(NULL), yuv_overlay(NULL), surface(NULL), need_data(true), start_time(0), - is_dirty(true), Width(0), Height(0), data(NULL) {}; + is_dirty(true), Width(0), Height(0), data(NULL), f(NULL) {}; ~Movie(); int Load(const std::string &filename, int w, int h); bool IsPlaying() const { return is_dirty; } diff --git a/src/include/video.h b/src/include/video.h index 4d5b36549..70d7870b4 100644 --- a/src/include/video.h +++ b/src/include/video.h @@ -155,7 +155,9 @@ public: virtual void *_getData() const; virtual int getWidth() const { return surface->h; } virtual int getHeight() const { return surface->w; } + virtual bool isDirty() const { return is_dirty; } + mutable bool is_dirty; std::string name; FILE *fd; mng_handle handle; diff --git a/src/video/mng.cpp b/src/video/mng.cpp index bc5422cf3..7b4d59305 100644 --- a/src/video/mng.cpp +++ b/src/video/mng.cpp @@ -184,7 +184,7 @@ static mng_bool MNG_DECL my_errorproc(mng_handle handle, mng_int32, Mng::Mng() : name(NULL), fd(NULL), handle(NULL), surface(NULL), buffer(NULL), - ticks(0), iteration(0) + ticks(0), iteration(0), is_dirty(false) { } @@ -265,7 +265,10 @@ void Mng::Reset() void* Mng::_getData() const { if (ticks <= GetTicks()) { + is_dirty = true; mng_display_resume(handle); + } else { + is_dirty = false; } return surface; } diff --git a/src/video/movie.cpp b/src/video/movie.cpp index e46a106dc..4752e99a1 100644 --- a/src/video/movie.cpp +++ b/src/video/movie.cpp @@ -426,17 +426,19 @@ int PlayMovie(const std::string &name) Movie::~Movie() { if (rect != NULL) { - // free(rect); + free(rect); } if (surface != NULL) { - // SDL_FreeSurface(surface); + SDL_FreeSurface(surface); } if (yuv_overlay != NULL) { - // SDL_DestroyTexture(yuv_overlay); + SDL_DestroyTexture(yuv_overlay); } if (data != NULL) { - // data.File->close(); - // OggFree(&data); + OggFree(data); + } + if (f != NULL) { + delete f; } }