summaryrefslogtreecommitdiffstats
path: root/cmds/bootanimation/BootAnimation.h
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/bootanimation/BootAnimation.h')
-rw-r--r--cmds/bootanimation/BootAnimation.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h
index a0f84da..090894f 100644
--- a/cmds/bootanimation/BootAnimation.h
+++ b/cmds/bootanimation/BootAnimation.h
@@ -26,6 +26,8 @@
#include <EGL/egl.h>
#include <GLES/gl.h>
+#include <utils/Thread.h>
+
class SkBitmap;
namespace android {
@@ -34,11 +36,17 @@ class AudioPlayer;
class Surface;
class SurfaceComposerClient;
class SurfaceControl;
+#ifdef MULTITHREAD_DECODE
+class FrameManager;
+#endif
// ---------------------------------------------------------------------------
class BootAnimation : public Thread, public IBinder::DeathRecipient
{
+#ifdef MULTITHREAD_DECODE
+ friend class FrameManager;
+#endif
public:
enum {
eOrientationDefault = 0,
@@ -89,6 +97,7 @@ private:
status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
status_t initTexture(const Animation::Frame& frame);
+ status_t initTexture(SkBitmap *bitmap);
bool android();
bool readFile(const char* name, String8& outString);
bool movie();
@@ -101,6 +110,8 @@ private:
void checkExit();
void checkShowAndroid();
+ static SkBitmap *decode(const Animation::Frame& frame);
+
sp<SurfaceComposerClient> mSession;
sp<AudioPlayer> mAudioPlayer;
AssetManager mAssets;
@@ -115,6 +126,50 @@ private:
ZipFileRO *mZip;
};
+#ifdef MULTITHREAD_DECODE
+
+class FrameManager {
+public:
+ struct DecodeWork {
+ const BootAnimation::Animation::Frame *frame;
+ SkBitmap *bitmap;
+ size_t idx;
+ };
+
+ FrameManager(int numThreads, size_t maxSize, const SortedVector<BootAnimation::Animation::Frame>& frames);
+ virtual ~FrameManager();
+
+ SkBitmap* next();
+
+protected:
+ DecodeWork getWork();
+ void completeWork(DecodeWork work);
+
+private:
+
+ class DecodeThread : public Thread {
+ public:
+ DecodeThread(FrameManager* manager);
+ virtual ~DecodeThread() {}
+ private:
+ virtual bool threadLoop();
+ FrameManager *mManager;
+ };
+
+ size_t mMaxSize;
+ size_t mFrameCounter;
+ size_t mNextIdx;
+ const SortedVector<BootAnimation::Animation::Frame>& mFrames;
+ Vector<DecodeWork> mDecodedFrames;
+ pthread_mutex_t mBitmapsMutex;
+ pthread_cond_t mSpaceAvailableCondition;
+ pthread_cond_t mBitmapReadyCondition;
+ bool mExit;
+ Vector<sp<DecodeThread> > mThreads;
+};
+
+#endif
+
// ---------------------------------------------------------------------------
}; // namespace android