Merge "Don't try to open action bar overflow menus from bogus events" into jb-mr1-dev
diff --git a/Android.mk b/Android.mk
index be98487..d38150f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -429,6 +429,7 @@
     -since ./frameworks/base/api/14.txt 14 \
     -since ./frameworks/base/api/15.txt 15 \
     -since ./frameworks/base/api/16.txt 16 \
+    -since ./frameworks/base/api/17.txt 17 \
 		-werror -hide 113 \
 		-overview $(LOCAL_PATH)/core/java/overview.html
 
@@ -539,7 +540,7 @@
 
 ## SDK version identifiers used in the published docs
   # major[.minor] version for current SDK. (full releases only)
-framework_docs_SDK_VERSION:=4.1
+framework_docs_SDK_VERSION:=4.2
   # release version (ie "Release x")  (full releases only)
 framework_docs_SDK_REL_ID:=1
 
diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java
index b72b8cb..e0c5bbd 100644
--- a/core/java/android/widget/Gallery.java
+++ b/core/java/android/widget/Gallery.java
@@ -182,6 +182,12 @@
      */
     private boolean mIsRtl = true;
     
+    /**
+     * Offset between the center of the selected child view and the center of the Gallery.
+     * Used to reset position correctly during layout.
+     */
+    private int mSelectedCenterOffset;
+
     public Gallery(Context context) {
         this(context, null);
     }
@@ -395,6 +401,14 @@
         
         setSelectionToCenterChild();
 
+        final View selChild = mSelectedChild;
+        if (selChild != null) {
+            final int childLeft = selChild.getLeft();
+            final int childCenter = selChild.getWidth() / 2;
+            final int galleryCenter = getWidth() / 2;
+            mSelectedCenterOffset = childLeft + childCenter - galleryCenter;
+        }
+
         onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these.
 
         invalidate();
@@ -537,6 +551,7 @@
             // We haven't been callbacking during the fling, so do it now
             super.selectionChanged();
         }
+        mSelectedCenterOffset = 0;
         invalidate();
     }
     
@@ -650,7 +665,8 @@
         View sel = makeAndAddView(mSelectedPosition, 0, 0, true);
         
         // Put the selected child in the center
-        int selectedOffset = childrenLeft + (childrenWidth / 2) - (sel.getWidth() / 2);
+        int selectedOffset = childrenLeft + (childrenWidth / 2) - (sel.getWidth() / 2) +
+                mSelectedCenterOffset;
         sel.offsetLeftAndRight(selectedOffset);
 
         fillToGalleryRight();
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index 704f6b6..4918e48 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -1361,6 +1361,14 @@
             // Allow text entry rather than strictly numeric entry.
             mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT
                     | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
+            // Make sure the min, max, respect the size of the displayed
+            // values. This will take care of the current value as well.
+            if (getMinValue() >= displayedValues.length) {
+                setMinValue(0);
+            }
+            if (getMaxValue() >= displayedValues.length) {
+                setMaxValue(displayedValues.length - 1);
+            }
         } else {
             mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
         }
diff --git a/docs/html/distribute/distribute_toc.cs b/docs/html/distribute/distribute_toc.cs
index 76073fb..84103b9 100644
--- a/docs/html/distribute/distribute_toc.cs
+++ b/docs/html/distribute/distribute_toc.cs
@@ -75,7 +75,7 @@
        <li><a href="<?cs var:toroot ?>distribute/promote/device-art.html">
         <span class="en">Device Art Generator</a></li>
        <li><a href="<?cs var:toroot ?>distribute/googleplay/promote/brand.html">
-        <span class="en">Brand Assets and Guidelines</a></li>
+        <span class="en">Brand Guidelines</a></li>
      </ul>
    </li>
 
