blob: fd497a362fc761e3bdb988c0025aa71b1cce6f3f [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
Mathias Agopian8335f1c2012-02-25 18:48:35 -080033class Surface;
34class SurfaceComposerClient;
35class SurfaceControl;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036
37// ---------------------------------------------------------------------------
38
Mathias Agopianbc726112009-09-23 15:44:05 -070039class BootAnimation : public Thread, public IBinder::DeathRecipient
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040{
41public:
Mathias Agopian627e7b52009-05-21 19:21:59 -070042 BootAnimation();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 virtual ~BootAnimation();
44
Mathias Agopianbc726112009-09-23 15:44:05 -070045 sp<SurfaceComposerClient> session() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046
47private:
48 virtual bool threadLoop();
49 virtual status_t readyToRun();
50 virtual void onFirstRef();
Mathias Agopianbc726112009-09-23 15:44:05 -070051 virtual void binderDied(const wp<IBinder>& who);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052
Damien Bargiacchi97480862016-03-29 14:55:55 -070053 bool updateIsTimeAccurate();
54
55 class TimeCheckThread : public Thread {
56 public:
57 TimeCheckThread(BootAnimation* bootAnimation);
58 virtual ~TimeCheckThread();
59 private:
60 virtual status_t readyToRun();
61 virtual bool threadLoop();
62 bool doThreadLoop();
63 void addTimeDirWatch();
64
65 int mInotifyFd;
66 int mSystemWd;
67 int mTimeWd;
68 BootAnimation* mBootAnimation;
69 };
70
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071 struct Texture {
72 GLint w;
73 GLint h;
74 GLuint name;
75 };
76
Mathias Agopiana8826d62009-10-01 03:10:14 -070077 struct Animation {
78 struct Frame {
79 String8 name;
80 FileMap* map;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -040081 int trimX;
82 int trimY;
83 int trimWidth;
84 int trimHeight;
Mathias Agopiana8826d62009-10-01 03:10:14 -070085 mutable GLuint tid;
86 bool operator < (const Frame& rhs) const {
87 return name < rhs.name;
88 }
89 };
90 struct Part {
Damien Bargiacchia704b7d2016-02-16 16:55:49 -080091 int count; // The number of times this part should repeat, 0 for infinite
92 int pause; // The number of frames to pause for at the end of this part
93 int clockPosY; // The y position of the clock, in pixels, from the bottom of the
94 // display (the clock is centred horizontally). -1 to disable the clock
Mathias Agopiana8826d62009-10-01 03:10:14 -070095 String8 path;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -040096 String8 trimData;
Mathias Agopiana8826d62009-10-01 03:10:14 -070097 SortedVector<Frame> frames;
Kevin Hesterd3782b22012-04-26 10:38:55 -070098 bool playUntilComplete;
Jesse Hall083b84c2014-09-22 10:51:09 -070099 float backgroundColor[3];
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700100 uint8_t* audioData;
101 int audioLength;
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);
Geoffrey Pitsch290c4352016-08-09 14:35:10 -0400123 bool playSoundsAllowed() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124
Kevin Hesterd3782b22012-04-26 10:38:55 -0700125 void checkExit();
126
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 sp<SurfaceComposerClient> mSession;
128 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;
Sai Kiran Korwar27167492015-07-07 20:00:06 +0530133 bool mUseNpotTextures = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 EGLDisplay mDisplay;
135 EGLDisplay mContext;
136 EGLDisplay mSurface;
Mathias Agopian17f638b2009-04-16 20:04:08 -0700137 sp<SurfaceControl> mFlingerSurfaceControl;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138 sp<Surface> mFlingerSurface;
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800139 bool mClockEnabled;
Damien Bargiacchi97480862016-03-29 14:55:55 -0700140 bool mTimeIsAccurate;
Geoffrey Pitsch290c4352016-08-09 14:35:10 -0400141 bool mSystemBoot;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700142 String8 mZipFileName;
143 SortedVector<String8> mLoadedFiles;
Damien Bargiacchi97480862016-03-29 14:55:55 -0700144 sp<TimeCheckThread> mTimeCheckThread;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145};
146
147// ---------------------------------------------------------------------------
148
149}; // namespace android
150
151#endif // ANDROID_BOOTANIMATION_H