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