summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.cpp
diff options
context:
space:
mode:
author Oleg Lyovin <ovlevin@sberdevices.ru> 2023-07-01 14:39:59 +0300
committer Oleg Lyovin <ovlevin@sberdevices.ru> 2023-07-01 14:51:23 +0300
commit6a4b84d2f4a84b5fd42cb439879f46407fcd51b2 (patch)
tree26e9e2a4a0f84e76f0f81a68426f21fd711a04b7 /cmds/bootanimation/BootAnimation.cpp
parentce749aa53731e0ab885dbd3ef627661beec80819 (diff)
bootanimation: do not create texture for parts with count=1
When bootanimation contains part that is played only once, there is no need to create a separate texture for its frames. Such an approach allows to reduce memory consumption for typical use case of such an animations, when a part consists of a lot of frames played only once. Actually, it was already implemented earlier, but part of it was lost in 'd711ac4858337539c2188f47ef015e5b88080830'. Moreover, the remained part leads to memory leak in current implementation on BootAnimation.cpp:1712. Test: play bootanimation with part.count=1 and a lot of frames, and check memory consumption. Change-Id: If3a0fa890f6f9e7abc0db2fe96b5635a1663fb8a Signed-off-by: Oleg Lyovin <ovlevin@sberdevices.ru>
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r--cmds/bootanimation/BootAnimation.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 27dadda40407..5b9d989bdfe6 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -1525,6 +1525,7 @@ bool BootAnimation::playAnimation(const Animation& animation) {
for (size_t i=0 ; i<pcount ; i++) {
const Animation::Part& part(animation.parts[i]);
const size_t fcount = part.frames.size();
+ glBindTexture(GL_TEXTURE_2D, 0);
// Handle animation package
if (part.animation != nullptr) {
@@ -1601,8 +1602,10 @@ bool BootAnimation::playAnimation(const Animation& animation) {
if (r > 0) {
glBindTexture(GL_TEXTURE_2D, frame.tid);
} else {
- glGenTextures(1, &frame.tid);
- glBindTexture(GL_TEXTURE_2D, frame.tid);
+ if (part.count != 1) {
+ glGenTextures(1, &frame.tid);
+ glBindTexture(GL_TEXTURE_2D, frame.tid);
+ }
int w, h;
// Set decoding option to alpha unpremultiplied so that the R, G, B channels
// of transparent pixels are preserved.