OSDN Git Service

DO NOT MERGE. Grant MMS Uri permissions as the calling UID.
[android-x86/frameworks-base.git] / cmds / bootanimation / BootAnimation.h
1 /*
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
23 #include <androidfw/AssetManager.h>
24 #include <utils/Thread.h>
25
26 #include <EGL/egl.h>
27 #include <GLES/gl.h>
28
29 class SkBitmap;
30
31 namespace android {
32
33 class Surface;
34 class SurfaceComposerClient;
35 class SurfaceControl;
36
37 // ---------------------------------------------------------------------------
38
39 class BootAnimation : public Thread, public IBinder::DeathRecipient
40 {
41 public:
42                 BootAnimation();
43     virtual     ~BootAnimation();
44
45     sp<SurfaceComposerClient> session() const;
46
47 private:
48     virtual bool        threadLoop();
49     virtual status_t    readyToRun();
50     virtual void        onFirstRef();
51     virtual void        binderDied(const wp<IBinder>& who);
52
53     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
71     struct Texture {
72         GLint   w;
73         GLint   h;
74         GLuint  name;
75     };
76
77     struct Animation {
78         struct Frame {
79             String8 name;
80             FileMap* map;
81             int trimX;
82             int trimY;
83             int trimWidth;
84             int trimHeight;
85             mutable GLuint tid;
86             bool operator < (const Frame& rhs) const {
87                 return name < rhs.name;
88             }
89         };
90         struct Part {
91             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
95             String8 path;
96             String8 trimData;
97             SortedVector<Frame> frames;
98             bool playUntilComplete;
99             float backgroundColor[3];
100             uint8_t* audioData;
101             int audioLength;
102             Animation* animation;
103         };
104         int fps;
105         int width;
106         int height;
107         Vector<Part> parts;
108         String8 audioConf;
109         String8 fileName;
110         ZipFileRO* zip;
111     };
112
113     status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
114     status_t initTexture(const Animation::Frame& frame);
115     bool android();
116     bool movie();
117     void drawTime(const Texture& clockTex, const int yPos);
118     Animation* loadAnimation(const String8&);
119     bool playAnimation(const Animation&);
120     void releaseAnimation(Animation*) const;
121     bool parseAnimationDesc(Animation&);
122     bool preloadZip(Animation &animation);
123     bool playSoundsAllowed() const;
124
125     void checkExit();
126
127     sp<SurfaceComposerClient>       mSession;
128     AssetManager mAssets;
129     Texture     mAndroid[2];
130     Texture     mClock;
131     int         mWidth;
132     int         mHeight;
133     bool        mUseNpotTextures = false;
134     EGLDisplay  mDisplay;
135     EGLDisplay  mContext;
136     EGLDisplay  mSurface;
137     sp<SurfaceControl> mFlingerSurfaceControl;
138     sp<Surface> mFlingerSurface;
139     bool        mClockEnabled;
140     bool        mTimeIsAccurate;
141     bool        mSystemBoot;
142     String8     mZipFileName;
143     SortedVector<String8> mLoadedFiles;
144     sp<TimeCheckThread> mTimeCheckThread;
145 };
146
147 // ---------------------------------------------------------------------------
148
149 }; // namespace android
150
151 #endif // ANDROID_BOOTANIMATION_H