diff options
author | Tor Norbye <tnorbye@google.com> | 2015-03-04 10:04:07 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2015-03-07 20:49:19 -0800 |
commit | b3ec733bb830f2d4425825d93f9ed95f284e9145 (patch) | |
tree | 988803742ef2ae17aebdea75567cd24715a18ac5 /graphics | |
parent | 1c2bf03d1082fc6b7eb42cbd163c60c07cf2bccc (diff) | |
download | frameworks_base-b3ec733bb830f2d4425825d93f9ed95f284e9145.zip frameworks_base-b3ec733bb830f2d4425825d93f9ed95f284e9145.tar.gz frameworks_base-b3ec733bb830f2d4425825d93f9ed95f284e9145.tar.bz2 |
Annotate methods with size and range annotations
Change-Id: I666861f0dfae31402b1280e9a966a583b88e2e1a
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/Canvas.java | 16 | ||||
-rw-r--r-- | graphics/java/android/graphics/Color.java | 13 | ||||
-rw-r--r-- | graphics/java/android/graphics/Outline.java | 3 |
3 files changed, 19 insertions, 13 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 55b7277..150f195 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -20,6 +20,7 @@ import android.annotation.ColorInt; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.Size; import android.text.GraphicsOperations; import android.text.SpannableString; import android.text.SpannedString; @@ -1055,14 +1056,15 @@ public class Canvas { * "points" that are drawn is really (count >> 1). * @param paint The paint used to draw the points */ - public void drawPoints(float[] pts, int offset, int count, @NonNull Paint paint) { + public void drawPoints(@Size(multiple=2) float[] pts, int offset, int count, + @NonNull Paint paint) { native_drawPoints(mNativeCanvasWrapper, pts, offset, count, paint.getNativeInstance()); } /** * Helper for drawPoints() that assumes you want to draw the entire array */ - public void drawPoints(@NonNull float[] pts, @NonNull Paint paint) { + public void drawPoints(@Size(multiple=2) @NonNull float[] pts, @NonNull Paint paint) { drawPoints(pts, 0, pts.length, paint); } @@ -1105,11 +1107,11 @@ public class Canvas { * (count >> 2). * @param paint The paint used to draw the points */ - public void drawLines(float[] pts, int offset, int count, Paint paint) { + public void drawLines(@Size(min=4,multiple=2) float[] pts, int offset, int count, Paint paint) { native_drawLines(mNativeCanvasWrapper, pts, offset, count, paint.getNativeInstance()); } - public void drawLines(@NonNull float[] pts, @NonNull Paint paint) { + public void drawLines(@Size(min=4,multiple=2) @NonNull float[] pts, @NonNull Paint paint) { drawLines(pts, 0, pts.length, paint); } @@ -1829,7 +1831,8 @@ public class Canvas { * @param paint The paint used for the text (e.g. color, size, style) */ @Deprecated - public void drawPosText(@NonNull char[] text, int index, int count, @NonNull float[] pos, + public void drawPosText(@NonNull char[] text, int index, int count, + @NonNull @Size(multiple=2) float[] pos, @NonNull Paint paint) { if (index < 0 || index + count > text.length || count*2 > pos.length) { throw new IndexOutOfBoundsException(); @@ -1852,7 +1855,8 @@ public class Canvas { * @param paint The paint used for the text (e.g. color, size, style) */ @Deprecated - public void drawPosText(@NonNull String text, @NonNull float[] pos, @NonNull Paint paint) { + public void drawPosText(@NonNull String text, @NonNull @Size(multiple=2) float[] pos, + @NonNull Paint paint) { drawPosText(text.toCharArray(), 0, text.length(), pos, paint); } diff --git a/graphics/java/android/graphics/Color.java b/graphics/java/android/graphics/Color.java index df0ebee..666dbd8 100644 --- a/graphics/java/android/graphics/Color.java +++ b/graphics/java/android/graphics/Color.java @@ -17,6 +17,7 @@ package android.graphics; import android.annotation.ColorInt; +import android.annotation.Size; import android.util.MathUtils; import com.android.internal.util.XmlUtils; @@ -214,7 +215,7 @@ public class Color { * 'silver', 'teal'. */ @ColorInt - public static int parseColor(String colorString) { + public static int parseColor(@Size(min=1) String colorString) { if (colorString.charAt(0) == '#') { // Use a long to avoid rollovers on #ffXXXXXX long color = Long.parseLong(colorString.substring(1), 16); @@ -246,7 +247,7 @@ public class Color { * @hide Pending API council */ @ColorInt - public static int HSBtoColor(float[] hsb) { + public static int HSBtoColor(@Size(3) float[] hsb) { return HSBtoColor(hsb[0], hsb[1], hsb[2]); } @@ -327,7 +328,7 @@ public class Color { * @param blue blue component value [0..255] * @param hsv 3 element array which holds the resulting HSV components. */ - public static void RGBToHSV(int red, int green, int blue, float hsv[]) { + public static void RGBToHSV(int red, int green, int blue, @Size(3) float hsv[]) { if (hsv.length < 3) { throw new RuntimeException("3 components required for hsv"); } @@ -342,7 +343,7 @@ public class Color { * @param color the argb color to convert. The alpha component is ignored. * @param hsv 3 element array which holds the resulting HSV components. */ - public static void colorToHSV(@ColorInt int color, float hsv[]) { + public static void colorToHSV(@ColorInt int color, @Size(3) float hsv[]) { RGBToHSV((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, hsv); } @@ -355,7 +356,7 @@ public class Color { * @param hsv 3 element array which holds the input HSV components. * @return the resulting argb color */ - public static int HSVToColor(float hsv[]) { + public static int HSVToColor(@Size(3) float hsv[]) { return HSVToColor(0xFF, hsv); } @@ -370,7 +371,7 @@ public class Color { * @param hsv 3 element array which holds the input HSV components. * @return the resulting argb color */ - public static int HSVToColor(int alpha, float hsv[]) { + public static int HSVToColor(int alpha, @Size(3) float hsv[]) { if (hsv.length < 3) { throw new RuntimeException("3 components required for hsv"); } diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java index f76184f..aa40408 100644 --- a/graphics/java/android/graphics/Outline.java +++ b/graphics/java/android/graphics/Outline.java @@ -16,6 +16,7 @@ package android.graphics; +import android.annotation.FloatRange; import android.annotation.NonNull; import android.graphics.drawable.Drawable; @@ -101,7 +102,7 @@ public final class Outline { * assumed by the drawing system to fully cover content beneath it, * meaning content beneath may be optimized away. */ - public void setAlpha(float alpha) { + public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) { mAlpha = alpha; } |