Merge branch 'master' into honeycomb-release
diff --git a/res/layout-land/application.xml b/res/layout-land/application.xml
index 846c81c..6e8c31e 100644
--- a/res/layout-land/application.xml
+++ b/res/layout-land/application.xml
@@ -14,5 +14,5 @@
      limitations under the License.
 -->
 
-<com.android.launcher2.DimmableBubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher2.BubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/WorkspaceIcon.Landscape" />
diff --git a/res/layout-port/application.xml b/res/layout-port/application.xml
index ec66976..32c1510 100644
--- a/res/layout-port/application.xml
+++ b/res/layout-port/application.xml
@@ -4,9 +4,9 @@
      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.
@@ -14,5 +14,5 @@
      limitations under the License.
 -->
 
-<com.android.launcher2.DimmableBubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
- 	style="@style/WorkspaceIcon.Portrait" />
+<com.android.launcher2.BubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
+   style="@style/WorkspaceIcon.Portrait" />
diff --git a/res/layout-xlarge-land/application.xml b/res/layout-xlarge-land/application.xml
new file mode 100644
index 0000000..d0c8d9b
--- /dev/null
+++ b/res/layout-xlarge-land/application.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<com.android.launcher2.DimmableBubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
+   style="@style/WorkspaceIcon.Landscape" />
\ No newline at end of file
diff --git a/res/layout-xlarge-port/application.xml b/res/layout-xlarge-port/application.xml
new file mode 100644
index 0000000..ec66976
--- /dev/null
+++ b/res/layout-xlarge-port/application.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<com.android.launcher2.DimmableBubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
+ 	style="@style/WorkspaceIcon.Portrait" />
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index d06624d..14c42bd 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -20,6 +20,8 @@
 import java.util.Arrays;
 import java.util.Collections;
 
+import com.android.launcher.R;
+
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.res.Resources;
@@ -27,17 +29,7 @@
 import android.graphics.Canvas;
 import android.graphics.PixelFormat;
 import android.graphics.Rect;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-import android.renderscript.Sampler;
-import android.renderscript.Mesh;
-import android.renderscript.Type;
+import android.renderscript.*;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
 import android.util.Log;
@@ -50,8 +42,6 @@
 import android.view.ViewConfiguration;
 import android.view.accessibility.AccessibilityEvent;
 
-import com.android.launcher.R;
-
 public class AllApps3D extends RSSurfaceView
         implements AllAppsView, View.OnClickListener, View.OnLongClickListener, DragSource {
     private static final String TAG = "Launcher.AllApps3D";
@@ -265,22 +255,6 @@
             sRS.mMessageCallback = mMessageProc = new AAMessage();
         }
 
-        if (sRollo.mUniformAlloc != null) {
-            ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
-            i.ScaleOffset.x = (2.f / 480.f);
-            i.ScaleOffset.y = 0;
-            i.ScaleOffset.z = -((float)w / 2) - 0.25f;
-            i.ScaleOffset.w = -380.25f;
-            i.BendPos.x = 120.f;
-            i.BendPos.y = 680.f;
-            if (w > h) {
-                i.ScaleOffset.z = 40.f;
-                i.ScaleOffset.w = h - 40.f;
-                i.BendPos.y = 1.f;
-            }
-            sRollo.mUniformAlloc.set(i, 0, true);
-        }
-
         //long endTime = SystemClock.uptimeMillis();
         //Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
     }
@@ -1029,8 +1003,51 @@
             mScript.set_gSMCell(mMesh);
         }
 
+        Matrix4f getProjectionMatrix(int w, int h) {
+            // range -1,1 in the narrow axis at z = 0.
+            Matrix4f m1 = new Matrix4f();
+            Matrix4f m2 = new Matrix4f();
+
+            if(w > h) {
+                float aspect = ((float)w) / h;
+                m1.loadFrustum(-aspect,aspect,  -1,1,  1,100);
+            } else {
+                float aspect = ((float)h) / w;
+                m1.loadFrustum(-1,1, -aspect,aspect, 1,100);
+            }
+
+            m2.loadRotate(180, 0, 1, 0);
+            m1.loadMultiply(m1, m2);
+
+            m2.loadScale(-2, 2, 1);
+            m1.loadMultiply(m1, m2);
+
+            m2.loadTranslate(0, 0, 2);
+            m1.loadMultiply(m1, m2);
+            return m1;
+        }
+
         void resize(int w, int h) {
-            mPVA.setupProjectionNormalized(w, h);
+            Matrix4f proj = getProjectionMatrix(w, h);
+            mPVA.loadProjection(proj);
+
+            if (mUniformAlloc != null) {
+                ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
+                i.Proj = proj;
+                i.ScaleOffset.x = (2.f / 480.f);
+                i.ScaleOffset.y = 0;
+                i.ScaleOffset.z = -((float)w / 2) - 0.25f;
+                i.ScaleOffset.w = -380.25f;
+                i.BendPos.x = 120.f;
+                i.BendPos.y = 680.f;
+                if (w > h) {
+                    i.ScaleOffset.z = 40.f;
+                    i.ScaleOffset.w = h - 40.f;
+                    i.BendPos.y = 1.f;
+                }
+                mUniformAlloc.set(i, 0, true);
+            }
+
             mWidth = w;
             mHeight = h;
         }
@@ -1050,7 +1067,9 @@
 
             initMesh();
             ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(sRS);
-            String t = "void main() {\n" +
+            String t = "varying vec4 varColor;\n" +
+                    "varying vec4 varTex0;\n" +
+                    "void main() {\n" +
                     // Animation
                     "  float ani = UNI_Position.z;\n" +
 
