Merge "Only enable GL rendering on the main thread." into honeycomb

This commit is contained in:
Romain Guy
2011-01-12 16:22:48 -08:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 2 deletions

View File

@ -36,7 +36,7 @@ import javax.microedition.khronos.opengles.GL;
* @hide
*/
public abstract class HardwareRenderer {
private static final String LOG_TAG = "HardwareRenderer";
static final String LOG_TAG = "HardwareRenderer";
/**
* A process can set this flag to false to prevent the use of hardware

View File

@ -485,7 +485,14 @@ public final class ViewRoot extends Handler implements ViewParent,
private void enableHardwareAcceleration(WindowManager.LayoutParams attrs) {
mAttachInfo.mHardwareAccelerated = false;
mAttachInfo.mHardwareAccelerationRequested = false;
// Don't enable hardware acceleration when we're not on the main thread
if (Looper.getMainLooper() != Looper.myLooper()) {
Log.w(HardwareRenderer.LOG_TAG, "Attempting to initialize hardware acceleration "
+ "outside of the main thread, aborting");
return;
}
// Try to enable hardware acceleration if requested
if (attrs != null &&
(attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0) {