blob: 2b30336b78b136eff5b042ad4744d098436d8d68 [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
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#define LOG_TAG "BootAnimation"
18
19#include <stdint.h>
20#include <sys/types.h>
21#include <math.h>
22#include <fcntl.h>
23#include <utils/misc.h>
24
25#include <utils/threads.h>
26#include <utils/Atomic.h>
27#include <utils/Errors.h>
28#include <utils/Log.h>
29#include <utils/AssetManager.h>
30
31#include <ui/PixelFormat.h>
32#include <ui/Rect.h>
33#include <ui/Region.h>
34#include <ui/DisplayInfo.h>
35#include <ui/ISurfaceComposer.h>
36#include <ui/ISurfaceFlingerClient.h>
37#include <ui/EGLNativeWindowSurface.h>
38
The Android Open Source Project27629322009-01-09 17:51:23 -080039#include <core/SkBitmap.h>
40#include <images/SkImageDecoder.h>
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070041
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080042#include <GLES/gl.h>
43#include <GLES/glext.h>
44#include <EGL/eglext.h>
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070045
46#include "BootAnimation.h"
47
48namespace android {
49
50// ---------------------------------------------------------------------------
51
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080052BootAnimation::BootAnimation(const sp<ISurfaceComposer>& composer) :
53 Thread(false) {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070054 mSession = SurfaceComposerClient::clientForConnection(
55 composer->createConnection()->asBinder());
56}
57
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080058BootAnimation::~BootAnimation() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070059}
60
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080061void BootAnimation::onFirstRef() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070062 run("BootAnimation", PRIORITY_DISPLAY);
63}
64
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080065const sp<SurfaceComposerClient>& BootAnimation::session() const {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070066 return mSession;
67}
68
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080069status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
70 const char* name) {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070071 Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080072 if (!asset)
73 return NO_INIT;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070074 SkBitmap bitmap;
75 SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
76 &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode);
77 asset->close();
78 delete asset;
79
80 // ensure we can call getPixels(). No need to call unlock, since the
81 // bitmap will go out of scope when we return from this method.
82 bitmap.lockPixels();
83
84 const int w = bitmap.width();
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080085 const int h = bitmap.height();
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070086 const void* p = bitmap.getPixels();
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080087
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070088 GLint crop[4] = { 0, h, w, -h };
89 texture->w = w;
90 texture->h = h;
91
92 glGenTextures(1, &texture->name);
93 glBindTexture(GL_TEXTURE_2D, texture->name);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080094
95 switch (bitmap.getConfig()) {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070096 case SkBitmap::kA8_Config:
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080097 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
98 GL_UNSIGNED_BYTE, p);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070099 break;
100 case SkBitmap::kARGB_4444_Config:
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800101 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
102 GL_UNSIGNED_SHORT_4_4_4_4, p);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700103 break;
104 case SkBitmap::kARGB_8888_Config:
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800105 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
106 GL_UNSIGNED_BYTE, p);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700107 break;
108 case SkBitmap::kRGB_565_Config:
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800109 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
110 GL_UNSIGNED_SHORT_5_6_5, p);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700111 break;
112 default:
113 break;
114 }
115
116 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
117 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
118 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
119 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
120 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
121 return NO_ERROR;
122}
123
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800124status_t BootAnimation::readyToRun() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700125 mAssets.addDefaultAssets();
126
127 DisplayInfo dinfo;
128 status_t status = session()->getDisplayInfo(0, &dinfo);
129 if (status)
130 return -1;
131
132 // create the native surface
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800133 sp<Surface> s = session()->createSurface(getpid(), 0, dinfo.w, dinfo.h,
134 PIXEL_FORMAT_RGB_565);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700135 session()->openTransaction();
136 s->setLayer(0x40000000);
137 session()->closeTransaction();
138
139 // initialize opengl and egl
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800140 const EGLint attribs[] = { EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6,
141 EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 0, EGL_NONE };
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700142 EGLint w, h, dummy;
143 EGLint numConfigs;
144 EGLConfig config;
145 EGLSurface surface;
146 EGLContext context;
147 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700148 eglChooseConfig(display, attribs, &config, 1, &numConfigs);
149
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800150 mNativeWindowSurface = new EGLNativeWindowSurface(s);
151 surface = eglCreateWindowSurface(display, config,
152 mNativeWindowSurface.get(), NULL);
153
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700154 context = eglCreateContext(display, config, NULL, NULL);
155 eglQuerySurface(display, surface, EGL_WIDTH, &w);
156 eglQuerySurface(display, surface, EGL_HEIGHT, &h);
157 eglMakeCurrent(display, surface, surface, context);
158 mDisplay = display;
159 mContext = context;
160 mSurface = surface;
161 mWidth = w;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800162 mHeight = h;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700163 mFlingerSurface = s;
164
165 // initialize GL
166 glShadeModel(GL_FLAT);
167 glEnable(GL_DITHER);
168 glEnable(GL_TEXTURE_2D);
169 glEnable(GL_SCISSOR_TEST);
170 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
171
172 return NO_ERROR;
173}
174
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800175void BootAnimation::requestExit() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700176 mBarrier.open();
177 Thread::requestExit();
178}
179
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800180bool BootAnimation::threadLoop() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700181 bool r = android();
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800182 eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
183 eglDestroyContext(mDisplay, mContext);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700184 eglDestroySurface(mDisplay, mSurface);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800185 mNativeWindowSurface.clear();
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700186 return r;
187}
188
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800189bool BootAnimation::android() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700190 initTexture(&mAndroid[0], mAssets, "images/android_320x480.png");
191 initTexture(&mAndroid[1], mAssets, "images/boot_robot.png");
192 initTexture(&mAndroid[2], mAssets, "images/boot_robot_glow.png");
193
194 // erase screen
195 glDisable(GL_SCISSOR_TEST);
196 glBindTexture(GL_TEXTURE_2D, mAndroid[0].name);
197
198 // clear screen
199 glClear(GL_COLOR_BUFFER_BIT);
200 eglSwapBuffers(mDisplay, mSurface);
201
202 // wait ~1s
203 usleep(800000);
204
205 // fade in
206 glEnable(GL_BLEND);
207 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
208 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
209 const int steps = 8;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800210 for (int i = 1; i < steps; i++) {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700211 float fade = i / float(steps);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800212 glColor4f(1, 1, 1, fade * fade);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700213 glClear(GL_COLOR_BUFFER_BIT);
214 glDrawTexiOES(0, 0, 0, mAndroid[0].w, mAndroid[0].h);
215 eglSwapBuffers(mDisplay, mSurface);
216 }
217
218 // draw last frame
219 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
220 glDisable(GL_BLEND);
221 glDrawTexiOES(0, 0, 0, mAndroid[0].w, mAndroid[0].h);
222 eglSwapBuffers(mDisplay, mSurface);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800223
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700224 // update rect for the robot
225 const int x = mWidth - mAndroid[1].w - 33;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800226 const int y = (mHeight - mAndroid[1].h) / 2 - 1;
227 const Rect updateRect(x, y, x + mAndroid[1].w, y + mAndroid[1].h);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700228
229 // draw and update only what we need
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800230 mNativeWindowSurface->setSwapRectangle(updateRect.left,
231 updateRect.top, updateRect.width(), updateRect.height());
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700232
233 glEnable(GL_SCISSOR_TEST);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800234 glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(),
235 updateRect.height());
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700236
237 const nsecs_t startTime = systemTime();
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800238 do {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700239 // glow speed and shape
240 nsecs_t time = systemTime() - startTime;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800241 float t = ((4.0f / (360.0f * us2ns(16667))) * time);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700242 t = t - floorf(t);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800243 const float fade = 0.5f + 0.5f * sinf(t * 2 * M_PI);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700244
245 // fade the glow in and out
246 glDisable(GL_BLEND);
247 glBindTexture(GL_TEXTURE_2D, mAndroid[2].name);
248 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
249 glColor4f(fade, fade, fade, fade);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800250 glDrawTexiOES(updateRect.left, mHeight - updateRect.bottom, 0,
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700251 updateRect.width(), updateRect.height());
252
253 // draw the robot
254 glEnable(GL_BLEND);
255 glBindTexture(GL_TEXTURE_2D, mAndroid[1].name);
256 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800257 glDrawTexiOES(updateRect.left, mHeight - updateRect.bottom, 0,
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700258 updateRect.width(), updateRect.height());
259
260 // make sure sleep a lot to not take too much CPU away from
261 // the boot process. With this "glow" animation there is no
262 // visible difference.
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800263 usleep(16667 * 4);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700264
265 eglSwapBuffers(mDisplay, mSurface);
266 } while (!exitPending());
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800267
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700268 glDeleteTextures(1, &mAndroid[0].name);
269 glDeleteTextures(1, &mAndroid[1].name);
270 glDeleteTextures(1, &mAndroid[2].name);
271 return false;
272}
273
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800274bool BootAnimation::cylon() {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700275 // initialize the textures...
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800276 initTexture(&mLeftTrail, mAssets, "images/cylon_left.png");
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700277 initTexture(&mRightTrail, mAssets, "images/cylon_right.png");
278 initTexture(&mBrightSpot, mAssets, "images/cylon_dot.png");
279
280 int w = mWidth;
281 int h = mHeight;
282
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800283 const Point c(w / 2, h / 2);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700284 const GLint amplitude = 60;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800285 const int scx = c.x - amplitude - mBrightSpot.w / 2;
286 const int scy = c.y - mBrightSpot.h / 2;
287 const int scw = amplitude * 2 + mBrightSpot.w;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700288 const int sch = mBrightSpot.h;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800289 const Rect updateRect(scx, h - scy - sch, scx + scw, h - scy);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700290
291 // erase screen
292 glDisable(GL_SCISSOR_TEST);
293 glClear(GL_COLOR_BUFFER_BIT);
294
295 eglSwapBuffers(mDisplay, mSurface);
296
297 glClear(GL_COLOR_BUFFER_BIT);
298
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800299 mNativeWindowSurface->setSwapRectangle(updateRect.left,
300 updateRect.top, updateRect.width(), updateRect.height());
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700301
302 glEnable(GL_SCISSOR_TEST);
303 glEnable(GL_BLEND);
304 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
305
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700306 // clear the screen to white
307 Point p;
308 float t = 0;
309 float alpha = 1.0f;
310 const nsecs_t startTime = systemTime();
311 nsecs_t fadeTime = 0;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800312
313 do {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700314 // Set scissor in interesting area
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800315 glScissor(scx, scy, scw, sch);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700316
317 // erase screen
318 glClear(GL_COLOR_BUFFER_BIT);
319
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700320 // compute wave
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800321 const float a = (t * 2 * M_PI) - M_PI / 2;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700322 const float sn = sinf(a);
323 const float cs = cosf(a);
324 GLint x = GLint(amplitude * sn);
325 float derivative = cs;
326
327 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
328
329 if (derivative > 0) {
330 // vanishing trail...
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800331 p.x = (-amplitude + c.x) - mBrightSpot.w / 2;
332 p.y = c.y - mLeftTrail.h / 2;
333 float fade = 2.0f * (0.5f - t);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700334 //fade *= fade;
335 glColor4f(fade, fade, fade, fade);
336 glBindTexture(GL_TEXTURE_2D, mLeftTrail.name);
337 glDrawTexiOES(p.x, p.y, 0, mLeftTrail.w, mLeftTrail.h);
338
339 // trail...
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800340 p.x = (x + c.x) - (mRightTrail.w + mBrightSpot.w / 2) + 16;
341 p.y = c.y - mRightTrail.h / 2;
342 fade = t < 0.25f ? t * 4.0f : 1.0f;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700343 fade *= fade;
344 glColor4f(fade, fade, fade, fade);
345 glBindTexture(GL_TEXTURE_2D, mRightTrail.name);
346 glDrawTexiOES(p.x, p.y, 0, mRightTrail.w, mRightTrail.h);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800347 } else {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700348 // vanishing trail..
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800349 p.x = (amplitude + c.x) - (mRightTrail.w + mBrightSpot.w / 2) + 16;
350 p.y = c.y - mRightTrail.h / 2;
351 float fade = 2.0f * (0.5f - (t - 0.5f));
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700352 //fade *= fade;
353 glColor4f(fade, fade, fade, fade);
354 glBindTexture(GL_TEXTURE_2D, mRightTrail.name);
355 glDrawTexiOES(p.x, p.y, 0, mRightTrail.w, mRightTrail.h);
356
357 // trail...
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800358 p.x = (x + c.x) - mBrightSpot.w / 2;
359 p.y = c.y - mLeftTrail.h / 2;
360 fade = t < 0.5f + 0.25f ? (t - 0.5f) * 4.0f : 1.0f;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700361 fade *= fade;
362 glColor4f(fade, fade, fade, fade);
363 glBindTexture(GL_TEXTURE_2D, mLeftTrail.name);
364 glDrawTexiOES(p.x, p.y, 0, mLeftTrail.w, mLeftTrail.h);
365 }
366
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800367 const Point p(x + c.x - mBrightSpot.w / 2, c.y - mBrightSpot.h / 2);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700368 glBindTexture(GL_TEXTURE_2D, mBrightSpot.name);
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800369 glColor4f(1, 0.5, 0.5, 1);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700370 glDrawTexiOES(p.x, p.y, 0, mBrightSpot.w, mBrightSpot.h);
371
372 // update animation
373 nsecs_t time = systemTime() - startTime;
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800374 t = ((4.0f / (360.0f * us2ns(16667))) * time);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700375 t = t - floorf(t);
376
377 eglSwapBuffers(mDisplay, mSurface);
378
379 if (exitPending()) {
380 if (fadeTime == 0) {
381 fadeTime = time;
382 }
383 time -= fadeTime;
384 alpha = 1.0f - ((float(time) * 6.0f) / float(s2ns(1)));
385
386 session()->openTransaction();
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800387 mFlingerSurface->setAlpha(alpha * alpha);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700388 session()->closeTransaction();
389 }
390 } while (alpha > 0);
391
392 // cleanup
393 glFinish();
394 glDeleteTextures(1, &mLeftTrail.name);
395 glDeleteTextures(1, &mRightTrail.name);
396 glDeleteTextures(1, &mBrightSpot.name);
397 return false;
398}
399
400// ---------------------------------------------------------------------------
401
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -0800402}
403; // namespace android