[Bf-blender-cvs] [32f591c0a34] master: Fix T66610: Planar Track extremely laggy when 3D View is open

Sergey Sharybin noreply at git.blender.org
Tue Jul 9 15:46:50 CEST 2019


Commit: 32f591c0a344e2e02e7740f487a55c154281501f
Author: Sergey Sharybin
Date:   Tue Jul 9 15:43:42 2019 +0200
Branches: master
https://developer.blender.org/rB32f591c0a344e2e02e7740f487a55c154281501f

Fix T66610: Planar Track extremely laggy when 3D View is open

The issue was caused by modifications to planar track tagging clip for
copy-on-write, which was invalidating its cache and forcing current
frame in 3D viewport to be re-load.

Ideal solution would be to share movie cache across original and
evaluated movie clips which will reduce memory usage. However, doing
such ownership changes so close to the code freeze is not something
comfortable to do.

===================================================================

M	source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

===================================================================

diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 3fef7fc9c02..453e9e06a6a 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -1334,6 +1334,50 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object)
   }
 }
 
+/* Backup of movie clip runtime data. */
+
+class MovieClipBackup {
+ public:
+  MovieClipBackup();
+
+  void reset();
+
+  void init_from_movieclip(MovieClip *movieclip);
+  void restore_to_movieclip(MovieClip *movieclip);
+
+  struct anim *anim;
+  struct MovieClipCache *cache;
+};
+
+MovieClipBackup::MovieClipBackup()
+{
+  reset();
+}
+
+void MovieClipBackup::reset()
+{
+  anim = NULL;
+  cache = NULL;
+}
+
+void MovieClipBackup::init_from_movieclip(MovieClip *movieclip)
+{
+  anim = movieclip->anim;
+  cache = movieclip->cache;
+  /* Clear pointers stored in the movie clip, so they are not freed when copied-on-written
+   * datablock is freed for re-allocation. */
+  movieclip->anim = NULL;
+  movieclip->cache = NULL;
+}
+
+void MovieClipBackup::restore_to_movieclip(MovieClip *movieclip)
+{
+  movieclip->anim = anim;
+  movieclip->cache = cache;
+
+  reset();
+}
+
 class RuntimeBackup {
  public:
   RuntimeBackup() : drawdata_ptr(NULL)
@@ -1352,6 +1396,7 @@ class RuntimeBackup {
   ObjectRuntimeBackup object_backup;
   DrawDataList drawdata_backup;
   DrawDataList *drawdata_ptr;
+  MovieClipBackup movieclip_backup;
 };
 
 void RuntimeBackup::init_from_id(ID *id)
@@ -1370,6 +1415,9 @@ void RuntimeBackup::init_from_id(ID *id)
     case ID_SO:
       sound_backup.init_from_sound(reinterpret_cast<bSound *>(id));
       break;
+    case ID_MC:
+      movieclip_backup.init_from_movieclip(reinterpret_cast<MovieClip *>(id));
+      break;
     default:
       break;
   }
@@ -1395,6 +1443,9 @@ void RuntimeBackup::restore_to_id(ID *id)
     case ID_SO:
       sound_backup.restore_to_sound(reinterpret_cast<bSound *>(id));
       break;
+    case ID_MC:
+      movieclip_backup.restore_to_movieclip(reinterpret_cast<MovieClip *>(id));
+      break;
     default:
       break;
   }



More information about the Bf-blender-cvs mailing list