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 | |
Mathias Agopian | 8335f1c | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 33 | class Surface; |
| 34 | class SurfaceComposerClient; |
| 35 | class SurfaceControl; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
| 37 | // --------------------------------------------------------------------------- |
| 38 | |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 39 | class BootAnimation : public Thread, public IBinder::DeathRecipient |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | { |
| 41 | public: |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 42 | BootAnimation(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 44 | sp<SurfaceComposerClient> session() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | |
| 46 | private: |
| 47 | virtual bool threadLoop(); |
| 48 | virtual status_t readyToRun(); |
| 49 | virtual void onFirstRef(); |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 50 | virtual void binderDied(const wp<IBinder>& who); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 52 | bool updateIsTimeAccurate(); |
| 53 | |
| 54 | class TimeCheckThread : public Thread { |
| 55 | public: |
| 56 | TimeCheckThread(BootAnimation* bootAnimation); |
| 57 | virtual ~TimeCheckThread(); |
| 58 | private: |
| 59 | virtual status_t readyToRun(); |
| 60 | virtual bool threadLoop(); |
| 61 | bool doThreadLoop(); |
| 62 | void addTimeDirWatch(); |
| 63 | |
| 64 | int mInotifyFd; |
| 65 | int mSystemWd; |
| 66 | int mTimeWd; |
| 67 | BootAnimation* mBootAnimation; |
| 68 | }; |
| 69 | |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 70 | class InitAudioThread : public Thread { |
| 71 | public: |
| 72 | InitAudioThread(uint8_t* exampleAudioData, int mExampleAudioLength); |
| 73 | private: |
| 74 | virtual bool threadLoop(); |
| 75 | |
| 76 | uint8_t* mExampleAudioData; |
| 77 | int mExampleAudioLength; |
| 78 | }; |
| 79 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | struct Texture { |
| 81 | GLint w; |
| 82 | GLint h; |
| 83 | GLuint name; |
| 84 | }; |
| 85 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 86 | struct Font { |
| 87 | FileMap* map; |
| 88 | Texture texture; |
| 89 | int char_width; |
| 90 | int char_height; |
| 91 | }; |
| 92 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 93 | struct Animation { |
| 94 | struct Frame { |
| 95 | String8 name; |
| 96 | FileMap* map; |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 97 | int trimX; |
| 98 | int trimY; |
| 99 | int trimWidth; |
| 100 | int trimHeight; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 101 | mutable GLuint tid; |
| 102 | bool operator < (const Frame& rhs) const { |
| 103 | return name < rhs.name; |
| 104 | } |
| 105 | }; |
| 106 | struct Part { |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 107 | int count; // The number of times this part should repeat, 0 for infinite |
| 108 | int pause; // The number of frames to pause for at the end of this part |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 109 | int clockPosX; // The x position of the clock, in pixels. Positive values offset from |
| 110 | // the left of the screen, negative values offset from the right. |
| 111 | int clockPosY; // The y position of the clock, in pixels. Positive values offset from |
| 112 | // the bottom of the screen, negative values offset from the top. |
| 113 | // If either of the above are INT_MIN the clock is disabled, if INT_MAX |
| 114 | // the clock is centred on that axis. |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 115 | String8 path; |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 116 | String8 trimData; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 117 | SortedVector<Frame> frames; |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 118 | bool playUntilComplete; |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 119 | float backgroundColor[3]; |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 120 | uint8_t* audioData; |
| 121 | int audioLength; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 122 | Animation* animation; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 123 | }; |
| 124 | int fps; |
| 125 | int width; |
| 126 | int height; |
| 127 | Vector<Part> parts; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 128 | String8 audioConf; |
| 129 | String8 fileName; |
| 130 | ZipFileRO* zip; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 131 | Font clockFont; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | status_t initTexture(Texture* texture, AssetManager& asset, const char* name); |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 135 | status_t initTexture(FileMap* map, int* width, int* height); |
| 136 | status_t initFont(Font* font, const char* fallback); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | bool android(); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 138 | bool movie(); |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 139 | void drawText(const char* str, const Font& font, bool bold, int* x, int* y); |
| 140 | void drawClock(const Font& font, const int xPos, const int yPos); |
| 141 | bool validClock(const Animation::Part& part); |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 142 | Animation* loadAnimation(const String8&); |
| 143 | bool playAnimation(const Animation&); |
| 144 | void releaseAnimation(Animation*) const; |
| 145 | bool parseAnimationDesc(Animation&); |
| 146 | bool preloadZip(Animation &animation); |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 147 | bool playSoundsAllowed() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 149 | void checkExit(); |
| 150 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | sp<SurfaceComposerClient> mSession; |
| 152 | AssetManager mAssets; |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 153 | Texture mAndroid[2]; |
| 154 | int mWidth; |
| 155 | int mHeight; |
Sai Kiran Korwar | 2716749 | 2015-07-07 20:00:06 +0530 | [diff] [blame] | 156 | bool mUseNpotTextures = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 157 | EGLDisplay mDisplay; |
| 158 | EGLDisplay mContext; |
| 159 | EGLDisplay mSurface; |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 160 | sp<SurfaceControl> mFlingerSurfaceControl; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | sp<Surface> mFlingerSurface; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 162 | bool mClockEnabled; |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 163 | bool mTimeIsAccurate; |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 164 | bool mTimeFormat12Hour; |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 165 | bool mSystemBoot; |
Keun-young Park | b593842 | 2017-03-23 13:46:24 -0700 | [diff] [blame] | 166 | bool mShuttingDown; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 167 | String8 mZipFileName; |
| 168 | SortedVector<String8> mLoadedFiles; |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 169 | sp<TimeCheckThread> mTimeCheckThread = nullptr; |
| 170 | sp<InitAudioThread> mInitAudioThread = nullptr; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | // --------------------------------------------------------------------------- |
| 174 | |
| 175 | }; // namespace android |
| 176 | |
| 177 | #endif // ANDROID_BOOTANIMATION_H |