diff --git a/docs/html/distribute/googleplay/promote/badges.jd b/docs/html/distribute/googleplay/promote/badges.jd
index 7b64be3..d6f15fb 100644
--- a/docs/html/distribute/googleplay/promote/badges.jd
+++ b/docs/html/distribute/googleplay/promote/badges.jd
@@ -13,7 +13,7 @@
 wraps your screenshots in real device artwork.</p>
 
 <p>For guidelines when using the Google Play badge and other brand assets,
-see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand Assets and
+see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand
 Guidelines</a>.</p>
 
 <style type="text/css">
diff --git a/docs/html/distribute/googleplay/promote/brand.jd b/docs/html/distribute/googleplay/promote/brand.jd
index 4051553..875794a 100644
--- a/docs/html/distribute/googleplay/promote/brand.jd
+++ b/docs/html/distribute/googleplay/promote/brand.jd
@@ -1,151 +1,172 @@
-page.title=Brand Assets, Icons, and Guidelines
+page.title=Brand Guidelines
 @jd:body
 
-<p>We encourage you to use the Android and Google Play brands in your
-promotional materials. You can use the icons and other assets on this page in
-any way you want, provided that you follow the guidelines described below.</p>
 
-<h2 id="brand-android">Android Brand</h2>
 
-<div>
-  <div style="float:right;width:50%;padding:1.5em;">
-    <img alt="" src="{@docRoot}images/brand/droid.gif">
+<p>We encourage you to use the Android and Google Play brands with your Android app
+promotional materials. You can use the icons and other assets on this page
+provided that you follow the guidelines described below.</p>
+
+<h2 id="brand-android">Android</h2>
+
+ <p>The following are guidelines for the Android brand
+ and related assets.</p>
+ 
+
+  <h4 style="clear:right">Android in text</h4>
+    
+  <div style="float:right;clear:right;width:200px;margin:0 0 20px 30px">
+    <img alt="" src="{@docRoot}images/brand/mediaplayer.png">
+  </div>
+    <ul>
+    <li>Android&trade; should have a trademark symbol the first time it appears in a creative.</li>
+    <li>Android should always be capitalized and is never plural or possessive.</li>
+    <li>"Android" by itself cannot be used in the name of an application name or accessory product.
+Instead use "for Android."
+      <ul>
+        <li><span style="color:red">Incorrect</span>: "Android MediaPlayer"</li>
+        <li><span style="color:green">Correct</span>: "MediaPlayer for Android"</li>
+      </ul>
+      <p>If used with your logo, "for Android" needs to be smaller in size than your logo.
+      First instance of this use should be followed by a TM symbol, "for Android&trade;".</p>
+    </li>
+    <li>Android may be used as a descriptor, as long as it is followed by a proper generic term.
+      <ul>
+        <li><span style="color:red">Incorrect</span>: "Android MediaPlayer" or "Android XYZ app"</li>
+        <li><span style="color:green">Correct</span>: "Android features" or "Android applications"</li>
+      </ul>
+    </li>
+    </ul>
+  
+    <p>Any use of the Android name needs to include this
+    attribution in your communication:</p>
+    <blockquote><em>Android is a trademark of Google Inc.</em></blockquote></p>
+
+
+ <h4>Android robot</h4>
+
+  <div style="float:right;width:200px;margin-left:30px">
+    <img alt="" src="{@docRoot}images/brand/Android_Robot_100.png"
+      style="margin-left:50px">
+    <p style="text-align:center">
+       <a href="{@docRoot}images/brand/Android_Robot_100.png">100x118</a> |
+       <a href="{@docRoot}images/brand/Android_Robot_200.png">200x237</a><br>
+       <a href="{@docRoot}images/brand/Android_Robot_outlined.ai">Illustrator (.ai)</a></p>
   </div>
 
