I was reading up on hardware acceleration and saw that it mentioned you can control it at the window, view and activity levels. Is there a reason for this much granularity of control? I thought that the application level more than enough if you wanted to disable or enable hardware acceleration.
There are a few reasons as to the granularity of hardware acceleration. A lot of good points are hit on in this article by Romain Guy.
One particular senerio would be in memory intense situations; here's a quote from the article:
Since hardware layers consume video memory, it is highly recommended you enable them only for the duration of the animation. This can be achieved with animation listeners:
view.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator animator = ObjectAnimator.ofFloat( view, "rotationY", 180); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setLayerType(View.LAYER_TYPE_NONE, null); } }); animator.start();
So, maybe you only want them enabled on certain views to save memory, but still want the animation to run smoothly so you use hardware acceleration.
Others reasons could steam from certain custom views making improper use of the graphics pipeline, so maybe you're getting performance issues, or screen tearing and want to turn it off on that specific view.