Bug 1201081 - UnsupportedOperationException crash at Canvas.clipPath. r=sebastian, a=sylvestre
authorChenxia Liu <liuche@mozilla.com>
Tue, 20 Oct 2015 12:46:58 -0700
changeset 291293 45403faf67cf
parent 291292 cda83cc1aae0
child 291294 13d1f4216f93
push id934
push userraliiev@mozilla.com
push date2015-10-26 12:58 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, sylvestre
bugs1201081
milestone42.0
Bug 1201081 - UnsupportedOperationException crash at Canvas.clipPath. r=sebastian, a=sylvestre
mobile/android/base/widget/RoundedCornerLayout.java
--- a/mobile/android/base/widget/RoundedCornerLayout.java
+++ b/mobile/android/base/widget/RoundedCornerLayout.java
@@ -1,31 +1,33 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.widget;
 
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.R;
 
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Path;
 import android.graphics.RectF;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
 import android.widget.LinearLayout;
 
 public class RoundedCornerLayout extends LinearLayout {
     private static final String LOGTAG = "Gecko" + RoundedCornerLayout.class.getSimpleName();
     private float cornerRadius;
 
     private Path path;
+    boolean cannotClipPath;
 
     public RoundedCornerLayout(Context context) {
         super(context);
         init(context);
     }
 
     public RoundedCornerLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -33,16 +35,19 @@ public class RoundedCornerLayout extends
     }
 
     public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         init(context);
     }
 
     private void init(Context context) {
+        // Bug 1201081 - clipPath with hardware acceleration crashes on r11-18.
+        cannotClipPath = AppConstants.Versions.feature11Plus && !AppConstants.Versions.feature19Plus;
+
         final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
 
         cornerRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
                 getResources().getDimensionPixelSize(R.dimen.doorhanger_rounded_corner_radius), metrics);
 
         setWillNotDraw(false);
     }
 
@@ -52,14 +57,19 @@ public class RoundedCornerLayout extends
         final RectF r = new RectF(0, 0, w, h);
         path = new Path();
         path.addRoundRect(r, cornerRadius, cornerRadius, Path.Direction.CW);
         path.close();
     }
 
     @Override
     public void draw(Canvas canvas) {
+        if (cannotClipPath) {
+            super.draw(canvas);
+            return;
+        }
+
         canvas.save();
         canvas.clipPath(path);
         super.draw(canvas);
         canvas.restore();
     }
 }