From eae6033ae678de48f8e01b2482cc93bd43e74e16 Mon Sep 17 00:00:00 2001
From: NoName <>
Date: Wed, 30 Sep 2020 09:24:46 +0300
Subject: [PATCH 01/12] ADD: rlottie as submodule
---
.gitmodules | 3 +++
sdk/rlottie | 1 +
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 sdk/rlottie
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..a0a2ef0cd
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "sdk/rlottie"]
+ path = sdk/rlottie
+ url = https://github.com/Samsung/rlottie.git
diff --git a/sdk/rlottie b/sdk/rlottie
new file mode 160000
index 000000000..4884e0e9b
--- /dev/null
+++ b/sdk/rlottie
@@ -0,0 +1 @@
+Subproject commit 4884e0e9b3b726c0219f69804f9946a7f3c052f1
From e6235324c622aae243f4a58b34533887708c0075 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82?= <68504048+diamondhat@users.noreply.github.com>
Date: Wed, 30 Sep 2020 09:57:56 +0300
Subject: [PATCH 02/12] Update readme.md
---
readme.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/readme.md b/readme.md
index cae49ec05..ece5507e2 100644
--- a/readme.md
+++ b/readme.md
@@ -1,3 +1,22 @@
+# Lottie compilation
+0. Navigate to repo root directory
+1. git submodule init
+2. git submodule update
+3. cd sdk
+4. cd rlottie
+5. mkdir build
+6. cd build
+
+We don't need a real dependency for user, we make a static library for linking and usage
+7. cmake -DBUILD_SHARED_LIBS=OFF ..
+8. cd ..
+9. cd ..
+10. cd..
+We are in root folder of repository (e.g. C:/users/user/RmlUi/)
+11. mkdir Build
+12. cd Build
+13. cmake -DBUILD_SAMPLES=ON ..
+
# RmlUi - The HTML/CSS User Interface Library Evolved

