From eafcb9978615149b116ce695374d849cff011c1e Mon Sep 17 00:00:00 2001 From: Yegor Malyshev Date: Thu, 10 Sep 2020 16:42:20 +0200 Subject: Support animation parts fading out This support helps with several things: - simpler animation structure (size, number of items) - more room for designers avoiding thinking about exit part - time saving as complete parts now can be safely used as fading parts Bug: 167352662 Test: Manual testing of major/edge cases - backward compatibility => "f 0" is mapped to "p", "p" still works - only trimmed areas are faded out - clock is not faded out (wear case) - adb shell su root bootanimation - [c, (exit) f 120, c] => "f 120" fades out and "c" completes - [c, (exit) f 120, f 320] => "f 120" fades out and "f 320" skipped - [c, f 16, (exit) f 120] => "f 16" played, "f 120" fades out - [c, (exit) f 0, f 120] => "f 0" skipped, "f 120" fades out Change-Id: I9b200ee7107ef9b3dc8d711658ed1042b83739c2 Merged-In: I9b200ee7107ef9b3dc8d711658ed1042b83739c2 --- cmds/bootanimation/BootAnimation.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cmds/bootanimation/BootAnimation.h') diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 6ba7fd450fbb..aee385387f57 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -45,6 +46,8 @@ class SurfaceControl; class BootAnimation : public Thread, public IBinder::DeathRecipient { public: + static constexpr int MAX_FADED_FRAMES_COUNT = std::numeric_limits::max(); + struct Texture { GLint w; GLint h; @@ -84,10 +87,15 @@ public: String8 trimData; SortedVector frames; bool playUntilComplete; + int framesToFadeCount; float backgroundColor[3]; uint8_t* audioData; int audioLength; Animation* animation; + + bool hasFadingPhase() const { + return !playUntilComplete && framesToFadeCount > 0; + } }; int fps; int width; @@ -160,6 +168,8 @@ private: bool movie(); void drawText(const char* str, const Font& font, bool bold, int* x, int* y); void drawClock(const Font& font, const int xPos, const int yPos); + void fadeFrame(int frameLeft, int frameBottom, int frameWidth, int frameHeight, + const Animation::Part& part, int fadedFramesCount); bool validClock(const Animation::Part& part); Animation* loadAnimation(const String8&); bool playAnimation(const Animation&); @@ -172,7 +182,9 @@ private: EGLConfig getEglConfig(const EGLDisplay&); ui::Size limitSurfaceSize(int width, int height) const; void resizeSurface(int newWidth, int newHeight); + void projectSceneToWindow(); + bool shouldStopPlayingPart(const Animation::Part& part, int fadedFramesCount); void checkExit(); void handleViewport(nsecs_t timestep); -- cgit v1.2.3-59-g8ed1b