The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Mathias Agopian | b13b9bd | 2012-02-17 18:27:36 -0800 | [diff] [blame] | 23 | #include <androidfw/AssetManager.h> |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 24 | #include <utils/Thread.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <EGL/egl.h> |
| 27 | #include <GLES/gl.h> |
| 28 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | class SkBitmap; |
| 30 | |
| 31 | namespace android { |
| 32 | |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 33 | class AudioPlayer; |
Mathias Agopian | 8335f1c | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 34 | class Surface; |
| 35 | class SurfaceComposerClient; |
| 36 | class SurfaceControl; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
| 38 | // --------------------------------------------------------------------------- |
| 39 | |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 40 | class BootAnimation : public Thread, public IBinder::DeathRecipient |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | { |
| 42 | public: |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 43 | BootAnimation(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | virtual ~BootAnimation(); |
| 45 | |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 46 | sp<SurfaceComposerClient> session() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | virtual bool threadLoop(); |
| 50 | virtual status_t readyToRun(); |
| 51 | virtual void onFirstRef(); |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 52 | virtual void binderDied(const wp<IBinder>& who); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | |
| 54 | struct Texture { |
| 55 | GLint w; |
| 56 | GLint h; |
| 57 | GLuint name; |
| 58 | }; |
| 59 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 60 | struct Animation { |
| 61 | struct Frame { |
| 62 | String8 name; |
| 63 | FileMap* map; |
| 64 | mutable GLuint tid; |
| 65 | bool operator < (const Frame& rhs) const { |
| 66 | return name < rhs.name; |
| 67 | } |
| 68 | }; |
| 69 | struct Part { |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 70 | int count; // The number of times this part should repeat, 0 for infinite |
| 71 | int pause; // The number of frames to pause for at the end of this part |
| 72 | int clockPosY; // The y position of the clock, in pixels, from the bottom of the |
| 73 | // display (the clock is centred horizontally). -1 to disable the clock |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 74 | String8 path; |
| 75 | SortedVector<Frame> frames; |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 76 | bool playUntilComplete; |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 77 | float backgroundColor[3]; |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 78 | FileMap* audioFile; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 79 | Animation* animation; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 80 | }; |
| 81 | int fps; |
| 82 | int width; |
| 83 | int height; |
| 84 | Vector<Part> parts; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 85 | String8 audioConf; |
| 86 | String8 fileName; |
| 87 | ZipFileRO* zip; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | status_t initTexture(Texture* texture, AssetManager& asset, const char* name); |
Mykola Kondratenko | 0c1eeb3 | 2014-04-15 09:35:44 +0200 | [diff] [blame] | 91 | status_t initTexture(const Animation::Frame& frame); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | bool android(); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 93 | bool movie(); |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 94 | void drawTime(const Texture& clockTex, const int yPos); |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 95 | Animation* loadAnimation(const String8&); |
| 96 | bool playAnimation(const Animation&); |
| 97 | void releaseAnimation(Animation*) const; |
| 98 | bool parseAnimationDesc(Animation&); |
| 99 | bool preloadZip(Animation &animation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 101 | void checkExit(); |
| 102 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | sp<SurfaceComposerClient> mSession; |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 104 | sp<AudioPlayer> mAudioPlayer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | AssetManager mAssets; |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 106 | Texture mAndroid[2]; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 107 | Texture mClock; |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 108 | int mWidth; |
| 109 | int mHeight; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | EGLDisplay mDisplay; |
| 111 | EGLDisplay mContext; |
| 112 | EGLDisplay mSurface; |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 113 | sp<SurfaceControl> mFlingerSurfaceControl; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | sp<Surface> mFlingerSurface; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 115 | bool mClockEnabled; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 116 | String8 mZipFileName; |
| 117 | SortedVector<String8> mLoadedFiles; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | // --------------------------------------------------------------------------- |
| 121 | |
| 122 | }; // namespace android |
| 123 | |
| 124 | #endif // ANDROID_BOOTANIMATION_H |