From 1357225dd52f3f2a6a1766c33eca32506b8f7ac2 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Mon, 20 Dec 2021 15:01:41 -0500 Subject: [PATCH 04/12] Dynamically resize boot animation to match screen size Change-Id: I54e49fc6b8c670103852e212d1416e27ff976205 --- cmds/bootanimation/BootAnimation.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index c2f6e3072..7213f3058 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -619,6 +619,28 @@ status_t BootAnimation::readyToRun() { mFlingerSurface = s; mTargetInset = -1; + if ( mAnimation != nullptr ) { + SLOGE("Got screen size %d, animation size %d", mWidth, mAnimation->width); + int origWidth = mAnimation->width; + if ( mAnimation->width*2 < mWidth ) { + SLOGE("Making animation bigger"); + mAnimation->width *= 2; + mAnimation->height *= 2; + } else if ( mWidth < mAnimation->width ) { + SLOGE("Making animation smaller"); + mAnimation->width /= 2; + mAnimation->height /= 2; + } + for (Animation::Part& part : mAnimation->parts) { + for(auto& frame: part.frames) { + if(frame.trimWidth == origWidth && frame.trimX == 0 && frame.trimY == 0) { + frame.trimWidth = mAnimation->width; + frame.trimHeight = mAnimation->height; + } + } + } + } + // Rotate the boot animation according to the value specified in the sysprop // ro.bootanim.set_orientation_. Four values are supported: ORIENTATION_0, // ORIENTATION_90, ORIENTATION_180 and ORIENTATION_270. -- 2.44.0