summaryrefslogtreecommitdiffstats
path: root/graphics/java/android
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-04-17 11:12:17 -0700
committerChris Craik <ccraik@google.com>2014-04-17 14:28:18 -0700
commitc306ad61a791bae34ed83b339f27cb67a1d91b53 (patch)
tree962cae68c0f8bd1c4e05259002a76a3ca0b4d891 /graphics/java/android
parent7085d138b21bbce7c9c989c719b35769267b422e (diff)
downloadframeworks_base-c306ad61a791bae34ed83b339f27cb67a1d91b53.zip
frameworks_base-c306ad61a791bae34ed83b339f27cb67a1d91b53.tar.gz
frameworks_base-c306ad61a791bae34ed83b339f27cb67a1d91b53.tar.bz2
Add convenience methods to encourage usage of ALL_SAVE_FLAG
Change-Id: I7a3bb2b83ca0463282764898e755b5f1a71ac557
Diffstat (limited to 'graphics/java/android')
-rw-r--r--graphics/java/android/graphics/Canvas.java51
1 files changed, 34 insertions, 17 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 1252ee2..f80ce28 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -168,21 +168,10 @@ public class Canvas {
}
/**
- * Gets the native canvas pointer.
- *
- * @return The native pointer.
- *
- * @hide
- */
- public long getNativeCanvas() {
- return mNativeCanvas;
- }
-
- /**
* Returns null.
- *
+ *
* @deprecated This method is not supported and should not be invoked.
- *
+ *
* @hide
*/
@Deprecated
@@ -233,14 +222,14 @@ public class Canvas {
mBitmap = bitmap;
}
-
+
/**
* Set the viewport dimensions if this canvas is GL based. If it is not,
* this method is ignored and no exception is thrown.
*
* @param width The width of the viewport
* @param height The height of the viewport
- *
+ *
* @hide
*/
public void setViewport(int width, int height) {
@@ -389,7 +378,14 @@ public class Canvas {
paint != null ? paint.mNativePaint : 0,
saveFlags);
}
-
+
+ /**
+ * Convenience for saveLayer(bounds, paint, {@link #ALL_SAVE_FLAG})
+ */
+ public int saveLayer(RectF bounds, Paint paint) {
+ return saveLayer(bounds, paint, ALL_SAVE_FLAG);
+ }
+
/**
* Helper version of saveLayer() that takes 4 values rather than a RectF.
*/
@@ -401,6 +397,13 @@ public class Canvas {
}
/**
+ * Convenience for saveLayer(left, top, right, bottom, paint, {@link #ALL_SAVE_FLAG})
+ */
+ public int saveLayer(float left, float top, float right, float bottom, Paint paint) {
+ return saveLayer(left, top, right, bottom, paint, ALL_SAVE_FLAG);
+ }
+
+ /**
* This behaves the same as save(), but in addition it allocates an
* offscreen bitmap. All drawing calls are directed there, and only when
* the balancing call to restore() is made is that offscreen transfered to
@@ -420,7 +423,14 @@ public class Canvas {
alpha = Math.min(255, Math.max(0, alpha));
return native_saveLayerAlpha(mNativeCanvas, bounds, alpha, saveFlags);
}
-
+
+ /**
+ * Convenience for saveLayerAlpha(bounds, alpha, {@link #ALL_SAVE_FLAG})
+ */
+ public int saveLayerAlpha(RectF bounds, int alpha) {
+ return saveLayerAlpha(bounds, alpha, ALL_SAVE_FLAG);
+ }
+
/**
* Helper for saveLayerAlpha() that takes 4 values instead of a RectF.
*/
@@ -431,6 +441,13 @@ public class Canvas {
}
/**
+ * Helper for saveLayerAlpha(left, top, right, bottom, alpha, {@link #ALL_SAVE_FLAG})
+ */
+ public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) {
+ return saveLayerAlpha(left, top, right, bottom, alpha, ALL_SAVE_FLAG);
+ }
+
+ /**
* This call balances a previous call to save(), and is used to remove all
* modifications to the matrix/clip state since the last save call. It is
* an error to call restore() more times than save() was called.