Graphics

Applications can spend a lot of time drawing things on the screen. Whether it is a 3D game using the GPU or simply a Calendar application using the CPU for most of its rendering, the idea is to do as little work as possible while still getting the desired results on the screen in order to preserve battery life.

As we saw earlier, the CPU uses less power when it is not running at full speed. Modern CPUs use dynamic frequency scaling and dynamic voltage scaling to conserve power or reduce heat. Such techniques are usually used together and referred to as DVFS (Dynamic Voltage and Frequency Scaling) and the Linux kernel, Android, and modern processors support such techniques.

Similarly, modern GPUs are able to turn off internal components, from a whole core to an individual pipeline, even between the renderings of two frames.

While you have no direct control over things like voltage, frequency, or what hardware module gets powered off, you do have direct control over what your application renders. While achieving a good frame rate is usually the first priority for most applications, reducing the power consumption should not be forgotten. Even though the frame rate on Android devices is usually capped (for example, at 60 frames per second), optimizing your rendering routines can still be beneficial even if your application has already reached the maximum frame rate. In addition to possibly reducing power consumption, you may also leave more room for other background applications to run, providing a better overall user experience.

For example, a typical pitfall is to ignore the call to onVisibilityChanged() in a live wallpaper. The fact that the wallpaper can be invisible can easily be overlooked, and perpetually drawing the wallpaper can use a lot of power.

For tips on how to optimize rendering, refer to Chapter 8.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.149.119