7] = y;
2132 }
2133 };
2134
2135 class h_stretch {
2136 const GLfloat hw_w, hw_h;
2137 public:
2138 h_stretch(uint32_t hw_w, uint32_t hw_h)
2139 : hw_w(hw_w), hw_h(hw_h) {
2140 }
2141 void operator()(GLfloat* vtx, float v) {
2142 const GLfloat w = hw_w - (hw_w * v);
2143 const GLfloat h = 1.0f;
2144 const GLfloat x = (hw_w - w) * 0.5f;
2145 const GLfloat y = (hw_h - h) * 0.5f;
2146 vtx[0] = x; vtx[1] = y;
2147 vtx[2] = x; vtx[3] = y + h;
2148 vtx[4] = x + w; vtx[5] = y + h;
2149 vtx[6] = x + w; vtx[7] = y;
2150 }
2151 };
2152
2153 // the full animation is 24 frames
2154 const int nbFrames = 12;
2155 s_curve_interpolator itr(nbFrames, 7.5f);
2156 s_curve_interpolator itg(nbFrames, 8.0f);
2157 s_curve_interpolator itb(nbFrames, 8.5f);
2158
2159 v_stretch vverts(hw_w, hw_h);
2160 glEnable(GL_BLEND);
2161 glBlendFunc(GL_ONE, GL_ONE);
2162 for (int i=0 ; i
2163 float x, y, w, h;
2164 const float vr = itr(i);
2165 const float vg = itg(i);
2166 const float vb = itb(i);
2167
2168 // clear screen
2169 glColorMask(1,1,1,1);
2170 glClear(GL_COLOR_BUFFER_BIT);
2171 glEnable(GL_TEXTURE_2D);
2172
2173 // draw the red plane
2174 vverts(vtx, vr);
2175 glColorMask(1,0,0,1);
2176 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
2177
2178 // draw the green plane
2179 vverts(vtx, vg);
2180 glColorMask(0,1,0,1);
2181 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
2182
2183 // draw the blue plane
2184 vverts(vtx, vb);
2185 glColorMask(0,0,1,1);
2186 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
2187
2188 // draw the white highlight (we use the last vertices)
2189 glDisable(GL_TEXTURE_2D);
2190 glColorMask(1,1,1,1);
2191 glColor4f(vg, vg, vg, 1);
2192 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
2193 hw.flip(screenBounds);
2194 }
2195
2196 h_stretch hverts(hw_w, hw_h);
2197 glDisable(GL_BLEND);
2198 glDisable(GL_TEXTURE_2D);
2199 glColorMask(1,1,1,1);
2200 for (int i=0 ; i
2201 const float v = itg(i);
2202 hverts(vtx, v);
2203 glClear(GL_COLOR_BUFFER_BIT);
2204 glColor4f(1-v, 1-v, 1-v, 1);
2205 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
2206 hw.flip(screenBounds);
2207 }
2208
2209 glColorMask(1,1,1,1);
2210 glEnable(GL_SCISSOR_TEST);
2211 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2212 glDeleteTextures(1, &tname);
2213 return NO_ERROR;
2214 }
2215
OK,看完代码回来,首先是PowerManagerService.java中
mAnimationSetting如果标记为ANIM_SETTING_OFF,则打开旧CRT动画。
下面关屏动作run()中,因为我们将config_animateScreenLights置为false,因此mAnimateScreenLights为fasle
分支进入else,执行nativeStartSurfaceFlingerAnimation()函数。
nativeStartSurfaceFlingerAnimation()函数是一个JNI调用,在com_android_server_PowerManagerService.cpp文件中,
对应surfaceflinger的s->turnElectronBeamOff(mode)函数。
好的,现在跳入SurfaceFlinger.cpp函数,具体调用顺序是:
tu