-  <div style="width:45%;">
-    <h4>01/ Android Robot</h4>
-
-    <p> Can be used, reproduced, and modified freely in marketing
-    communications. Our standard color value for print is PMS 376C. Our online hex
-    color is <span id= "android-green">#A4C639</span>.</p>
+    <p>The Android robot can be used, reproduced, and modified freely in marketing
+    communications. The color value for print is PMS 376C and the online hex
+    color is <span style="color:#A4C639">#A4C639</span>.</p>
 
     <p>When using the Android Robot or any modification of it, proper attribution is
-    required under the terms of the Creative Commons Attribution license. For more
-    details on proper attribution, please see the <a
-    href="{@docRoot}license.html#attribution">Content License</a> document. </p>
+    required under the terms of the <a href="http://creativecommons.org/licenses/by/3.0/">Creative
+Commons Attribution</a> license:</p>
+   
+    <blockquote><em>The Android robot is reproduced or modified from work created and shared by Google and
+used according to terms described in the Creative Commons 3.0 Attribution License.</em></blockquote>
+    
+    <p>You may not file trademark applications incorporating the Android robot logo or
+derivatives thereof. We want to ensure that the Android robot remains available
+for all to use.</p>
+
+
+<h4 style="clear:right">Android logo</h4>
+
+<div style="float:right;width:210px;margin-left:30px;margin-top:-10px">
+  <img alt="" src="{@docRoot}images/brand/android_logo_no.png">
+</div>
+
+<p>The Android logo may not be used. Nor can this be used with the Android robot.</p>
+<p>The custom typeface may not be used.</p>
+
+
+
+
+<h2 id="brand-google_play">Google Play</h2>
+
+
+ <p>The following are guidelines for the Google Play brand
+ and related assets.</p>
+
+<h4>Google Play in text</h4>
+
+<p>Always include a TM symbol on the first or most prominent instance of Google Play&trade;
+in text.</p>
+
+<p>When referring to the mobile experience, use "Google Play" unless the text is clearly
+instructional for the user. For example, a marketing headline might read "Download our
+games on Google Play&trade;," but instructional text woud read "Download our games using the Google
+Play&trade; Store app."
+
+ <p>Any use of the Google Play name or icon needs to include this
+    attribution in your communication:</p>
+
+<blockquote><em>Google Play is a trademark of Google Inc.</em></blockquote>
+
+
+  <div style="float:right;width:96px;margin-left:30px;margin-top:-20px">
+     <img src="{@docRoot}images/brand/Google_Play_Store_96.png" alt="">
+    <p style="text-align:center">
+       <a href="{@docRoot}images/brand/Google_Play_Store_48.png">48x48</a> |
+       <a href="{@docRoot}images/brand/Google_Play_Store_96.png">96x96</a><br>
+       <a href="{@docRoot}images/brand/Google_Play_Store.ai">Illustrator (.ai)</a>
+       </p>
   </div>
-<div>
+  
+<h4>Google Play Store icon</h4>
 
-<div style="clear:both">
-  <div style="float:right;width:50%;padding:1.5em;">
-    <img alt="" src="{@docRoot}images/brand/logo_android.gif">
-  </div>
+<p>You may use the Google Play Store icon, but you may not modify it.</p>
 
-  <div style="width:45%;">
-    <h4>02/ Android Logo</h4>
+<p>When labeling or referring to the icon, the name can be either the full app
+name, Google Play Store, or the app display name, Play Store.</p>
 
