File: Atomic-render.patch

package info (click to toggle)
rlottie 0.1%2Bdfsg-4.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,948 kB
  • sloc: cpp: 20,376; asm: 221; ansic: 194; makefile: 16
file content (46 lines) | stat: -rw-r--r-- 1,623 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Description: Make the render() method really atomic
 Value of the mRenderInProgress flag should be checked and updated in a single
 operation or its atomic characteristics will not work.
Author: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Sat, 10 Sep 2022 18:41:59 +0300

--- a/src/lottie/lottieanimation.cpp
+++ b/src/lottie/lottieanimation.cpp
@@ -74,7 +74,7 @@ private:
     std::shared_ptr<LOTModel>    mModel;
     std::unique_ptr<LOTCompItem> mCompItem;
     SharedRenderTask             mTask;
-    std::atomic<bool>            mRenderInProgress;
+    std::atomic_flag             mRenderInProgress;
 };
 
 void AnimationImpl::setValue(const std::string &keypath, LOTVariant &&value)
@@ -104,17 +104,15 @@ bool AnimationImpl::update(size_t frameN
 
 Surface AnimationImpl::render(size_t frameNo, const Surface &surface, bool keepAspectRatio)
 {
-    bool renderInProgress = mRenderInProgress.load();
-    if (renderInProgress) {
+    if (mRenderInProgress.test_and_set()) {
         vCritical << "Already Rendering Scheduled for this Animation";
         return surface;
     }
 
-    mRenderInProgress.store(true);
     update(frameNo,
            VSize(int(surface.drawRegionWidth()), int(surface.drawRegionHeight())), keepAspectRatio);
     mCompItem->render(surface);
-    mRenderInProgress.store(false);
+    mRenderInProgress.clear();
 
     return surface;
 }
@@ -123,7 +121,7 @@ void AnimationImpl::init(const std::shar
 {
     mModel = model;
     mCompItem = std::make_unique<LOTCompItem>(mModel.get());
-    mRenderInProgress = false;
+    mRenderInProgress.clear();
 }
 
 #ifdef LOTTIE_THREAD_SUPPORT