From 4e03999ca20fd326e4ded3d7444ddd5c14f369c7 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Tue, 29 Sep 2009 17:02:26 -0400 Subject: if we have a single value for roundrect radius, manually clamp it before drawing. Skia will clamp the radius independently in X and Y to ensure it is not larger than 1/2 the width (or height). If the caller to our drawable gives us a single value, we'll assume they want it to be circular, and not an oval. To do that, we clamp it up front, so we get (possibly smaller) circular corners, rather than potentially elliptical ones. This makes the progress bar look "nicer" when it is very thin in one dimension. --- graphics/java/android/graphics/drawable/GradientDrawable.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'graphics/java') diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index ddbbaf1..91a2bc1 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -319,7 +319,16 @@ public class GradientDrawable extends Drawable { } } else { + // since the caller is only giving us 1 value, we will force + // it to be square if the rect is too small in one dimension + // to show it. If we did nothing, Skia would clamp the rad + // independently along each axis, giving us a thin ellips + // if the rect were very wide but not very tall float rad = st.mRadius; + float r = Math.min(mRect.width(), mRect.height()) * 0.5f; + if (rad > r) { + rad = r; + } canvas.drawRoundRect(mRect, rad, rad, mFillPaint); if (haveStroke) { canvas.drawRoundRect(mRect, rad, rad, mStrokePaint); -- cgit v1.1