-    <p>The Android logo may not be used.</p>
-  </div>
-<div>
-
-<div style="clear:both">
-  <div style="float:right;width:50%;padding:1.5em;">
-    <img alt="" src="{@docRoot}images/brand/norad.gif">
-  </div>
-
-  <div style="width:45%;">
-    <h4>03/ Android Custom Typeface</h4>
-
-    <p>The custom typeface may not be used.</p>
-  </div>
-<div>
-
-<div style="clear:both">
-  <div style="float:right;width:50%;padding:1.5em;">
-    <img alt="" src="{@docRoot}images/brand/mediaplayer.gif">
-  </div>
-
-  <div style="width:45%;">
-    <h4>04/ Android in Official Names</h4>
-<p>Any name with 'Android' alone may not be used in a name without permission. Any name
-            with 'Droid' alone may not be used in a name.</p>
-            
-          <p>The word 'Android' may be used only as a descriptor, 'for Android'. If used with your
-            logo, 'for Android' needs to be smaller in size than your logo. First instance of this
-            use should be followed by a TM symbol, 'for Android™'.</p>
-            
-          <p>If you are not sure you meet these criteria, <a href=
-            "http://services.google.com/permissions/application">please contact us</a>. </p>
-  </div>
-<div>
-
-<div style="clear:both">
-  <div style="float:right;width:50%;padding:1.5em;">
-    <img alt="" src="{@docRoot}images/brand/learnmore.gif">
-  </div>
-
-  <div style="width:45%;">
-    <h4>05/ Android in Messaging</h4>
-          <p>
-            May be used in text as a descriptor, as long as it is followed by a proper generic term
-            (e.g. "Android™ application"). First instance of this use should be followed by a TM
-            symbol.
-          </p>       
-  </div>
-<div>
-          <p class="caution"><strong>Note: Any usage of #04 or #05 needs to include footer attribution in your
-          communication:</strong><br /><span style="margin-left:1.5em">
-          "Android is a trademark of Google Inc."</span>
-        </p>
-
-
-<h2 id="brand-google_play">Google Play Brand</h2>
-
-    <img alt="" src="http://www.android.com/images/brand/google_play_logo_450.png"
-         style="float:right;">
-      
-    <img alt="Android app on Google Play badge, large"
-         src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
-         style="float:right;clear:right;">
-
-    <img alt="Android app on Google Play badge, small"
-         src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
-         style="float:right;margin:0 30px 30px">
-
-    <img alt="Get it on Google Play badge, large"
-         src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
-         style="float:right;clear:right;">
-
-    <img alt="Get it on Google Play badge, small"
-         src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
-         style="float:right;margin:0 30px 30px;">
         
-    <h4>06/ <em>Get it on Google Play</em> Badge
-          </h4>
-          <p>
-            The "Get it on Google Play" and "Android App on Google Play" logos are badges that you
-            can use on your web site and promotional materials, to point to your products on Google
-            Play.
-          </p>
-          <p>
-            Guidelines for usage:
-          </p>
-          <ul>
-            <li>Do not modify the color, proportions, spacing or any other aspect of the badge image.
-            </li>
-            <li>When used alongside logos for other application marketplaces, the Google Play logo
-            should be of equal or greater size.</li>
-            <li>When used online, the badge should link to either:
-              <ul>
-                <li>A list of products published by you, for example:<br />
-                <span style="margin-left:1em;">http://play.google.com/store/search?q=<em>publisherName</em></span>
-                </li>
-                <li>A specific app product details page within Google Play, for example:<br />
-                <span style="margin-left:1em;">http://play.google.com/store/apps/details?id=<em>packageName</em></span>
-                </li>
-              </ul>
-            </li>
+<h4>Google Play badge</h4>
+      
+  <div style="float:right;clear:right;width:172px;margin-left:30px">
+    <img src="{@docRoot}images/brand/en_app_rgb_wo_60.png" alt="">
+    <p style="text-align:center">
+       <a href="{@docRoot}images/brand/en_app_rgb_wo_45.png">129x45</a> |
+       <a href="{@docRoot}images/brand/en_app_rgb_wo_60.png">172x60</a><br>
+       <a href="{@docRoot}images/brand/en_app_rgb_wo.ai">Illustrator (.ai)</a></p>
+  </div>
+      
+  <div style="float:right;clear:right;width:172px;margin-left:30px">
+    <img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png" alt="">
+    <p style="text-align:center">
+       <a href="{@docRoot}images/brand/en_generic_rgb_wo_45.png">129x45</a> |
+       <a href="{@docRoot}images/brand/en_generic_rgb_wo_60.png">172x60</a><br>
+       <a href="{@docRoot}images/brand/en_generic_rgb_wo.ai">Illustrator (.ai)</a></p>
+  </div>
+         
+  <p>The "Get it on Google Play" and "Android App on Google Play" logos are badges that you
+    can use on your web site and promotional materials, to point to your products on Google
+    Play.</p>
+
+  <ul>
+    <li>Do not modify the color, proportions, spacing or any other aspect of the badge image.
+    </li>
+    <li>When used alongside logos for other application marketplaces, the Google Play logo
+    should be of equal or greater size.</li>
+    <li>When used online, the badge should link to either:
+      <ul>
+        <li>A list of products published by you, for example:<br />
+        <span style="margin-left:1em;">http://play.google.com/store/search?q=<em>publisherName</em></span>
+        </li>
+        <li>A specific app product details page within Google Play, for example:<br />
+        <span style="margin-left:1em;">http://play.google.com/store/apps/details?id=<em>packageName</em></span>
+        </li>
+      </ul>
+    </li>
   </ul>
 
