summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/Canvas.java53
-rw-r--r--graphics/java/android/graphics/Path.java4
-rw-r--r--graphics/java/android/graphics/Typeface.java12
3 files changed, 36 insertions, 33 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 483d11a..3949afd 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -37,8 +37,8 @@ import javax.microedition.khronos.opengles.GL;
* Canvas and Drawables</a> developer guide.</p></div>
*/
public class Canvas {
- // assigned in constructors or setBitmap, freed in finalizer
- int mNativeCanvas;
+ // assigned in constructors, freed in finalizer
+ final int mNativeCanvas;
// may be null
private Bitmap mBitmap;
@@ -83,7 +83,7 @@ public class Canvas {
private final CanvasFinalizer mFinalizer;
private static class CanvasFinalizer {
- private int mNativeCanvas;
+ private final int mNativeCanvas;
public CanvasFinalizer(int nativeCanvas) {
mNativeCanvas = nativeCanvas;
@@ -143,17 +143,6 @@ public class Canvas {
}
/**
- * Replace existing canvas while ensuring that the swap has occurred before
- * the previous native canvas is unreferenced.
- */
- private void safeCanvasSwap(int nativeCanvas) {
- final int oldCanvas = mNativeCanvas;
- mNativeCanvas = nativeCanvas;
- mFinalizer.mNativeCanvas = nativeCanvas;
- finalizer(oldCanvas);
- }
-
- /**
* Returns null.
*
* @deprecated This method is not supported and should not be invoked.
@@ -179,11 +168,11 @@ public class Canvas {
}
/**
- * Specify a bitmap for the canvas to draw into. As a side-effect, the
- * canvas' target density is updated to match that of the bitmap while all
- * other state such as the layers, filters, matrix, and clip are reset.
+ * Specify a bitmap for the canvas to draw into. As a side-effect, also
+ * updates the canvas's target density to match that of the bitmap.
*
* @param bitmap Specifies a mutable bitmap for the canvas to draw into.
+ *
* @see #setDensity(int)
* @see #getDensity()
*/
@@ -192,19 +181,17 @@ public class Canvas {
throw new RuntimeException("Can't set a bitmap device on a GL canvas");
}
- if (bitmap == null) {
- safeCanvasSwap(initRaster(0));
- mDensity = Bitmap.DENSITY_NONE;
- } else {
+ int pointer = 0;
+ if (bitmap != null) {
if (!bitmap.isMutable()) {
throw new IllegalStateException();
}
throwIfRecycled(bitmap);
-
- safeCanvasSwap(initRaster(bitmap.ni()));
mDensity = bitmap.mDensity;
+ pointer = bitmap.ni();
}
+ native_setBitmap(mNativeCanvas, pointer);
mBitmap = bitmap;
}
@@ -719,7 +706,7 @@ public class Canvas {
* does not intersect with the canvas' clip
*/
public boolean quickReject(RectF rect, EdgeType type) {
- return native_quickReject(mNativeCanvas, rect);
+ return native_quickReject(mNativeCanvas, rect, type.nativeInt);
}
/**
@@ -739,7 +726,7 @@ public class Canvas {
* does not intersect with the canvas' clip
*/
public boolean quickReject(Path path, EdgeType type) {
- return native_quickReject(mNativeCanvas, path.ni());
+ return native_quickReject(mNativeCanvas, path.ni(), type.nativeInt);
}
/**
@@ -762,9 +749,9 @@ public class Canvas {
* @return true if the rect (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
*/
- public boolean quickReject(float left, float top, float right, float bottom,
- EdgeType type) {
- return native_quickReject(mNativeCanvas, left, top, right, bottom);
+ public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) {
+ return native_quickReject(mNativeCanvas, left, top, right, bottom,
+ type.nativeInt);
}
/**
@@ -1638,6 +1625,7 @@ public class Canvas {
public static native void freeTextLayoutCaches();
private static native int initRaster(int nativeBitmapOrZero);
+ private static native void native_setBitmap(int nativeCanvas, int bitmap);
private static native int native_saveLayer(int nativeCanvas, RectF bounds,
int paint, int layerFlags);
private static native int native_saveLayer(int nativeCanvas, float l,
@@ -1668,12 +1656,15 @@ public class Canvas {
Rect bounds);
private static native void native_getCTM(int canvas, int matrix);
private static native boolean native_quickReject(int nativeCanvas,
- RectF rect);
+ RectF rect,
+ int native_edgeType);
private static native boolean native_quickReject(int nativeCanvas,
- int path);
+ int path,
+ int native_edgeType);
private static native boolean native_quickReject(int nativeCanvas,
float left, float top,
- float right, float bottom);
+ float right, float bottom,
+ int native_edgeType);
private static native void native_drawRGB(int nativeCanvas, int r, int g,
int b);
private static native void native_drawARGB(int nativeCanvas, int a, int r,
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java
index 157c7d1..f6b5ffc 100644
--- a/graphics/java/android/graphics/Path.java
+++ b/graphics/java/android/graphics/Path.java
@@ -375,9 +375,9 @@ public class Path {
*/
public enum Direction {
/** clockwise */
- CW (1), // must match enum in SkPath.h
+ CW (0), // must match enum in SkPath.h
/** counter-clockwise */
- CCW (2); // must match enum in SkPath.h
+ CCW (1); // must match enum in SkPath.h
Direction(int ni) {
nativeInt = ni;
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index c68c9f7..4487a3c 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -225,4 +225,16 @@ public class Typeface {
private static native int nativeGetStyle(int native_instance);
private static native int nativeCreateFromAsset(AssetManager mgr, String path);
private static native int nativeCreateFromFile(String path);
+
+ /**
+ * Set the global gamma coefficients for black and white text. This call is
+ * usually a no-op in shipping products, and only exists for testing during
+ * development.
+ *
+ * @param blackGamma gamma coefficient for black text
+ * @param whiteGamma gamma coefficient for white text
+ *
+ * @hide - this is just for calibrating devices, not for normal apps
+ */
+ public static native void setGammaForText(float blackGamma, float whiteGamma);
}