summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.cpp
diff options
context:
space:
mode:
author Shan Huang <shanh@google.com> 2021-08-18 00:56:08 +0000
committer Shan Huang <shanh@google.com> 2021-08-18 01:10:16 +0000
commit7fee35220794edd1b0700c25002df6e6719400bb (patch)
tree0a4fab137d717d6acc27d33eed1ab7b9475815bf /cmds/bootanimation/BootAnimation.cpp
parentd790d63e254efdb4aadafbd091d7215afcd24095 (diff)
Move boot color sysprop parsing to after loading zips.
Otherwise the sysprops would not be loaded yet and accessing them would return empty strings. Though unlikely, this is not 100% safe because boot color sysprops are not guaranteed to be loaded by the time zips are loaded. A TODO here is to understand boot steps and their timing implications so that we can fully avoid the race condition. Bug: 190093578 Test: adb shell setprop persist.bootanim.color(1-4), then reboot phone. Change-Id: I603da080b1732a436a10dbaca6f2be9f158124dc
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r--cmds/bootanimation/BootAnimation.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 13bbe556b8ee..7c81f0942f78 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -728,22 +728,6 @@ void BootAnimation::initShaders() {
glVertexAttribPointer(uvLocation, 2, GL_FLOAT, GL_FALSE, 0, quadUVs);
glEnableVertexAttribArray(uvLocation);
- if (dynamicColoringEnabled) {
- glUseProgram(mImageShader);
- SLOGI("[BootAnimation] Dynamically coloring boot animation.");
- for (int i = 0; i < DYNAMIC_COLOR_COUNT; i++) {
- float *startColor = mAnimation->startColors[i];
- float *endColor = mAnimation->endColors[i];
- glUniform4f(glGetUniformLocation(mImageShader,
- (U_START_COLOR_PREFIX + std::to_string(i)).c_str()),
- startColor[0], startColor[1], startColor[2], 1 /* alpha */);
- glUniform4f(glGetUniformLocation(mImageShader,
- (U_END_COLOR_PREFIX + std::to_string(i)).c_str()),
- endColor[0], endColor[1], endColor[2], 1 /* alpha */);
- }
- mImageColorProgressLocation = glGetUniformLocation(mImageShader, U_COLOR_PROGRESS);
- }
-
// Initialize text shader.
mTextShader = linkShader(vertexShader, textFragmentShader);
positionLocation = glGetAttribLocation(mTextShader, A_POSITION);
@@ -1179,12 +1163,6 @@ bool BootAnimation::parseAnimationDesc(Animation& animation) {
s = ++endl;
}
- for (int i = 0; i < DYNAMIC_COLOR_COUNT; i++) {
- parseColorDecimalString(
- android::base::GetProperty("persist.bootanim.color" + std::to_string(i + 1), ""),
- animation.endColors[i], animation.startColors[i]);
- }
-
return true;
}
@@ -1361,6 +1339,10 @@ bool BootAnimation::movie() {
mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL);
}
+ if (mAnimation != nullptr && mAnimation->dynamicColoringEnabled) {
+ initDynamicColors();
+ }
+
playAnimation(*mAnimation);
if (mTimeCheckThread != nullptr) {
@@ -1414,6 +1396,27 @@ void BootAnimation::drawTexturedQuad(float xStart, float yStart, float width, fl
sizeof(quadPositions) / sizeof(quadPositions[0]) / 2);
}
+void BootAnimation::initDynamicColors() {
+ for (int i = 0; i < DYNAMIC_COLOR_COUNT; i++) {
+ parseColorDecimalString(
+ android::base::GetProperty("persist.bootanim.color" + std::to_string(i + 1), ""),
+ mAnimation->endColors[i], mAnimation->startColors[i]);
+ }
+ glUseProgram(mImageShader);
+ SLOGI("[BootAnimation] Dynamically coloring boot animation.");
+ for (int i = 0; i < DYNAMIC_COLOR_COUNT; i++) {
+ float *startColor = mAnimation->startColors[i];
+ float *endColor = mAnimation->endColors[i];
+ glUniform4f(glGetUniformLocation(mImageShader,
+ (U_START_COLOR_PREFIX + std::to_string(i)).c_str()),
+ startColor[0], startColor[1], startColor[2], 1 /* alpha */);
+ glUniform4f(glGetUniformLocation(mImageShader,
+ (U_END_COLOR_PREFIX + std::to_string(i)).c_str()),
+ endColor[0], endColor[1], endColor[2], 1 /* alpha */);
+ }
+ mImageColorProgressLocation = glGetUniformLocation(mImageShader, U_COLOR_PROGRESS);
+}
+
bool BootAnimation::playAnimation(const Animation& animation) {
const size_t pcount = animation.parts.size();
nsecs_t frameDuration = s2ns(1) / animation.fps;