diff options
author | Ed Coyne <edcoyne@google.com> | 2017-05-31 10:08:28 -0700 |
---|---|---|
committer | Ed Coyne <edcoyne@google.com> | 2017-05-31 10:24:52 -0700 |
commit | 2c9e94aa3e9614f0d202ee008c08a9011fa7f75f (patch) | |
tree | ccc7e6d62479007774b6d58effcff4994298d987 /cmds/bootanimation/BootAnimation.h | |
parent | 0ed316b7f147401d158bd07f188ed2e598b337ba (diff) |
Refactor bootanimation into a shared lib.
We would like to reuse the animation parts of it in Android things.
This refactors the audio part into the _main and gets callbacks from
the BootAnimation class at interesting times. This will be the same
approach we take to integrate with it.
BUG: 37992717
Test: Built locally and pushed to a bullhead, works with sound.
Change-Id: I5eaca07c25eeb5edeab07d7ae7a29945e0e2cd37
Diffstat (limited to 'cmds/bootanimation/BootAnimation.h')
-rw-r--r-- | cmds/bootanimation/BootAnimation.h | 86 |
1 files changed, 45 insertions, 41 deletions
diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 181ef1c596d1..3ebe7d6e4dff 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -39,44 +39,6 @@ class SurfaceControl; class BootAnimation : public Thread, public IBinder::DeathRecipient { public: - BootAnimation(); - - sp<SurfaceComposerClient> session() const; - -private: - virtual bool threadLoop(); - virtual status_t readyToRun(); - virtual void onFirstRef(); - virtual void binderDied(const wp<IBinder>& who); - - bool updateIsTimeAccurate(); - - class TimeCheckThread : public Thread { - public: - TimeCheckThread(BootAnimation* bootAnimation); - virtual ~TimeCheckThread(); - private: - virtual status_t readyToRun(); - virtual bool threadLoop(); - bool doThreadLoop(); - void addTimeDirWatch(); - - int mInotifyFd; - int mSystemWd; - int mTimeWd; - BootAnimation* mBootAnimation; - }; - - class InitAudioThread : public Thread { - public: - InitAudioThread(uint8_t* exampleAudioData, int mExampleAudioLength); - private: - virtual bool threadLoop(); - - uint8_t* mExampleAudioData; - int mExampleAudioLength; - }; - struct Texture { GLint w; GLint h; @@ -131,6 +93,49 @@ private: Font clockFont; }; + // Callback will be called during initialization after we have loaded + // the animation and be provided with all parts in animation. + typedef std::function<void(const Vector<Animation::Part>& parts)> InitCallback; + + // Callback will be called while animation is playing before each part is + // played. It will be provided with the part and play count for it. + // It will be provided with the partNumber for the part about to be played, + // as well as a reference to the part itself. It will also be provided with + // which play of that part is about to start, some parts are repeated + // multiple times. + typedef std::function<void(int partNumber, const Animation::Part& part, int playNumber)> + PlayPartCallback; + + // Callbacks may be null and will be called from this class's internal + // thread. + BootAnimation(InitCallback initCallback, PlayPartCallback partCallback); + + sp<SurfaceComposerClient> session() const; + +private: + virtual bool threadLoop(); + virtual status_t readyToRun(); + virtual void onFirstRef(); + virtual void binderDied(const wp<IBinder>& who); + + bool updateIsTimeAccurate(); + + class TimeCheckThread : public Thread { + public: + TimeCheckThread(BootAnimation* bootAnimation); + virtual ~TimeCheckThread(); + private: + virtual status_t readyToRun(); + virtual bool threadLoop(); + bool doThreadLoop(); + void addTimeDirWatch(); + + int mInotifyFd; + int mSystemWd; + int mTimeWd; + BootAnimation* mBootAnimation; + }; + status_t initTexture(Texture* texture, AssetManager& asset, const char* name); status_t initTexture(FileMap* map, int* width, int* height); status_t initFont(Font* font, const char* fallback); @@ -144,7 +149,6 @@ private: void releaseAnimation(Animation*) const; bool parseAnimationDesc(Animation&); bool preloadZip(Animation &animation); - bool playSoundsAllowed() const; void checkExit(); @@ -162,12 +166,12 @@ private: bool mClockEnabled; bool mTimeIsAccurate; bool mTimeFormat12Hour; - bool mSystemBoot; bool mShuttingDown; String8 mZipFileName; SortedVector<String8> mLoadedFiles; sp<TimeCheckThread> mTimeCheckThread = nullptr; - sp<InitAudioThread> mInitAudioThread = nullptr; + InitCallback mInitCallback = nullptr; + PlayPartCallback mPlayPartCallback = nullptr; }; // --------------------------------------------------------------------------- |