Add libhwui, to hardware accelerate the Canvas API using OpenGL ES 2.0.

This is the initial checkin to setup the library and turn on OEGL ES 2.0
in ViewRoot, not a functional renderer.

Change-Id: I6655c54166e2967da2e21e7d6dcfba78bf113b44
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index fc28e69..0c12998 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -259,17 +259,6 @@
         mAttachInfo = new View.AttachInfo(sWindowSession, mWindow, this, this);
         mViewConfiguration = ViewConfiguration.get(context);
         mDensity = context.getResources().getDisplayMetrics().densityDpi;
-
-        // Only enable hardware acceleration if we are not in the system process
-        // The window manager creates ViewRoots to display animated preview windows
-        // of launching apps and we don't want those to be hardware accelerated
-        if (Process.myUid() != Process.SYSTEM_UID) {
-            // Try to enable hardware acceleration if requested
-            if ((context.getApplicationInfo().flags &
-                    ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
-                mHwRenderer = HardwareRenderer.createGlRenderer(1);
-            }
-        }
     }
 
     // For debug only
@@ -331,13 +320,15 @@
     /**
      * We have one child
      */
-    public void setView(View view, WindowManager.LayoutParams attrs,
-            View panelParentView) {
+    public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView) {
         synchronized (this) {
             if (mView == null) {
                 mView = view;
                 mWindowAttributes.copyFrom(attrs);
                 attrs = mWindowAttributes;
+                
+                enableHardwareAcceleration(view, attrs);
+
                 if (view instanceof RootViewSurfaceTaker) {
                     mSurfaceHolderCallback =
                             ((RootViewSurfaceTaker)view).willYouTakeTheSurface();
@@ -459,6 +450,20 @@
         }
     }
 
+    private void enableHardwareAcceleration(View view, WindowManager.LayoutParams attrs) {
+        // Only enable hardware acceleration if we are not in the system process
+        // The window manager creates ViewRoots to display animated preview windows
+        // of launching apps and we don't want those to be hardware accelerated
+        if (Process.myUid() != Process.SYSTEM_UID) {
+            // Try to enable hardware acceleration if requested
+            if ((view.getContext().getApplicationInfo().flags &
+                    ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
+                final boolean translucent = attrs.format != PixelFormat.OPAQUE;
+                mHwRenderer = HardwareRenderer.createGlRenderer(2, translucent);
+            }
+        }
+    }
+
     public View getView() {
         return mView;
     }