summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.h
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/bootanimation/BootAnimation.h')
-rw-r--r--cmds/bootanimation/BootAnimation.h40
1 files changed, 22 insertions, 18 deletions
diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h
index 3ebe7d6e4dff..56e131523bcb 100644
--- a/cmds/bootanimation/BootAnimation.h
+++ b/cmds/bootanimation/BootAnimation.h
@@ -93,22 +93,27 @@ public:
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);
+ // All callbacks will be called from this class's internal thread.
+ class Callbacks : public RefBase {
+ public:
+ // Will be called during initialization after we have loaded
+ // the animation and be provided with all parts in animation.
+ virtual void init(const Vector<Animation::Part>& /*parts*/) {}
+
+ // 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.
+ virtual void playPart(int /*partNumber*/, const Animation::Part& /*part*/,
+ int /*playNumber*/) {}
+
+ // Will be called when animation is done and thread is shutting down.
+ virtual void shutdown() {}
+ };
+
+ BootAnimation(sp<Callbacks> callbacks);
sp<SurfaceComposerClient> session() const;
@@ -170,8 +175,7 @@ private:
String8 mZipFileName;
SortedVector<String8> mLoadedFiles;
sp<TimeCheckThread> mTimeCheckThread = nullptr;
- InitCallback mInitCallback = nullptr;
- PlayPartCallback mPlayPartCallback = nullptr;
+ sp<Callbacks> mCallbacks;
};
// ---------------------------------------------------------------------------