-          <p>For your convenience, you can use the 
-            <a href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>
-            to create badges that link to your apps on Google Play.</p>
-            
-          <p>For details on all the ways that you can link to your product details page in Google Play, 
-            see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
+  <p>For your convenience, you can use the 
+    <a href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>
+    to create badges that link to your apps on Google Play.</p>
+    
+  <p>For details on all the ways that you can link to your product details page in Google Play, 
+    see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
 
-<h2>Other Brands</h2>
 
-<p>Any other brands or icons depicted on this site are <em>not</em> are the property of their
-respective owners and usage is reserved. You must seek the developer for appropriate permission to use them.</p>
-
+<p>If you are not sure you meet these criteria, <a href=
+            "http://services.google.com/permissions/application">please contact us</a>. </p>
diff --git a/docs/html/distribute/googleplay/promote/linking.jd b/docs/html/distribute/googleplay/promote/linking.jd
index 4a1b198..2d3bd05 100644
--- a/docs/html/distribute/googleplay/promote/linking.jd
+++ b/docs/html/distribute/googleplay/promote/linking.jd
@@ -5,7 +5,7 @@
 <div class="sidebox">
 <a href="badges.html">
   <img alt="Get it on Google Play"
-       src="http://www.android.com/images/brand/get_it_on_play_logo_small.png" />
+       src="{@docRoot}en_app_rgb_wo_45.png" />
 </a>
 <p>For a link that includes the Google Play brand icon, check out the <a href="badges.html">Badges</a> page. </p>
 </div>