@@ -1100,7 +1119,7 @@
                     "  pos.z -= ani * 1.5;\n" +
                     "  lum *= 1.0 - ani;\n" +
 
-                    "  gl_Position = UNI_MVP * pos;\n" +
+                    "  gl_Position = UNI_Proj * pos;\n" +
                     "  varColor.rgba = vec4(lum, lum, lum, 1.0);\n" +
                     "  varTex0.xy = ATTRIB_position;\n" +
                     "  varTex0.y = 1.0 - varTex0.y;\n" +
@@ -1110,8 +1129,7 @@
             sb.addConstant(mUniformAlloc.getType());
             sb.addInput(mMesh.getVertexAllocation(0).getType().getElement());
             ProgramVertex pvc = sb.create();
-            pvc.bindAllocation(mPVA);
-            pvc.bindConstants(mUniformAlloc.getAllocation(), 1);
+            pvc.bindConstants(mUniformAlloc.getAllocation(), 0);
 
             mScript.set_gPVCurve(pvc);
         }
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index e3c36af..1e0dad4 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -329,18 +329,19 @@
         }
 
         setMeasuredDimension(widthSize, heightSize);
-
-        if (mFirstLayout && mCurrentPage >= 0 && mCurrentPage < getChildCount()) {
-            setHorizontalScrollBarEnabled(false);
-            scrollTo(getChildOffset(mCurrentPage) - getRelativeChildOffset(mCurrentPage), 0);
-            mScroller.setFinalX(getChildOffset(mCurrentPage) - getRelativeChildOffset(mCurrentPage));
-            setHorizontalScrollBarEnabled(true);
-            mFirstLayout = false;
-        }
     }
 
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+        if (mFirstLayout && mCurrentPage >= 0 && mCurrentPage < getChildCount()) {
+            setHorizontalScrollBarEnabled(false);
+            int newX = getChildOffset(mCurrentPage) - getRelativeChildOffset(mCurrentPage);
+            scrollTo(newX, 0);
+            mScroller.setFinalX(newX);
+            setHorizontalScrollBarEnabled(true);
+            mFirstLayout = false;
+        }
+
         final int childCount = getChildCount();
         int childLeft = 0;
         if (childCount > 0) {
@@ -544,15 +545,21 @@
             return true;
         }
 
-
         switch (action & MotionEvent.ACTION_MASK) {
             case MotionEvent.ACTION_MOVE: {
                 /*
                  * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
                  * whether the user has moved far enough from his original down touch.
                  */
-                determineScrollingStart(ev);
-                break;
+                if (mActivePointerId != INVALID_POINTER) {
+                    determineScrollingStart(ev);
+                    break;
+                }
+                // if mActivePointerId is INVALID_POINTER, then we must have missed an ACTION_DOWN
+                // event. in that case, treat the first occurence of a move event as a ACTION_DOWN
+                // i.e. fall through to the next case (don't break)
+                // (We sometimes miss ACTION_DOWN events in Workspace because it ignores all events
+                // while it's small- this was causing a crash before we checked for INVALID_POINTER)
             }
 
             case MotionEvent.ACTION_DOWN: {
diff --git a/src/com/android/launcher2/allapps.rs b/src/com/android/launcher2/allapps.rs
index b07e1fe..acee82b 100644
--- a/src/com/android/launcher2/allapps.rs
+++ b/src/com/android/launcher2/allapps.rs
@@ -28,6 +28,7 @@
 rs_allocation *gLabelIDs;
 
 typedef struct VpConsts {
+    rs_matrix4x4 Proj;
     float4 Position;
     float4 ScaleOffset;
     float2 BendPos;
@@ -65,6 +66,8 @@
 static int g_Cols;
 static int g_Rows;
 
+rs_allocation g_VPConstAlloc;
+
 // Drawing constants, should be parameters ======
 #define VIEW_ANGLE 1.28700222f
 
@@ -300,6 +303,7 @@
                     vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
                     vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
                                                 - rsAllocationGetDimY(gIconIDs[iconNum])) * 0.5f;
+                    rsAllocationMarkDirty(g_VPConstAlloc);
                     rsgDrawMesh(gSMCell);
                 }
 
@@ -307,6 +311,7 @@
                 vpConstants->ImgSize.x = rsAllocationGetDimX(gIconIDs[iconNum]);
                 vpConstants->ImgSize.y = rsAllocationGetDimY(gIconIDs[iconNum]);
                 vpConstants->Position.y = y - 0.2f;
+                rsAllocationMarkDirty(g_VPConstAlloc);
                 rsgBindTexture(gPFTexMip, 0, gIconIDs[iconNum]);
                 rsgDrawMesh(gSMCell);
 
@@ -314,6 +319,7 @@
                 vpConstants->ImgSize.x = rsAllocationGetDimX(gLabelIDs[iconNum]);
                 vpConstants->ImgSize.y = rsAllocationGetDimY(gLabelIDs[iconNum]);
                 vpConstants->Position.y = y - 64.f - 0.2f;
+                rsAllocationMarkDirty(g_VPConstAlloc);
                 rsgBindTexture(gPFTexMipAlpha, 0, gLabelIDs[iconNum]);
                 rsgDrawMesh(gSMCell);
             }
@@ -328,6 +334,7 @@
     // Compute dt in seconds.
     // physics may break if DT is large.
     g_DT = min(rsGetDt(), 0.1f);
+    g_VPConstAlloc = rsGetAllocation(vpConstants);
 
     if (g_Zoom != gZoomTarget) {
         float dz = g_DT * 1.7f;