From 422cbe6a4a6018a356b99c8cf96b14c186283770 Mon Sep 17 00:00:00 2001
From: NoName <>
Date: Wed, 30 Sep 2020 09:58:17 +0300
Subject: [PATCH 03/12] ADD: added rlottie as dependency for this project
---
CMakeLists.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c13bbbf84..3b09e4177 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -295,6 +295,14 @@ if(NOT NO_FONT_INTERFACE_DEFAULT)
endif()
endif()
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/sdk/rlottie/build)
+find_package(rlottie REQUIRED)
+if (RLOTTIE_FOUND)
+ include_directories(${RLOTTIE_INCLUDE_DIRS})
+ link_directories(${RLOTTIE_LINK_DIRS})
+ list(APPEND CORE_LINK_LIBS ${RLOTTIE_LIBRARY})
+endif()
+
#Lua
if(BUILD_LUA_BINDINGS)
find_package(Lua REQUIRED)
From bbc31ecdfcb4083d8ff2f3628e2745c8eb0822f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82?= <68504048+diamondhat@users.noreply.github.com>
Date: Wed, 30 Sep 2020 09:58:54 +0300
Subject: [PATCH 04/12] Update readme.md
---
readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/readme.md b/readme.md
index ece5507e2..fa069dfec 100644
--- a/readme.md
+++ b/readme.md
@@ -8,6 +8,7 @@
6. cd build
We don't need a real dependency for user, we make a static library for linking and usage
+
7. cmake -DBUILD_SHARED_LIBS=OFF ..
8. cd ..
9. cd ..
From 2c5f1bab3ab7beafee9bb7562b641c754f0038e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82?= <68504048+diamondhat@users.noreply.github.com>
Date: Wed, 30 Sep 2020 09:59:10 +0300
Subject: [PATCH 05/12] Update readme.md
---
readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/readme.md b/readme.md
index fa069dfec..b17e8d38d 100644
--- a/readme.md
+++ b/readme.md
@@ -13,6 +13,7 @@ We don't need a real dependency for user, we make a static library for linking a
8. cd ..
9. cd ..
10. cd..
+
We are in root folder of repository (e.g. C:/users/user/RmlUi/)
11. mkdir Build
12. cd Build
From f65f4ae8b0c7d1861930e38da8ac5616e7bd0caa Mon Sep 17 00:00:00 2001
From: NoName <>
Date: Wed, 30 Sep 2020 11:09:32 +0300
Subject: [PATCH 06/12] Add: lots of features, starting implement rlottie
wrapper throught ElementLottie class
---
CMake/FileList.cmake | 2 +
CMakeLists.txt | 8 +--
Samples/assets/lottie.rml | 28 +++++++++++
Samples/basic/loaddocument/src/main.cpp | 2 +-
Source/Core/Elements/ElementLottie.cpp | 52 +++++++++++++++++++
Source/Core/Elements/ElementLottie.h | 66 +++++++++++++++++++++++++
Source/Core/Factory.cpp | 3 ++
7 files changed, 156 insertions(+), 5 deletions(-)
create mode 100644 Samples/assets/lottie.rml
create mode 100644 Source/Core/Elements/ElementLottie.cpp
create mode 100644 Source/Core/Elements/ElementLottie.h
diff --git a/CMake/FileList.cmake b/CMake/FileList.cmake
index 70cd3e0cb..f933cb46b 100644
--- a/CMake/FileList.cmake
+++ b/CMake/FileList.cmake
@@ -26,6 +26,7 @@ set(Core_HDR_FILES
${PROJECT_SOURCE_DIR}/Source/Core/ElementDefinition.h
${PROJECT_SOURCE_DIR}/Source/Core/ElementHandle.h
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementImage.h
+ ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementLottie.h
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementTextSelection.h
${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputType.h
${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeButton.h
@@ -282,6 +283,7 @@ set(Core_SRC_FILES
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControlSelect.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControlTextArea.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementImage.cpp
+ ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementLottie.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementProgressBar.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementTabSet.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementTextSelection.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b09e4177..c86f067fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -297,10 +297,10 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/sdk/rlottie/build)
find_package(rlottie REQUIRED)
-if (RLOTTIE_FOUND)
- include_directories(${RLOTTIE_INCLUDE_DIRS})
- link_directories(${RLOTTIE_LINK_DIRS})
- list(APPEND CORE_LINK_LIBS ${RLOTTIE_LIBRARY})
+if (rlottie_FOUND)
+ message("rlottie FOUND")
+ include_directories(${CMAKE_SOURCE_DIR}/sdk/rlottie/inc/)
+ list(APPEND CORE_LINK_LIBS ${rlottie_LIBRARIES})
endif()
#Lua
diff --git a/Samples/assets/lottie.rml b/Samples/assets/lottie.rml
new file mode 100644
index 000000000..a74882b0c
--- /dev/null
+++ b/Samples/assets/lottie.rml
@@ -0,0 +1,28 @@
+
+
+ Demo
+
+
+
+
+
+
+
diff --git a/Samples/basic/loaddocument/src/main.cpp b/Samples/basic/loaddocument/src/main.cpp
index cfb405013..4130e5b2e 100644
--- a/Samples/basic/loaddocument/src/main.cpp
+++ b/Samples/basic/loaddocument/src/main.cpp
@@ -105,7 +105,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
Shell::LoadFonts("assets/");
// Load and show the demo document.
- if (Rml::ElementDocument * document = context->LoadDocument("assets/demo.rml"))
+ if (Rml::ElementDocument * document = context->LoadDocument("assets/lottie.rml"))
document->Show();
Shell::EventLoop(GameLoop);
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
new file mode 100644
index 000000000..abc32e7a2
--- /dev/null
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -0,0 +1,52 @@
+#include "ElementLottie.h"
+#include "../TextureDatabase.h"
+#include "../../../Include/RmlUi/Core/URL.h"
+#include "../../../Include/RmlUi/Core/PropertyIdSet.h"
+#include "../../../Include/RmlUi/Core/GeometryUtilities.h"
+#include "../../../Include/RmlUi/Core/ElementDocument.h"
+#include "../../../Include/RmlUi/Core/StyleSheet.h"
+
+namespace Rml
+{
+ ElementLottie::ElementLottie(const String& tag) : Element(tag), geometry(this), dimensions(-1.0f, -1.0f)
+ {
+ }
+
+ ElementLottie::~ElementLottie(void)
+ {
+ }
+
+ bool ElementLottie::GetIntrinsicDimensions(Vector2f& dimensions, float& ratio)
+ {
+ return false;
+ }
+
+ void ElementLottie::OnRender()
+ {
+ }
+
+ void ElementLottie::OnResize()
+ {
+ }
+
+ void ElementLottie::OnAttributeChange(const ElementAttributes& changed_attributes)
+ {
+ }
+
+ void ElementLottie::OnPropertyChange(const PropertyIdSet& changed_properties)
+ {
+ }
+
+ void ElementLottie::GenerateGeometry()
+ {
+ }
+
+ bool ElementLottie::LoadTexture()
+ {
+ return false;
+ }
+
+ void ElementLottie::UpdateRect()
+ {
+ }
+}
\ No newline at end of file
diff --git a/Source/Core/Elements/ElementLottie.h b/Source/Core/Elements/ElementLottie.h
new file mode 100644
index 000000000..42bfce684
--- /dev/null
+++ b/Source/Core/Elements/ElementLottie.h
@@ -0,0 +1,66 @@
+#pragma once
+
+#include "../../../Include/RmlUi/Core/Header.h"
+#include "../../../Include/RmlUi/Core/Element.h"
+#include "../../../Include/RmlUi/Core/Geometry.h"
+#include "../../../Include/RmlUi/Core/Texture.h"
+#include "../../../Include/RmlUi/Core/Spritesheet.h"
+
+#include
+
+namespace Rml
+{
+ class RMLUICORE_API ElementLottie : public Element
+ {
+ public:
+ RMLUI_RTTI_DefineWithParent(ElementLottie, Element);
+ ElementLottie(const String& tag);
+
+ virtual ~ElementLottie(void);
+
+ /// Returns the element's inherent size.
+ bool GetIntrinsicDimensions(Vector2f& dimensions, float& ratio) override;
+
+ protected:
+ /// Renders the image.
+ void OnRender() override;
+
+ /// Regenerates the element's geometry.
+ void OnResize() override;
+
+ /// Checks for changes to the image's source or dimensions.
+ /// @param[in] changed_attributes A list of attributes changed on the element.
+ void OnAttributeChange(const ElementAttributes& changed_attributes) override;
+
+ /// Called when properties on the element are changed.
+ /// @param[in] changed_properties The properties changed on the element.
+ void OnPropertyChange(const PropertyIdSet& changed_properties) override;
+
+ private:
+ // Generates the element's geometry.
+ void GenerateGeometry();
+ // Loads the element's texture, as specified by the 'src' attribute.
+ bool LoadTexture();
+ // Loads the rect value from the element's attribute, but only if we're not a sprite.
+ void UpdateRect();
+
+ // The texture this element is rendering from.
+ Texture texture;
+ // True if we need to refetch the texture's source from the element's attributes.
+ bool texture_dirty;
+ // The element's computed intrinsic dimensions. If either of these values are set to -1, then
+ // that dimension has not been computed yet.
+ Vector2f dimensions;
+
+ // The rectangle extracted from the sprite or 'rect' attribute. The rect_source will be None if
+ // these have not been specified or are invalid.
+ Rectangle rect;
+
+ // The geometry used to render this element.
+ Geometry geometry;
+
+ std::unique_ptr m_p_lottie;
+
+ bool geometry_dirty;
+ };
+}
\ No newline at end of file
diff --git a/Source/Core/Factory.cpp b/Source/Core/Factory.cpp
index 3b349b3ed..35a2ab606 100644
--- a/Source/Core/Factory.cpp
+++ b/Source/Core/Factory.cpp
@@ -79,6 +79,7 @@
#include "XMLParseTools.h"
#include "Elements/ElementImage.h"
+#include "Elements/ElementLottie.h"
#include "Elements/ElementTextSelection.h"
#include "Elements/XMLNodeHandlerDataGrid.h"
#include "Elements/XMLNodeHandlerTabSet.h"
@@ -134,6 +135,7 @@ struct DefaultInstancers {
ElementInstancerElement element_default;
ElementInstancerTextDefault element_text_default;
ElementInstancerGeneric element_img;
+ ElementInstancerGeneric element_lottie;
ElementInstancerGeneric element_handle;
ElementInstancerGeneric element_body;
@@ -222,6 +224,7 @@ bool Factory::Initialise()
// Basic element instancers
RegisterElementInstancer("*", &default_instancers->element_default);
RegisterElementInstancer("img", &default_instancers->element_img);
+ RegisterElementInstancer("lottie", &default_instancers->element_lottie);
RegisterElementInstancer("#text", &default_instancers->element_text_default);
RegisterElementInstancer("handle", &default_instancers->element_handle);
RegisterElementInstancer("body", &default_instancers->element_body);
From a90ad4304faf59bfbdd7630a887f20c8efea8b8d Mon Sep 17 00:00:00 2001
From: NoName <>
Date: Wed, 30 Sep 2020 13:38:26 +0300
Subject: [PATCH 07/12] ADD: renders lottie, very raw, don't touch
---
Samples/assets/lottie.json | 1 +
Source/Core/Elements/ElementLottie.cpp | 101 ++++++++++++++++++++++++-
Source/Core/Elements/ElementLottie.h | 12 +--
3 files changed, 106 insertions(+), 8 deletions(-)
create mode 100644 Samples/assets/lottie.json
diff --git a/Samples/assets/lottie.json b/Samples/assets/lottie.json
new file mode 100644
index 000000000..08b20396b
--- /dev/null
+++ b/Samples/assets/lottie.json
@@ -0,0 +1 @@
+{"v":"5.1.7","fr":29.9700012207031,"ip":0,"op":24.00000097754,"w":100,"h":100,"nm":"heart","ddd":0,"assets":[{"id":"comp_4","layers":[{"ddd":0,"ind":1,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":180,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":130,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":90,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":45,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":-135,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":6,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":-90,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":7,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":-45,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":8,"ty":0,"nm":"Shape Layer 2 Comp 2","refId":"comp_5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":0,"op":900.000036657751,"st":0,"bm":0}]},{"id":"comp_5","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 4","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0.281]},"n":["0p667_1_0p333_0p281"],"t":3,"s":[0],"e":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":9,"s":[100],"e":[0]},{"t":17.0000006924242}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":0.567},"o":{"x":0.333,"y":0.406},"n":"0p667_0p567_0p333_0p406","t":3,"s":[39.878,39.582,0],"e":[39.878,22.253,0],"to":[0,-0.83333331346512,0],"ti":[0,2.48720121383667,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.5},"n":"0p667_1_0p333_0p5","t":9,"s":[39.878,22.253,0],"e":[39.878,2.25,0],"to":[0,-8.33440494537354,0],"ti":[0,3.3337619304657,0]},{"t":17.0000006924242}],"ix":2},"a":{"a":0,"k":[-0.122,-27.75,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[15.897,15.897,-17.409]},"o":{"x":[0.333,0.333,0.333],"y":[-44.172,-44.172,107.618]},"n":["0p667_15p897_0p333_-44p172","0p667_15p897_0p333_-44p172","0p667_-17p409_0p333_107p618"],"t":3,"s":[78.68,78.68,100],"e":[78,78,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[-0.562,-0.562,24.545]},"n":["0p667_1_0p333_-0p562","0p667_1_0p333_-0p562","0p667_1_0p333_24p545"],"t":9,"s":[78,78,100],"e":[54,54,100]},{"t":17.0000006924242}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[6.66,6.66],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.909803921569,0.18431372549,0.56862745098,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-0.17,-26.594],"ix":2},"a":{"a":0,"k":[0,1.076],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 3","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0.281]},"n":["0p667_1_0p333_0p281"],"t":0,"s":[0],"e":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":6,"s":[100],"e":[0]},{"t":17.0000006924242}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":0.567},"o":{"x":0.333,"y":0.406},"n":"0p667_0p567_0p333_0p406","t":0,"s":[49.878,39.582,0],"e":[49.878,22.253,0],"to":[0,-2.35414934158325,0],"ti":[0,2.48720121383667,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.687},"n":"0p667_1_0p333_0p687","t":6,"s":[49.878,22.253,0],"e":[49.878,2.25,0],"to":[0,-8.33440494537354,0],"ti":[0,3.3337619304657,0]},{"t":17.0000006924242}],"ix":2},"a":{"a":0,"k":[-0.122,-27.75,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[15.897,15.897,-17.409]},"o":{"x":[0.333,0.333,0.333],"y":[-44.172,-44.172,107.618]},"n":["0p667_15p897_0p333_-44p172","0p667_15p897_0p333_-44p172","0p667_-17p409_0p333_107p618"],"t":0,"s":[78.68,78.68,100],"e":[78,78,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[-0.773,-0.773,33.75]},"n":["0p667_1_0p333_-0p773","0p667_1_0p333_-0p773","0p667_1_0p333_33p75"],"t":6,"s":[78,78,100],"e":[54,54,100]},{"t":17.0000006924242}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[6.66,6.66],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.964705882353,0.309803921569,0.4,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-0.17,-26.594],"ix":2},"a":{"a":0,"k":[0,1.076],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0.281]},"n":["0p667_1_0p333_0p281"],"t":5,"s":[0],"e":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":11,"s":[100],"e":[0]},{"t":19.0000007738859}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":0.567},"o":{"x":0.333,"y":0.406},"n":"0p667_0p567_0p333_0p406","t":5,"s":[59.878,39.582,0],"e":[59.878,22.253,0],"to":[0,-2.35414934158325,0],"ti":[0,2.48720121383667,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.5},"n":"0p667_1_0p333_0p5","t":11,"s":[59.878,22.253,0],"e":[59.878,2.25,0],"to":[0,-8.33440494537354,0],"ti":[0,3.3337619304657,0]},{"t":19.0000007738859}],"ix":2},"a":{"a":0,"k":[-0.122,-27.75,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[15.897,15.897,-17.409]},"o":{"x":[0.333,0.333,0.333],"y":[-44.172,-44.172,107.618]},"n":["0p667_15p897_0p333_-44p172","0p667_15p897_0p333_-44p172","0p667_-17p409_0p333_107p618"],"t":5,"s":[78.68,78.68,100],"e":[78,78,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[-0.562,-0.562,24.545]},"n":["0p667_1_0p333_-0p562","0p667_1_0p333_-0p562","0p667_1_0p333_24p545"],"t":11,"s":[78,78,100],"e":[54,54,100]},{"t":19.0000007738859}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[6.66,6.66],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.868822583965,0.051056981554,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-0.17,-26.594],"ix":2},"a":{"a":0,"k":[0,1.076],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":5.00000020365417,"op":905.000036861406,"st":5.00000020365417,"bm":0}]}],"layers":[{"ddd":0,"ind":3,"ty":4,"nm":"Layer 2 Outlines","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[50.085,49.972,0],"ix":2},"a":{"a":0,"k":[20.392,17.022,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.486,0.486,0.333],"y":[0,0,0]},"n":["0p667_1_0p486_0","0p667_1_0p486_0","0p667_1_0p333_0"],"t":0,"s":[0,0,100],"e":[119,119,100]},{"i":{"x":[0.576,0.576,0.667],"y":[1,1,1]},"o":{"x":[0.439,0.439,0.333],"y":[0,0,0]},"n":["0p576_1_0p439_0","0p576_1_0p439_0","0p667_1_0p333_0"],"t":5,"s":[119,119,100],"e":[82,82,100]},{"i":{"x":[0.288,0.288,0.667],"y":[1,1,1]},"o":{"x":[0.152,0.152,0.333],"y":[0,0,0]},"n":["0p288_1_0p152_0","0p288_1_0p152_0","0p667_1_0p333_0"],"t":10,"s":[82,82,100],"e":[100,100,100]},{"t":15.0000006109625}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-2.008,2.091],[-2.887,0.06],[0,0],[-2.098,-2.123],[0,0],[0,0],[-3.003,0.063],[0,0],[-2.092,-2.008],[-0.059,-2.889],[2.542,-1.428],[0.178,8.815]],"o":[[2.007,-2.09],[0,0],[3.002,-0.062],[0,0],[0,0],[2.009,-2.205],[0,0],[2.89,-0.058],[2.09,2.008],[0.229,11.336],[-7.185,-3.885],[-0.059,-2.89]],"v":[[-17.06,-13.009],[-9.471,-16.342],[-9.465,-16.342],[-1.555,-13.145],[-0.209,-11.783],[1.081,-13.198],[8.851,-16.714],[8.855,-16.714],[16.579,-13.69],[19.913,-6.096],[0.38,16.772],[-20.083,-5.285]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.964999988032,0.310000011968,0.4,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[20.392,17.022],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":0,"nm":"Shape Layer 2 Comp 1","refId":"comp_4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[86,86,100],"ix":6}},"ao":0,"w":100,"h":100,"ip":3.00000012219251,"op":903.000036779944,"st":3.00000012219251,"bm":0},{"ddd":0,"ind":6,"ty":1,"nm":"White Solid 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2},"a":{"a":0,"k":[50,50,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"sw":100,"sh":100,"sc":"#ffffff","ip":0,"op":900.000036657751,"st":0,"bm":0}],"markers":[]}
\ No newline at end of file
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
index abc32e7a2..0c35ac08b 100644
--- a/Source/Core/Elements/ElementLottie.cpp
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -8,7 +8,7 @@
namespace Rml
{
- ElementLottie::ElementLottie(const String& tag) : Element(tag), geometry(this), dimensions(-1.0f, -1.0f)
+ ElementLottie::ElementLottie(const String& tag) : Element(tag), geometry(this), m_dimensions(200.0f, 200.0f), m_is_need_recreate_texture(true), m_is_need_recreate_geometry(true)
{
}
@@ -18,11 +18,22 @@ namespace Rml
bool ElementLottie::GetIntrinsicDimensions(Vector2f& dimensions, float& ratio)
{
- return false;
+ if (this->m_is_need_recreate_texture)
+ this->LoadTexture();
+
+ m_dimensions.x += 1;
+ m_dimensions.y += 1;
+ dimensions = this->m_dimensions;
+
+ return true;
}
void ElementLottie::OnRender()
{
+ //if (this->m_is_need_recreate_geometry)
+ this->GenerateGeometry();
+
+ geometry.Render(GetAbsoluteOffset(Box::CONTENT).Round());
}
void ElementLottie::OnResize()
@@ -39,11 +50,95 @@ namespace Rml
void ElementLottie::GenerateGeometry()
{
+ geometry.Release(true);
+
+ Vector< Vertex >& vertices = geometry.GetVertices();
+ Vector< int >& indices = geometry.GetIndices();
+
+ vertices.resize(4);
+ indices.resize(6);
+
+ // Generate the texture coordinates.
+ Vector2f texcoords[2];
+/*
+ if (rect_source != RectSource::None)
+ {
+ Vector2f texture_dimensions((float)texture.GetDimensions(GetRenderInterface()).x, (float)texture.GetDimensions(GetRenderInterface()).y);
+ if (texture_dimensions.x == 0.0f)
+ texture_dimensions.x = 1.0f;
+
+ if (texture_dimensions.y == 0.0f)
+ texture_dimensions.y = 1.0f;
+
+ texcoords[0].x = rect.x / texture_dimensions.x;
+ texcoords[0].y = rect.y / texture_dimensions.y;
+
+ texcoords[1].x = (rect.x + rect.width) / texture_dimensions.x;
+ texcoords[1].y = (rect.y + rect.height) / texture_dimensions.y;
+ }
+ else
+ {*/
+ texcoords[0] = Vector2f(0.0f, 0.0f);
+ texcoords[1] = Vector2f(1.0f, 1.0f);
+/*
+ }
+*/
+
+ const ComputedValues& computed = GetComputedValues();
+
+ float opacity = computed.opacity;
+ Colourb quad_colour = computed.image_color;
+ quad_colour.alpha = (byte)(opacity * (float)quad_colour.alpha);
+
+ Vector2f quad_size = GetBox().GetSize(Box::CONTENT).Round();
+
+ GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0, 0), quad_size, quad_colour, texcoords[0], texcoords[1]);
+
+ this->m_is_need_recreate_geometry = false;
}
bool ElementLottie::LoadTexture()
{
- return false;
+/* this->m_is_need_recreate_texture = false;*/
+ static float counter = 0.0f;
+ if (counter > 0.995f)
+ counter = 0.0f;
+
+ counter += 0.01f;
+
+ const String& attiribute_value_name = GetAttribute("src", "C:\\Users\\user\\RmlUi\\Samples\\assets\\lottie.json");
+
+ if (attiribute_value_name.empty())
+ return false;
+
+ this->m_p_lottie = rlottie::Animation::loadFromFile(attiribute_value_name.c_str());
+
+ if (this->m_p_lottie == nullptr)
+ {
+ Log::Message(Rml::Log::Type::LT_WARNING, "can't load lottie file properly");
+ return false;
+ }
+
+ auto p_callback = [this](const String& name, UniquePtr& data, Vector2i& dimensions) -> bool {
+ size_t bytes_per_line = m_dimensions.x * sizeof(std::uint32_t);
+ std::uint32_t* p_data = static_cast(calloc(bytes_per_line * m_dimensions.y, sizeof(std::uint32_t)));
+ rlottie::Surface surface(p_data, m_dimensions.x, m_dimensions.y, bytes_per_line);
+ m_p_lottie->renderSync(m_p_lottie->frameAtPos(counter), surface);
+ const Rml::byte* p_result = reinterpret_cast(p_data);
+ data.reset(p_result);
+
+ dimensions.x = m_dimensions.x;
+ dimensions.y = m_dimensions.y;
+
+
+ return true;
+ };
+
+ this->texture.Set(attiribute_value_name, p_callback);
+
+ this->geometry.SetTexture(&this->texture);
+
+ return true;
}
void ElementLottie::UpdateRect()
diff --git a/Source/Core/Elements/ElementLottie.h b/Source/Core/Elements/ElementLottie.h
index 42bfce684..fd83a6950 100644
--- a/Source/Core/Elements/ElementLottie.h
+++ b/Source/Core/Elements/ElementLottie.h
@@ -44,13 +44,17 @@ namespace Rml
// Loads the rect value from the element's attribute, but only if we're not a sprite.
void UpdateRect();
+
+ private:
+ bool m_is_need_recreate_texture;
+ bool m_is_need_recreate_geometry;
+
// The texture this element is rendering from.
Texture texture;
- // True if we need to refetch the texture's source from the element's attributes.
- bool texture_dirty;
+
// The element's computed intrinsic dimensions. If either of these values are set to -1, then
// that dimension has not been computed yet.
- Vector2f dimensions;
+ Vector2f m_dimensions;
// The rectangle extracted from the sprite or 'rect' attribute. The rect_source will be None if
// these have not been specified or are invalid.
@@ -60,7 +64,5 @@ namespace Rml
Geometry geometry;
std::unique_ptr m_p_lottie;
-
- bool geometry_dirty;
};
}
\ No newline at end of file
From 73b8674955a5ad647642352a9f649384f8c07cae Mon Sep 17 00:00:00 2001
From: NoName <>
Date: Wed, 30 Sep 2020 14:47:55 +0300
Subject: [PATCH 08/12] FIX: deleted irrational stuff
---
Samples/assets/lottie.rml | 2 +-
Source/Core/Elements/ElementLottie.cpp | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/Samples/assets/lottie.rml b/Samples/assets/lottie.rml
index a74882b0c..c220ce658 100644
--- a/Samples/assets/lottie.rml
+++ b/Samples/assets/lottie.rml
@@ -23,6 +23,6 @@
-
+
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
index 0c35ac08b..ee98f5d3c 100644
--- a/Source/Core/Elements/ElementLottie.cpp
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -21,8 +21,6 @@ namespace Rml
if (this->m_is_need_recreate_texture)
this->LoadTexture();
- m_dimensions.x += 1;
- m_dimensions.y += 1;
dimensions = this->m_dimensions;
return true;
From b230c23c982a230e1207c9a3631c26ba4a8ed048 Mon Sep 17 00:00:00 2001
From: diamondhat <>
Date: Sat, 10 Oct 2020 10:26:43 +0300
Subject: [PATCH 09/12] FIX: very raw and not quality implemented stuff
thinking about cool api
---
Samples/assets/lottie.rml | 2 +-
Source/Core/Elements/ElementLottie.cpp | 10 ++++++++--
Source/Core/Elements/ElementLottie.h | 1 +
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Samples/assets/lottie.rml b/Samples/assets/lottie.rml
index c220ce658..a74882b0c 100644
--- a/Samples/assets/lottie.rml
+++ b/Samples/assets/lottie.rml
@@ -23,6 +23,6 @@
-
+
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
index ee98f5d3c..b4bcf19e5 100644
--- a/Source/Core/Elements/ElementLottie.cpp
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -28,12 +28,18 @@ namespace Rml
void ElementLottie::OnRender()
{
- //if (this->m_is_need_recreate_geometry)
+ if (this->m_is_need_recreate_geometry)
this->GenerateGeometry();
+ this->LoadTexture();
geometry.Render(GetAbsoluteOffset(Box::CONTENT).Round());
}
+ void ElementLottie::OnUpdate()
+ {
+
+ }
+
void ElementLottie::OnResize()
{
}
@@ -104,7 +110,7 @@ namespace Rml
counter += 0.01f;
- const String& attiribute_value_name = GetAttribute("src", "C:\\Users\\user\\RmlUi\\Samples\\assets\\lottie.json");
+ const String& attiribute_value_name = GetAttribute("src", "C:\\Users\\lord\\RmlUi\\Samples\\assets\\lottie.json");
if (attiribute_value_name.empty())
return false;
diff --git a/Source/Core/Elements/ElementLottie.h b/Source/Core/Elements/ElementLottie.h
index fd83a6950..5f5276d13 100644
--- a/Source/Core/Elements/ElementLottie.h
+++ b/Source/Core/Elements/ElementLottie.h
@@ -24,6 +24,7 @@ namespace Rml
protected:
/// Renders the image.
void OnRender() override;
+ void OnUpdate() override;
/// Regenerates the element's geometry.
void OnResize() override;
From 6880c219ec9777a5198044d5742082ba6015d440 Mon Sep 17 00:00:00 2001
From: diamondhat
Date: Sat, 10 Oct 2020 11:46:22 +0300
Subject: [PATCH 10/12] FIX: raw and need author help
---
Source/Core/Elements/ElementLottie.cpp | 56 ++++++++++++++++++++------
Source/Core/Elements/ElementLottie.h | 4 +-
sdk/rlottie | 2 +-
3 files changed, 47 insertions(+), 15 deletions(-)
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
index b4bcf19e5..8c78d722f 100644
--- a/Source/Core/Elements/ElementLottie.cpp
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -8,7 +8,7 @@
namespace Rml
{
- ElementLottie::ElementLottie(const String& tag) : Element(tag), geometry(this), m_dimensions(200.0f, 200.0f), m_is_need_recreate_texture(true), m_is_need_recreate_geometry(true)
+ ElementLottie::ElementLottie(const String& tag) : Element(tag), geometry(this), m_dimensions(200.0f, 200.0f), m_is_need_recreate_texture(true), m_is_need_recreate_geometry(true), m_p_raw_data(nullptr)
{
}
@@ -28,11 +28,9 @@ namespace Rml
void ElementLottie::OnRender()
{
- if (this->m_is_need_recreate_geometry)
- this->GenerateGeometry();
- this->LoadTexture();
geometry.Render(GetAbsoluteOffset(Box::CONTENT).Round());
+ this->Play();
}
void ElementLottie::OnUpdate()
@@ -42,6 +40,7 @@ namespace Rml
void ElementLottie::OnResize()
{
+ this->GenerateGeometry();
}
void ElementLottie::OnAttributeChange(const ElementAttributes& changed_attributes)
@@ -103,18 +102,14 @@ namespace Rml
bool ElementLottie::LoadTexture()
{
-/* this->m_is_need_recreate_texture = false;*/
- static float counter = 0.0f;
- if (counter > 0.995f)
- counter = 0.0f;
-
- counter += 0.01f;
+ this->m_is_need_recreate_texture = false;
const String& attiribute_value_name = GetAttribute("src", "C:\\Users\\lord\\RmlUi\\Samples\\assets\\lottie.json");
if (attiribute_value_name.empty())
return false;
+ this->m_file_name = attiribute_value_name;
this->m_p_lottie = rlottie::Animation::loadFromFile(attiribute_value_name.c_str());
if (this->m_p_lottie == nullptr)
@@ -125,9 +120,10 @@ namespace Rml
auto p_callback = [this](const String& name, UniquePtr& data, Vector2i& dimensions) -> bool {
size_t bytes_per_line = m_dimensions.x * sizeof(std::uint32_t);
- std::uint32_t* p_data = static_cast(calloc(bytes_per_line * m_dimensions.y, sizeof(std::uint32_t)));
- rlottie::Surface surface(p_data, m_dimensions.x, m_dimensions.y, bytes_per_line);
- m_p_lottie->renderSync(m_p_lottie->frameAtPos(counter), surface);
+ std::uint32_t* p_data = new std::uint32_t[bytes_per_line * m_dimensions.y];
+ this->m_p_raw_data = p_data;
+/* rlottie::Surface surface(p_data, m_dimensions.x, m_dimensions.y, bytes_per_line);*/
+/* m_p_lottie->renderSync(m_p_lottie->frameAtPos(counter), surface);*/
const Rml::byte* p_result = reinterpret_cast(p_data);
data.reset(p_result);
@@ -148,4 +144,38 @@ namespace Rml
void ElementLottie::UpdateRect()
{
}
+
+ void ElementLottie::Play(void)
+ {
+ if (this->m_p_raw_data == nullptr)
+ return;
+
+ static std::uint32_t current_frame = 0;
+ ++current_frame;
+ current_frame = current_frame % this->m_p_lottie->totalFrame();
+ static float pos = 0.0f;
+ pos += 0.1f / this->m_p_lottie->frameRate();
+ if (pos >= 1.0f)
+ pos = 0.0f;
+
+ auto p_callback = [this](const String& name, UniquePtr& data, Vector2i& dimensions) -> bool {
+ size_t bytes_per_line = m_dimensions.x * sizeof(std::uint32_t);
+ std::uint32_t* p_data = new std::uint32_t[bytes_per_line * m_dimensions.y];
+ this->m_p_raw_data = p_data;
+ rlottie::Surface surface(p_data, m_dimensions.x, m_dimensions.y, bytes_per_line);
+ m_p_lottie->renderSync(this->m_p_lottie->frameAtPos(pos), surface);
+ const Rml::byte* p_result = reinterpret_cast(p_data);
+ data.reset(p_result);
+
+ dimensions.x = m_dimensions.x;
+ dimensions.y = m_dimensions.y;
+
+
+ return true;
+ };
+
+ this->texture.Set(this->m_file_name, p_callback);
+
+ this->geometry.SetTexture(&this->texture);
+ }
}
\ No newline at end of file
diff --git a/Source/Core/Elements/ElementLottie.h b/Source/Core/Elements/ElementLottie.h
index 5f5276d13..d0e9ff3bc 100644
--- a/Source/Core/Elements/ElementLottie.h
+++ b/Source/Core/Elements/ElementLottie.h
@@ -45,11 +45,13 @@ namespace Rml
// Loads the rect value from the element's attribute, but only if we're not a sprite.
void UpdateRect();
+ void Play(void);
private:
bool m_is_need_recreate_texture;
bool m_is_need_recreate_geometry;
-
+ std::uint32_t* m_p_raw_data;
+ String m_file_name;
// The texture this element is rendering from.
Texture texture;
diff --git a/sdk/rlottie b/sdk/rlottie
index 4884e0e9b..09662b89d 160000
--- a/sdk/rlottie
+++ b/sdk/rlottie
@@ -1 +1 @@
-Subproject commit 4884e0e9b3b726c0219f69804f9946a7f3c052f1
+Subproject commit 09662b89dc4566414d99f00e545ec8dd3b1fadd5
From 1e36cd401c0cc4ecc3052d84b2254772979818d2 Mon Sep 17 00:00:00 2001
From: diamondhat
Date: Sat, 10 Oct 2020 17:10:04 +0300
Subject: [PATCH 11/12] FIX: converted color
---
Source/Core/Elements/ElementLottie.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
index 8c78d722f..b268f8b05 100644
--- a/Source/Core/Elements/ElementLottie.cpp
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -164,6 +164,21 @@ namespace Rml
this->m_p_raw_data = p_data;
rlottie::Surface surface(p_data, m_dimensions.x, m_dimensions.y, bytes_per_line);
m_p_lottie->renderSync(this->m_p_lottie->frameAtPos(pos), surface);
+
+ size_t total_bytes = m_dimensions.x * m_dimensions.y;
+
+/*
+
+ for (int i = 0; i < total_bytes; ++i)
+ {
+ p_data[i] = p_data[i] << 8 | p_data[i] >> 24;
+ }
+*/
+ for (int i = 0; i < total_bytes; ++i)
+ {
+ p_data[i] = p_data[i] << 8 | p_data[i] >> 24;
+ }
+
const Rml::byte* p_result = reinterpret_cast(p_data);
data.reset(p_result);
From 1b4e48953d18f53fc204289f0970e4c011fa096c Mon Sep 17 00:00:00 2001
From: diamondhat
Date: Mon, 12 Oct 2020 15:03:09 +0300
Subject: [PATCH 12/12] ADD: something new
---
Source/Core/Elements/ElementLottie.cpp | 29 +++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/Source/Core/Elements/ElementLottie.cpp b/Source/Core/Elements/ElementLottie.cpp
index b268f8b05..a0a7ea44e 100644
--- a/Source/Core/Elements/ElementLottie.cpp
+++ b/Source/Core/Elements/ElementLottie.cpp
@@ -165,7 +165,7 @@ namespace Rml
rlottie::Surface surface(p_data, m_dimensions.x, m_dimensions.y, bytes_per_line);
m_p_lottie->renderSync(this->m_p_lottie->frameAtPos(pos), surface);
- size_t total_bytes = m_dimensions.x * m_dimensions.y;
+ size_t total_bytes = m_dimensions.x * m_dimensions.y * 4;
/*
@@ -174,11 +174,38 @@ namespace Rml
p_data[i] = p_data[i] << 8 | p_data[i] >> 24;
}
*/
+ // temporary convertation, but need future fixes
for (int i = 0; i < total_bytes; ++i)
{
p_data[i] = p_data[i] << 8 | p_data[i] >> 24;
}
+/* not working well
+ for (int i = 0; i < total_bytes; i += 4) {
+ auto a = p_data[i + 3];
+ // compute only if alpha is non zero
+ if (a) {
+ auto r = p_data[i + 2];
+ auto g = p_data[i + 1];
+ auto b = p_data[i];
+
+ if (a != 255) { // un premultiply
+ r = (r * 255) / a;
+ g = (g * 255) / a;
+ b = (b * 255) / a;
+
+ p_data[i] = r;
+ p_data[i + 1] = g;
+ p_data[i + 2] = b;
+
+ }
+ else {
+ // only swizzle r and b
+ p_data[i] = r;
+ p_data[i + 2] = b;
+ }
+ }
+ }*/
const Rml::byte* p_result = reinterpret_cast(p_data);
data.reset(p_result);