diff --git a/docs/html/images/brand/Android_Robot_100.png b/docs/html/images/brand/Android_Robot_100.png
new file mode 100644
index 0000000..946ee3a
--- /dev/null
+++ b/docs/html/images/brand/Android_Robot_100.png
Binary files differ
diff --git a/docs/html/images/brand/Android_Robot_200.png b/docs/html/images/brand/Android_Robot_200.png
new file mode 100644
index 0000000..40bf934
--- /dev/null
+++ b/docs/html/images/brand/Android_Robot_200.png
Binary files differ
diff --git a/docs/html/images/brand/Android_Robot_500.png b/docs/html/images/brand/Android_Robot_500.png
new file mode 100644
index 0000000..1fbfc51
--- /dev/null
+++ b/docs/html/images/brand/Android_Robot_500.png
Binary files differ
diff --git a/docs/html/images/brand/Android_Robot_outlined.ai b/docs/html/images/brand/Android_Robot_outlined.ai
new file mode 100644
index 0000000..9105cba
--- /dev/null
+++ b/docs/html/images/brand/Android_Robot_outlined.ai
Binary files differ
diff --git a/docs/html/images/brand/Google_Play_Store.ai b/docs/html/images/brand/Google_Play_Store.ai
new file mode 100644
index 0000000..51f07c6
--- /dev/null
+++ b/docs/html/images/brand/Google_Play_Store.ai
Binary files differ
diff --git a/docs/html/images/brand/Google_Play_Store_48.png b/docs/html/images/brand/Google_Play_Store_48.png
new file mode 100644
index 0000000..2f0cfe0
--- /dev/null
+++ b/docs/html/images/brand/Google_Play_Store_48.png
Binary files differ
diff --git a/docs/html/images/brand/Google_Play_Store_96.png b/docs/html/images/brand/Google_Play_Store_96.png
new file mode 100644
index 0000000..6e2c835
--- /dev/null
+++ b/docs/html/images/brand/Google_Play_Store_96.png
Binary files differ
diff --git a/docs/html/images/brand/android_logo_no.png b/docs/html/images/brand/android_logo_no.png
new file mode 100644
index 0000000..8de22d8
--- /dev/null
+++ b/docs/html/images/brand/android_logo_no.png
Binary files differ
diff --git a/docs/html/images/brand/droid.gif b/docs/html/images/brand/droid.gif
deleted file mode 100644
index 7c7b941..0000000
--- a/docs/html/images/brand/droid.gif
+++ /dev/null
Binary files differ
diff --git a/docs/html/images/brand/en_app_rgb_wo.ai b/docs/html/images/brand/en_app_rgb_wo.ai
new file mode 100644
index 0000000..db27314
--- /dev/null
+++ b/docs/html/images/brand/en_app_rgb_wo.ai
Binary files differ
diff --git a/docs/html/images/brand/en_generic_rgb_wo.ai b/docs/html/images/brand/en_generic_rgb_wo.ai
new file mode 100644
index 0000000..57c1e47
--- /dev/null
+++ b/docs/html/images/brand/en_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/html/images/brand/google_play_logo_450.png b/docs/html/images/brand/google_play_logo_450.png
deleted file mode 100644
index 59a1fcf..0000000
--- a/docs/html/images/brand/google_play_logo_450.png
+++ /dev/null
Binary files differ
diff --git a/docs/html/images/brand/learnmore.gif b/docs/html/images/brand/learnmore.gif
deleted file mode 100644
index 70a8e6b..0000000
--- a/docs/html/images/brand/learnmore.gif
+++ /dev/null
Binary files differ
diff --git a/docs/html/images/brand/logo_android.gif b/docs/html/images/brand/logo_android.gif
deleted file mode 100644
index 169c764..0000000
--- a/docs/html/images/brand/logo_android.gif
+++ /dev/null
Binary files differ
diff --git a/docs/html/images/brand/mediaplayer.gif b/docs/html/images/brand/mediaplayer.gif
deleted file mode 100644
index 860d110..0000000
--- a/docs/html/images/brand/mediaplayer.gif
+++ /dev/null
Binary files differ
diff --git a/docs/html/images/brand/mediaplayer.png b/docs/html/images/brand/mediaplayer.png
new file mode 100644
index 0000000..f857d5f
--- /dev/null
+++ b/docs/html/images/brand/mediaplayer.png
Binary files differ
diff --git a/docs/html/images/brand/norad.gif b/docs/html/images/brand/norad.gif
deleted file mode 100644
index d8707bd..0000000
--- a/docs/html/images/brand/norad.gif
+++ /dev/null
Binary files differ
diff --git a/docs/html/legal.jd b/docs/html/legal.jd
index 3206503..1698af0f 100644
--- a/docs/html/legal.jd
+++ b/docs/html/legal.jd
@@ -39,7 +39,7 @@
 use of it must be attributed as such.</p>
 
 <p>For more information about Android brands, see the <a
