File: Cache-compatibility.patch

package info (click to toggle)
rlottie 0.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,864 kB
  • sloc: cpp: 20,368; asm: 221; ansic: 194; makefile: 15
file content (110 lines) | stat: -rw-r--r-- 3,903 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Description: Hacks for cache compatibility
 In order to provide backward compatibility with previous versions of the
 package available in Debian, the patch temporary reintroduces the loadFromFile
 and the loadFromData methods with old signature. These methods are intended for
 use by non-rebuilt binaries.
 .
 The modification turns caching off by default. If a client supports rlottie's
 cache, it may call configureModelCacheSize to inform the library.
Author: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Thu, 05 Mar 2020 21:16:01 +0300

--- a/inc/rlottie.h
+++ b/inc/rlottie.h
@@ -480,6 +480,36 @@ private:
      */
     Animation();
 
+#ifdef LOT_BUILD
+    /**
+     *  @brief Constructs an animation object from file path.
+     *
+     *  @param[in] path Lottie resource file path
+     *
+     *  @return Animation object that can render the contents of the
+     *          Lottie resource represented by file path.
+     *
+     *  @internal
+     */
+    static std::unique_ptr<Animation>
+    loadFromFile(const std::string &path);
+
+    /**
+     *  @brief Constructs an animation object from JSON string data.
+     *
+     *  @param[in] jsonData The JSON string data.
+     *  @param[in] key the string that will be used to cache the JSON string data.
+     *  @param[in] resourcePath the path will be used to search for external resource.
+     *
+     *  @return Animation object that can render the contents of the
+     *          Lottie resource represented by JSON string data.
+     *
+     *  @internal
+     */
+    static std::unique_ptr<Animation>
+    loadFromData(std::string jsonData, const std::string &key, const std::string &resourcePath);
+#endif
+
     std::unique_ptr<AnimationImpl> d;
 };
 
--- a/src/binding/c/lottieanimation_capi.cpp
+++ b/src/binding/c/lottieanimation_capi.cpp
@@ -36,7 +36,7 @@ struct Lottie_Animation_S
 
 LOT_EXPORT Lottie_Animation_S *lottie_animation_from_file(const char *path)
 {
-    if (auto animation = Animation::loadFromFile(path) ) {
+    if (auto animation = Animation::loadFromFile(path, true) ) {
         Lottie_Animation_S *handle = new Lottie_Animation_S();
         handle->mAnimation = std::move(animation);
         return handle;
@@ -47,7 +47,7 @@ LOT_EXPORT Lottie_Animation_S *lottie_an
 
 LOT_EXPORT Lottie_Animation_S *lottie_animation_from_data(const char *data, const char *key, const char *resourcePath)
 {
-    if (auto animation = Animation::loadFromData(data, key, resourcePath) ) {
+    if (auto animation = Animation::loadFromData(data, key, resourcePath, true) ) {
         Lottie_Animation_S *handle = new Lottie_Animation_S();
         handle->mAnimation = std::move(animation);
         return handle;
--- a/src/lottie/lottieanimation.cpp
+++ b/src/lottie/lottieanimation.cpp
@@ -265,6 +265,13 @@ std::unique_ptr<Animation> Animation::lo
     return nullptr;
 }
 
+std::unique_ptr<Animation> Animation::loadFromData(
+    std::string jsonData, const std::string &key,
+    const std::string &resourcePath)
+{
+    return loadFromData(std::move(jsonData), key, resourcePath, true);
+}
+
 std::unique_ptr<Animation>
 Animation::loadFromFile(const std::string &path, bool cachePolicy)
 {
@@ -282,6 +289,12 @@ Animation::loadFromFile(const std::strin
     return nullptr;
 }
 
+std::unique_ptr<Animation>
+Animation::loadFromFile(const std::string &path)
+{
+    return loadFromFile(path, true);
+}
+
 void Animation::size(size_t &width, size_t &height) const
 {
     VSize sz = d->size();
--- a/src/lottie/lottieloader.cpp
+++ b/src/lottie/lottieloader.cpp
@@ -71,7 +71,7 @@ private:
 
     std::unordered_map<std::string, std::shared_ptr<LOTModel>>  mHash;
     std::mutex                                                  mMutex;
-    size_t                                                      mcacheSize{10};
+    size_t                                                      mcacheSize{0};
 };
 
 #else