在工作的过程中,有客户要求修改动画,顺便看了一下,仅供参考。
首先在frameworks\base\cmds\bootanimation\BootAnimation.cpp目录下
在bool BootAnimation::android()中修改一下代码
{
int i = 0;
initTexture(&mAndroid[0], mAssets, "images/android-logo-mask-1.png");
initTexture(&mAndroid[1], mAssets, "images/android-logo-mask-2.png");
initTexture(&mAndroid[2], mAssets, "images/android-logo-mask-3.png");
initTexture(&mAndroid[3], mAssets, "images/android-logo-mask-4.png");
initTexture(&mAndroid[4], mAssets, "images/android-logo-mask-5.png");
initTexture(&mAndroid[5], mAssets, "images/android-logo-mask-6.png");
initTexture(&mAndroid[6], mAssets, "images/android-logo-shine.png")
然后在做以下红色部分修改.
do {
nsecs_t now = systemTime();
double time = now - startTime;
float t = 4.0f * float(time / us2ns(16667)) / mAndroid[6].w;
GLint offset = (1 - (t - floorf(t))) * mAndroid[6].w;
GLint x = xc - offset;
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, mAndroid[6].name);
glDrawTexiOES(x, yc, 0, mAndroid[6].w, mAndroid[6].h);
glDrawTexiOES(x + mAndroid[6].w, yc, 0, mAndroid[6].w, mAndroid[6].h);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, mAndroid[i].name);
glDrawTexiOES(xc, yc, 0, mAndroid[i].w, mAndroid[i].h);
EGLBoolean res = eglSwapBuffers(mDisplay, mSurface);
if(i<5)
i++;
else
i = 0;
if (res == EGL_FALSE)
break;
// 12fps: don't animate too fast to preserve CPU
const nsecs_t sleepTime = 183333 - ns2us(systemTime() - now);
if (sleepTime > 0)
usleep(sleepTime);
} while (!exitPending());
glDeleteTextures(1, &mAndroid[0].name);
glDeleteTextures(1, &mAndroid[1].name);
glDeleteTextures(1, &mAndroid[2].name);
glDeleteTextures(1, &mAndroid[3].name);
glDeleteTextures(1, &mAndroid[4].name);
glDeleteTextures(1, &mAndroid[5].name);
glDeleteTextures(1, &mAndroid[6].name);
return false;
}
最后还有根据你所加动画的图片数量去修改BootAnimation.h下的值
Texture mAndroid[7];