-href="{@docRoot}distribute/googleplay/promote/brand.html">Android Branding Guidelines</a>.</p>
+href="{@docRoot}distribute/googleplay/promote/brand.html">Brand Guidelines</a>.</p>
 
 <p>All other trademarks are the property of their respective owners.</p>
 
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 6ca70a4..f84c847 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -1573,7 +1573,8 @@
 }
 
 status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
-    const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
+    const bool reject = quickRejectNoScissor(left, top,
+            left + bitmap->width(), top + bitmap->height());
     uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
     addBitmap(bitmap);
     addPoint(left, top);
@@ -1587,7 +1588,7 @@
     const mat4 transform(*matrix);
     transform.mapRect(r);
 
-    const bool reject = quickReject(r.left, r.top, r.right, r.bottom);
+    const bool reject = quickRejectNoScissor(r.left, r.top, r.right, r.bottom);
     uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
     addBitmap(bitmap);
     addMatrix(matrix);
@@ -1599,7 +1600,7 @@
 status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
         float srcRight, float srcBottom, float dstLeft, float dstTop,
         float dstRight, float dstBottom, SkPaint* paint) {
-    const bool reject = quickReject(dstLeft, dstTop, dstRight, dstBottom);
+    const bool reject = quickRejectNoScissor(dstLeft, dstTop, dstRight, dstBottom);
     uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
     addBitmap(bitmap);
     addBounds(srcLeft, srcTop, srcRight, srcBottom);
@@ -1611,7 +1612,8 @@
 
 status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
         SkPaint* paint) {
-    const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
+    const bool reject = quickRejectNoScissor(left, top,
+            left + bitmap->width(), top + bitmap->height());
     uint32_t* location = addOp(DisplayList::DrawBitmapData, reject);
     addBitmapData(bitmap);
     addPoint(left, top);
@@ -1644,7 +1646,7 @@
     SkXfermode::Mode mode;
     OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
 
-    const bool reject = quickReject(left, top, right, bottom);
+    const bool reject = quickRejectNoScissor(left, top, right, bottom);
     uint32_t* location = addOp(DisplayList::DrawPatch, reject);
     addBitmap(bitmap);
     addInts(xDivs, width);
@@ -1667,7 +1669,7 @@
 status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
         SkPaint* paint) {
     const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
-            quickReject(left, top, right, bottom);
+            quickRejectNoScissor(left, top, right, bottom);
     uint32_t* location = addOp(DisplayList::DrawRect, reject);
     addBounds(left, top, right, bottom);
     addPaint(paint);
@@ -1678,7 +1680,7 @@
 status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
         float rx, float ry, SkPaint* paint) {
     const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
-            quickReject(left, top, right, bottom);
+            quickRejectNoScissor(left, top, right, bottom);
     uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
     addBounds(left, top, right, bottom);
     addPoint(rx, ry);
@@ -1721,7 +1723,7 @@
     left -= offset;
     top -= offset;
 
-    const bool reject = quickReject(left, top, left + width, top + height);
+    const bool reject = quickRejectNoScissor(left, top, left + width, top + height);
     uint32_t* location = addOp(DisplayList::DrawPath, reject);
     addPath(path);
     addPaint(paint);
@@ -1791,7 +1793,7 @@
     if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
         SkPaint::FontMetrics metrics;
         paint->getFontMetrics(&metrics, 0.0f);
-        reject = quickReject(x, y + metrics.fTop, x + length, y + metrics.fBottom);
+        reject = quickRejectNoScissor(x, y + metrics.fTop, x + length, y + metrics.fBottom);
     }
 
     uint32_t* location = addOp(DisplayList::DrawText, reject);
diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp
index 87add17..a924362 100644
--- a/libs/hwui/Matrix.cpp
+++ b/libs/hwui/Matrix.cpp
@@ -73,6 +73,11 @@
     return mIsIdentity;
 }
 
