blob: a093c9b87e75fda5a329045e16f20f247125d1e2 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_BOOTANIMATION_H
18#define ANDROID_BOOTANIMATION_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopianb13b9bd2012-02-17 18:27:36 -080023#include <androidfw/AssetManager.h>
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -070024#include <utils/Thread.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026#include <EGL/egl.h>
27#include <GLES/gl.h>
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029class SkBitmap;
30
31namespace android {
32
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -070033class AudioPlayer;
Mathias Agopian8335f1c2012-02-25 18:48:35 -080034class Surface;
35class SurfaceComposerClient;
36class SurfaceControl;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037
38// ---------------------------------------------------------------------------
39
Mathias Agopianbc726112009-09-23 15:44:05 -070040class BootAnimation : public Thread, public IBinder::DeathRecipient
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041{
42public:
Mathias Agopian627e7b52009-05-21 19:21:59 -070043 BootAnimation();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044 virtual ~BootAnimation();
45
Mathias Agopianbc726112009-09-23 15:44:05 -070046 sp<SurfaceComposerClient> session() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047
48private:
49 virtual bool threadLoop();
50 virtual status_t readyToRun();
51 virtual void onFirstRef();
Mathias Agopianbc726112009-09-23 15:44:05 -070052 virtual void binderDied(const wp<IBinder>& who);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053
Damien Bargiacchi97480862016-03-29 14:55:55 -070054 bool updateIsTimeAccurate();
55
56 class TimeCheckThread : public Thread {
57 public:
58 TimeCheckThread(BootAnimation* bootAnimation);
59 virtual ~TimeCheckThread();
60 private:
61 virtual status_t readyToRun();
62 virtual bool threadLoop();
63 bool doThreadLoop();
64 void addTimeDirWatch();
65
66 int mInotifyFd;
67 int mSystemWd;
68 int mTimeWd;
69 BootAnimation* mBootAnimation;
70 };
71
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 struct Texture {
73 GLint w;
74 GLint h;
75 GLuint name;
76 };
77
Mathias Agopiana8826d62009-10-01 03:10:14 -070078 struct Animation {
79 struct Frame {
80 String8 name;
81 FileMap* map;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -040082 int trimX;
83 int trimY;
84 int trimWidth;
85 int trimHeight;
Mathias Agopiana8826d62009-10-01 03:10:14 -070086 mutable GLuint tid;
87 bool operator < (const Frame& rhs) const {
88 return name < rhs.name;
89 }
90 };
91 struct Part {
Damien Bargiacchia704b7d2016-02-16 16:55:49 -080092 int count; // The number of times this part should repeat, 0 for infinite
93 int pause; // The number of frames to pause for at the end of this part
94 int clockPosY; // The y position of the clock, in pixels, from the bottom of the
95 // display (the clock is centred horizontally). -1 to disable the clock
Mathias Agopiana8826d62009-10-01 03:10:14 -070096 String8 path;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -040097 String8 trimData;
Mathias Agopiana8826d62009-10-01 03:10:14 -070098 SortedVector<Frame> frames;
Kevin Hesterd3782b22012-04-26 10:38:55 -070099 bool playUntilComplete;
Jesse Hall083b84c2014-09-22 10:51:09 -0700100 float backgroundColor[3];
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700101 FileMap* audioFile;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700102 Animation* animation;
Mathias Agopiana8826d62009-10-01 03:10:14 -0700103 };
104 int fps;
105 int width;
106 int height;
107 Vector<Part> parts;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700108 String8 audioConf;
109 String8 fileName;
110 ZipFileRO* zip;
Mathias Agopiana8826d62009-10-01 03:10:14 -0700111 };
112
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800113 status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
Mykola Kondratenko0c1eeb32014-04-15 09:35:44 +0200114 status_t initTexture(const Animation::Frame& frame);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 bool android();
Mathias Agopiana8826d62009-10-01 03:10:14 -0700116 bool movie();
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800117 void drawTime(const Texture& clockTex, const int yPos);
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700118 Animation* loadAnimation(const String8&);
119 bool playAnimation(const Animation&);
120 void releaseAnimation(Animation*) const;
121 bool parseAnimationDesc(Animation&);
122 bool preloadZip(Animation &animation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800123
Kevin Hesterd3782b22012-04-26 10:38:55 -0700124 void checkExit();
125
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800126 sp<SurfaceComposerClient> mSession;
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700127 sp<AudioPlayer> mAudioPlayer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 AssetManager mAssets;
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700129 Texture mAndroid[2];
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800130 Texture mClock;
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700131 int mWidth;
132 int mHeight;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800133 EGLDisplay mDisplay;
134 EGLDisplay mContext;
135 EGLDisplay mSurface;
Mathias Agopian17f638b2009-04-16 20:04:08 -0700136 sp<SurfaceControl> mFlingerSurfaceControl;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 sp<Surface> mFlingerSurface;
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800138 bool mClockEnabled;
Damien Bargiacchi97480862016-03-29 14:55:55 -0700139 bool mTimeIsAccurate;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700140 String8 mZipFileName;
141 SortedVector<String8> mLoadedFiles;
Damien Bargiacchi97480862016-03-29 14:55:55 -0700142 sp<TimeCheckThread> mTimeCheckThread;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800143};
144
145// ---------------------------------------------------------------------------
146
147}; // namespace android
148
149#endif // ANDROID_BOOTANIMATION_H