diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2012-08-13 14:56:36 +0400 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2012-08-13 14:56:36 +0400 |
commit | e28fcec04201fb3be19960a0b91fcb20f8d6c56d (patch) | |
tree | dffeb25323ad214ac86f6b4cb0d126d729643eba /source/blender/compositor/operations/COM_MovieDistortionOperation.h | |
parent | 64e0202314531f2435d518f522b8f06e956c2f3d (diff) |
Fix for [#32220] regression - DistortionCache is never freed.
* at max 10 cache items will be available. Items will be removed by
latest usage.
* number of cached items can be adjusted in code
* added deinitialization of compositor when blender exists.
* updated scons and cmake build files
Diffstat (limited to 'source/blender/compositor/operations/COM_MovieDistortionOperation.h')
-rw-r--r-- | source/blender/compositor/operations/COM_MovieDistortionOperation.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index a58349f9324..00723d92a84 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -27,8 +27,11 @@ #include "DNA_movieclip_types.h" extern "C" { #include "BKE_tracking.h" + #include "PIL_time.h" } +#define COM_DISTORTIONCACHE_MAXSIZE 10 + class DistortionCache { private: float m_k1; @@ -44,6 +47,8 @@ private: bool m_inverted; float *m_buffer; int *m_bufferCalculated; + double timeLastUsage; + public: DistortionCache(MovieClip *movieclip, int width, int height, int calibration_width, int calibration_height, bool inverted) { this->m_k1 = movieclip->tracking.camera.k1; @@ -62,7 +67,29 @@ public: for (int i = 0; i < this->m_width * this->m_height; i++) { this->m_bufferCalculated[i] = 0; } + this->updateLastUsage(); + } + + ~DistortionCache() { + if (this->m_buffer) { + delete[] this->m_buffer; + this->m_buffer = NULL; + } + + if (this->m_bufferCalculated) { + delete[] this->m_bufferCalculated; + this->m_bufferCalculated = NULL; + } } + + void updateLastUsage() { + this->timeLastUsage = PIL_check_seconds_timer(); + } + + inline double getTimeLastUsage() { + return this->timeLastUsage; + } + bool isCacheFor(MovieClip *movieclip, int width, int height, int calibration_width, int claibration_height, bool inverted) { return this->m_k1 == movieclip->tracking.camera.k1 && this->m_k2 == movieclip->tracking.camera.k2 && @@ -139,4 +166,6 @@ public: void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } }; +void deintializeDistortionCache(void); + #endif |