+bool Matrix4::isPerspective() const {
+    return data[kPerspective0] != 0.0f || data[kPerspective1] != 0.0f ||
+            data[kPerspective2] != 1.0f;
+}
+
 void Matrix4::load(const float* v) {
     memcpy(data, v, sizeof(data));
     // TODO: Do something smarter here
diff --git a/libs/hwui/Matrix.h b/libs/hwui/Matrix.h
index 02b781e..f86823d 100644
--- a/libs/hwui/Matrix.h
+++ b/libs/hwui/Matrix.h
@@ -115,6 +115,7 @@
     bool isPureTranslate() const;
     bool isSimple() const;
     bool isIdentity() const;
+    bool isPerspective() const;
 
     bool changesBounds() const;
 
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 684d5e1..c015077 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2647,20 +2647,21 @@
     setupDrawShaderUniforms(pureTranslate);
     setupDrawTextGammaUniforms();
 
-    const Rect* clip = pureTranslate ? mSnapshot->clipRect : &mSnapshot->getLocalClip();
+    const Rect* clip = pureTranslate ? mSnapshot->clipRect :
+            (mSnapshot->hasPerspectiveTransform() ? NULL : &mSnapshot->getLocalClip());
     Rect bounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f);
 
     const bool hasActiveLayer = hasLayer();
 
     bool status;
-    if (paint->getTextAlign() != SkPaint::kLeft_Align) {
+    if (CC_UNLIKELY(paint->getTextAlign() != SkPaint::kLeft_Align)) {
         SkPaint paintCopy(*paint);
         paintCopy.setTextAlign(SkPaint::kLeft_Align);
         status = fontRenderer.renderPosText(&paintCopy, clip, text, 0, bytesCount, count, x, y,
-            positions, hasActiveLayer ? &bounds : NULL);
+                positions, hasActiveLayer ? &bounds : NULL);
     } else {
         status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y,
-            positions, hasActiveLayer ? &bounds : NULL);
+                positions, hasActiveLayer ? &bounds : NULL);
     }
 
     if (status && hasActiveLayer) {
diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp
index 4484676..fbc8455 100644
--- a/libs/hwui/Snapshot.cpp
+++ b/libs/hwui/Snapshot.cpp
@@ -178,6 +178,10 @@
     flags |= Snapshot::kFlagClipSet;
 }
 
+bool Snapshot::hasPerspectiveTransform() const {
+    return transform->isPerspective();
+}
+
 const Rect& Snapshot::getLocalClip() {
     mat4 inverse;
     inverse.loadInverse(*transform);
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index a89b740..9c612ff 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -121,6 +121,11 @@
     bool isIgnored() const;
 
     /**
+     * Indicates whether the current transform has perspective components.
+     */
+    bool hasPerspectiveTransform() const;
+
+    /**
      * Dirty flags.
      */
     int flags;
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp
index 6e205b8..7bfa63d 100644
--- a/libs/hwui/font/Font.cpp
+++ b/libs/hwui/font/Font.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "OpenGLRenderer"
+
 #include <cutils/compiler.h>
 
 #include <SkUtils.h>
diff --git a/services/jni/com_android_server_power_PowerManagerService.cpp b/services/jni/com_android_server_power_PowerManagerService.cpp
index 38af38d..dcc2b58 100644
--- a/services/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/jni/com_android_server_power_PowerManagerService.cpp
@@ -183,14 +183,16 @@
             gPowerModule->setInteractive(gPowerModule, true);
         }
 
+        const sp<IBinder>& display = s->getBuiltInDisplay(0);   // TODO: support multiple displays
         {
             ALOGD_IF_SLOW(100, "Excessive delay in unblank() while turning screen on");
-            s->unblank();
+            s->unblank(display);
         }
     } else {
+        const sp<IBinder>& display = s->getBuiltInDisplay(0);   // TODO: support multiple displays
         {
             ALOGD_IF_SLOW(100, "Excessive delay in blank() while turning screen off");
-            s->blank();
+            s->blank(display);
         }
 
         if (gPowerModule) {