Re-enable DisplayList properties.

Re-enabling DisplayList properties last week caused some app
errors due to the way that some transforms were being handled (specifically,
those coming from the old Animations and ViewGroup's childStaticTransformation
field). This change pushes *all* transform/alpha data from View.draw() into
the view's DisplayList, making DisplayLists more encapsulated (and correct).

Change-Id: Ia702c6aae050784bb3ed505aa87553113f8a1938
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index b310d93..f4c0841 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -638,7 +638,6 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        
 
         <activity
                 android:name="StackActivity"
@@ -649,5 +648,14 @@
             </intent-filter>
         </activity>
 
+        <activity
+                android:name="TransformsAndAnimationsActivity"
+                android:label="_TransformAnim">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
     </application>
 </manifest>
diff --git a/tests/HwAccelerationTest/res/layout/transforms_and_animations.xml b/tests/HwAccelerationTest/res/layout/transforms_and_animations.xml
new file mode 100644
index 0000000..1595502
--- /dev/null
+++ b/tests/HwAccelerationTest/res/layout/transforms_and_animations.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <CheckBox android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="None"
+                android:checked="true"
+                android:id="@+id/layersNoneCB"/>
+
+        <CheckBox android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="Hardware"
+                  android:id="@+id/layersHwCB"/>
+
+        <CheckBox android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="Software"
+                  android:id="@+id/layersSwCB"/>
+
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="1"
+                android:id="@+id/button1"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="2"
+                android:id="@+id/button2"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="3"
+                android:id="@+id/button3"/>
+
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="1a"
+                android:id="@+id/button1a"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="2a"
+                android:id="@+id/button2a"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="3a"
+                android:id="@+id/button3a"/>
+
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="1b"
+                android:id="@+id/button1b"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="2b"
+                android:id="@+id/button2b"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="3b"
+                android:id="@+id/button3b"/>
+
+    </LinearLayout>
+
+    <view class="com.android.test.hwui.TransformsAndAnimationsActivity$MyLayout"
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="4"
+                android:id="@+id/button4"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="5"
+                android:id="@+id/button5"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="6"
+                android:id="@+id/button6"/>
+
+    </view>
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="7"
+                android:id="@+id/button7"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="8"
+                android:id="@+id/button8"/>
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TransformsAndAnimationsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TransformsAndAnimationsActivity.java
new file mode 100644
index 0000000..684d179
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TransformsAndAnimationsActivity.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.test.hwui;
+
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.Animation;
+import android.view.animation.Transformation;
+import android.view.animation.TranslateAnimation;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.LinearLayout;
+
+public class TransformsAndAnimationsActivity extends Activity {
+    Button button1;
+    Button button2;
+    Button button3;
+    Button button1a;
+    Button button2a;
+    Button button3a;
+    Button button1b;
+    Button button2b;
+    Button button3b;
+    Button button4;
+    Button button5;
+    Button button6;
+    Button button7;
+    Button button8;
+    CheckBox layersNoneCB;
+    CheckBox layersHardwareCB;
+    CheckBox layersSoftwareCB;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.transforms_and_animations);
+
+        button1 = (Button) findViewById(R.id.button1);
+        button2 = (Button) findViewById(R.id.button2);
+        button3 = (Button) findViewById(R.id.button3);
+        button1a = (Button) findViewById(R.id.button1a);
+        button2a = (Button) findViewById(R.id.button2a);
+        button3a = (Button) findViewById(R.id.button3a);
+        button1b = (Button) findViewById(R.id.button1b);
+        button2b = (Button) findViewById(R.id.button2b);
+        button3b = (Button) findViewById(R.id.button3b);
+        button4 = (Button) findViewById(R.id.button4);
+        button5 = (Button) findViewById(R.id.button5);
+        button6 = (Button) findViewById(R.id.button6);
+        button7 = (Button) findViewById(R.id.button7);
+        button8 = (Button) findViewById(R.id.button8);
+        layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
+        layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
+        layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
+
+        layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (isChecked) {
+                    setLayerType(View.LAYER_TYPE_NONE);
+                    layersHardwareCB.setChecked(false);
+                    layersSoftwareCB.setChecked(false);
+                }
+            }
+        });
+
+        layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (isChecked) {
+                    setLayerType(View.LAYER_TYPE_SOFTWARE);
+                    layersHardwareCB.setChecked(false);
+                    layersNoneCB.setChecked(false);
+                }
+            }
+        });
+
+        layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (isChecked) {
+                    setLayerType(View.LAYER_TYPE_HARDWARE);
+                    layersNoneCB.setChecked(false);
+                    layersSoftwareCB.setChecked(false);
+                }
+            }
+        });
+
+        button1a.setAlpha(.5f);
+        button2a.setAlpha(.5f);
+        button3a.setAlpha(.5f);
+        button3.setTranslationX(50);
+        button7.setTranslationX(50);
+        button8.setTranslationX(50);
+
+        final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
+        alphaAnim.setDuration(1000);
+        alphaAnim.setRepeatCount(Animation.INFINITE);
+        alphaAnim.setRepeatMode(Animation.REVERSE);
+
+        final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
+        transAnim.setDuration(1000);
+        transAnim.setRepeatCount(Animation.INFINITE);
+        transAnim.setRepeatMode(Animation.REVERSE);
+        
+        getWindow().getDecorView().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                button1.startAnimation(alphaAnim);
+                button2.startAnimation(alphaAnim);
+                button3.startAnimation(alphaAnim);
+
+                button1a.startAnimation(alphaAnim);
+                button2a.startAnimation(alphaAnim);
+                button3a.startAnimation(alphaAnim);
+
+                button1b.startAnimation(alphaAnim);
+                button2b.startAnimation(alphaAnim);
+                button3b.startAnimation(alphaAnim);
+                startAnimator(button1b);
+                startAnimator(button2b);
+                startAnimator(button3b);
+
+                button7.startAnimation(transAnim);
+                button8.startAnimation(transAnim);
+            }
+        }, 2000);
+    }
+
+    private void setLayerType(int layerType) {
+        button1.setLayerType(layerType, null);
+        button2.setLayerType(layerType, null);
+        button3.setLayerType(layerType, null);
+        button1a.setLayerType(layerType, null);
+        button2a.setLayerType(layerType, null);
+        button3a.setLayerType(layerType, null);
+        button1b.setLayerType(layerType, null);
+        button2b.setLayerType(layerType, null);
+        button3b.setLayerType(layerType, null);
+        button4.setLayerType(layerType, null);
+        button5.setLayerType(layerType, null);
+        button6.setLayerType(layerType, null);
+        button7.setLayerType(layerType, null);
+        button8.setLayerType(layerType, null);
+    }
+
+    private void startAnimator(View target) {
+        ObjectAnimator anim1b = ObjectAnimator.ofFloat(target, View.ALPHA, 0);
+        anim1b.setRepeatCount(ValueAnimator.INFINITE);
+        anim1b.setRepeatMode(ValueAnimator.REVERSE);
+        anim1b.setDuration(1000);
+        anim1b.start();
+    }
+
+    public static class MyLayout extends LinearLayout {
+
+        public MyLayout(Context context) {
+            super(context);
+            setStaticTransformationsEnabled(true);
+        }
+
+        public MyLayout(Context context, AttributeSet attrs) {
+            super(context, attrs);
+            setStaticTransformationsEnabled(true);
+        }
+
+        public MyLayout(Context context, AttributeSet attrs, int defStyle) {
+            super(context, attrs, defStyle);
+            setStaticTransformationsEnabled(true);
+        }
+
+        @Override
+        protected boolean getChildStaticTransformation(View child, Transformation t) {
+            t.clear();
+            t.setAlpha(.35f);
+
+            return true;
+        }
+    }
+}
+