BootAnimation.h revision afd31e08299008fdc5c2813f21b2573f29dc53df
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/threads.h>
25
26#include <EGL/egl.h>
27#include <GLES/gl.h>
28
29class SkBitmap;
30
31namespace android {
32
33class Surface;
34class SurfaceComposerClient;
35class SurfaceControl;
36
37// ---------------------------------------------------------------------------
38
39class BootAnimation : public Thread, public IBinder::DeathRecipient
40{
41public:
42                BootAnimation();
43    virtual     ~BootAnimation();
44
45    sp<SurfaceComposerClient> session() const;
46
47private:
48    virtual bool        threadLoop();
49    virtual status_t    readyToRun();
50    virtual void        onFirstRef();
51    virtual void        binderDied(const wp<IBinder>& who);
52
53    struct Texture {
54        GLint   w;
55        GLint   h;
56        GLuint  name;
57    };
58
59    struct Animation {
60        struct Frame {
61            String8 name;
62            FileMap* map;
63            mutable GLuint tid;
64            bool operator < (const Frame& rhs) const {
65                return name < rhs.name;
66            }
67        };
68        struct Part {
69            int count;
70            int pause;
71            String8 path;
72            SortedVector<Frame> frames;
73            bool playUntilComplete;
74        };
75        int fps;
76        int width;
77        int height;
78        Vector<Part> parts;
79    };
80
81    status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
82    status_t initTexture(void* buffer, size_t len);
83    bool android();
84    bool movie();
85
86    void checkExit();
87
88    sp<SurfaceComposerClient>       mSession;
89    AssetManager mAssets;
90    Texture     mAndroid[2];
91    int         mWidth;
92    int         mHeight;
93    EGLDisplay  mDisplay;
94    EGLDisplay  mContext;
95    EGLDisplay  mSurface;
96    sp<SurfaceControl> mFlingerSurfaceControl;
97    sp<Surface> mFlingerSurface;
98    ZipFileRO   *mZip;
99};
100
101// ---------------------------------------------------------------------------
102
103}; // namespace android
104
105#endif // ANDROID_BOOTANIMATION_H
106