summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-07-07 15:29:12 -0700
committerAlan Viverette <alanv@google.com>2014-07-07 15:29:12 -0700
commit7c0517272ba2d97084739a14fea78641b265eb5d (patch)
treeeba43146da033a822285a9b9be6730e12a4d6b08 /graphics
parent5e458dd6b4b92c369865e59c81a02c8ce8c342f6 (diff)
downloadframeworks_base-7c0517272ba2d97084739a14fea78641b265eb5d.zip
frameworks_base-7c0517272ba2d97084739a14fea78641b265eb5d.tar.gz
frameworks_base-7c0517272ba2d97084739a14fea78641b265eb5d.tar.bz2
Fix getOutline() in ripple and layer drawables
BUG: 16134862 Change-Id: Ibcef20fc154ecc342344770f96fbd3d77d6fad26
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/LayerDrawable.java19
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java24
2 files changed, 38 insertions, 5 deletions
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index 2f22392..8ebb6f2 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -566,13 +566,24 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
}
/**
- * Builds an Outline from the first child Drawable, if present.
+ * Populates <code>outline</code> with the first available layer outline.
+ * Returns <code>true</code> if an outline is available, <code>false</code>
+ * otherwise.
+ *
+ * @param outline Outline in which to place the first available layer outline
+ * @return <code>true</code> if an outline is available
*/
@Override
public boolean getOutline(@NonNull Outline outline) {
- if (mLayerState.mNum < 1) return false;
- final Drawable firstChild = mLayerState.mChildren[0].mDrawable;
- return firstChild.getOutline(outline);
+ final LayerState state = mLayerState;
+ final ChildDrawable[] children = state.mChildren;
+ final int N = state.mNum;
+ for (int i = 0; i < N; i++) {
+ if (children[i].mDrawable.getOutline(outline)) {
+ return true;
+ }
+ }
+ return false;
}
@Override
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index be8df59..dfe14f2 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -25,6 +25,7 @@ import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
+import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff.Mode;
@@ -497,8 +498,29 @@ public class RippleDrawable extends LayerDrawable {
}
}
+ /**
+ * Populates <code>outline</code> with the first available layer outline,
+ * excluding the mask layer. Returns <code>true</code> if an outline is
+ * available, <code>false</code> otherwise.
+ *
+ * @param outline Outline in which to place the first available layer outline
+ * @return <code>true</code> if an outline is available
+ */
+ @Override
+ public boolean getOutline(@NonNull Outline outline) {
+ final LayerState state = mLayerState;
+ final ChildDrawable[] children = state.mChildren;
+ final int N = state.mNum;
+ for (int i = 0; i < N; i++) {
+ if (children[i].mId != R.id.mask && children[i].mDrawable.getOutline(outline)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
- public void draw(Canvas canvas) {
+ public void draw(@NonNull Canvas canvas) {
final boolean isProjected = isProjected();
final boolean hasMask = mMask != null;
final boolean drawNonMaskContent = mLayerState.mNum > (hasMask ? 1 : 0);