summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/Bitmap.java8
-rw-r--r--graphics/java/android/graphics/Color.java47
-rw-r--r--graphics/java/android/graphics/Paint.java2
-rw-r--r--graphics/java/android/graphics/SurfaceTexture.java5
-rw-r--r--graphics/java/android/graphics/drawable/BitmapDrawable.java48
-rw-r--r--graphics/java/android/graphics/drawable/Drawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/DrawableContainer.java4
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java30
-rw-r--r--graphics/java/android/renderscript/Allocation.java18
-rw-r--r--graphics/java/android/renderscript/ScriptIntrinsicBlur.java2
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp10
11 files changed, 139 insertions, 37 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 688fd7a..89abdef 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -82,6 +82,7 @@ public final class Bitmap implements Parcelable {
if (sDefaultDensity >= 0) {
return sDefaultDensity;
}
+ //noinspection deprecation
sDefaultDensity = DisplayMetrics.DENSITY_DEVICE;
return sDefaultDensity;
}
@@ -360,6 +361,9 @@ public final class Bitmap implements Parcelable {
* that if this bitmap stores its pixels pre-multiplied
* (see {@link #isPremultiplied()}, the values in the buffer will also be
* pre-multiplied.</p>
+ * <p>After this method returns, the current position of the buffer is
+ * updated: the position is incremented by the number of elements written
+ * in the buffer.</p>
*/
public void copyPixelsToBuffer(Buffer dst) {
int elements = dst.remaining();
@@ -394,6 +398,10 @@ public final class Bitmap implements Parcelable {
* overwriting the bitmap's pixels. The data in the buffer is not changed
* in any way (unlike setPixels(), which converts from unpremultipled 32bit
* to whatever the bitmap's native format is.</p>
+ * <p>After this method returns, the current position of the buffer is
+ * updated: the position is incremented by the number of elements read from
+ * the buffer. If you need to read the bitmap from the buffer again you must
+ * first rewind the buffer.</p>
*/
public void copyPixelsFromBuffer(Buffer src) {
checkRecycled("copyPixelsFromBuffer called on recycled bitmap");
diff --git a/graphics/java/android/graphics/Color.java b/graphics/java/android/graphics/Color.java
index a50693d..6a4e89a 100644
--- a/graphics/java/android/graphics/Color.java
+++ b/graphics/java/android/graphics/Color.java
@@ -17,6 +17,7 @@
package android.graphics;
import android.util.MathUtils;
+import com.android.internal.util.XmlUtils;
import java.util.HashMap;
import java.util.Locale;
@@ -178,9 +179,9 @@ public class Color {
/**
* Returns the brightness component of a color int.
- *
+ *
* @return A value between 0.0f and 1.0f
- *
+ *
* @hide Pending API council
*/
public static float brightness(int color) {
@@ -200,7 +201,9 @@ public class Color {
* #RRGGBB
* #AARRGGBB
* 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta',
- * 'yellow', 'lightgray', 'darkgray'
+ * 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey',
+ * 'aqua', 'fuschia', 'lime', 'maroon', 'navy', 'olive', 'purple',
+ * 'silver', 'teal'
*/
public static int parseColor(String colorString) {
if (colorString.charAt(0) == '#') {
@@ -363,9 +366,31 @@ public class Color {
return nativeHSVToColor(alpha, hsv);
}
- private static native void nativeRGBToHSV(int red, int greed, int blue, float hsv[]);
+ private static native void nativeRGBToHSV(int red, int greed, int blue, float hsv[]);
private static native int nativeHSVToColor(int alpha, float hsv[]);
+ /**
+ * Converts an HTML color (named or numeric) to an integer RGB value.
+ *
+ * @param color Non-null color string.
+ *
+ * @return A color value, or {@code -1} if the color string could not be interpreted.
+ *
+ * @hide
+ */
+ public static int getHtmlColor(String color) {
+ Integer i = sColorNameMap.get(color.toLowerCase());
+ if (i != null) {
+ return i;
+ } else {
+ try {
+ return XmlUtils.convertValueToInt(color, -1);
+ } catch (NumberFormatException nfe) {
+ return -1;
+ }
+ }
+ }
+
private static final HashMap<String, Integer> sColorNameMap;
static {
@@ -381,6 +406,18 @@ public class Color {
sColorNameMap.put("yellow", YELLOW);
sColorNameMap.put("cyan", CYAN);
sColorNameMap.put("magenta", MAGENTA);
+ sColorNameMap.put("aqua", 0x00FFFF);
+ sColorNameMap.put("fuchsia", 0xFF00FF);
+ sColorNameMap.put("darkgrey", DKGRAY);
+ sColorNameMap.put("grey", GRAY);
+ sColorNameMap.put("lightgrey", LTGRAY);
+ sColorNameMap.put("lime", 0x00FF00);
+ sColorNameMap.put("maroon", 0x800000);
+ sColorNameMap.put("navy", 0x000080);
+ sColorNameMap.put("olive", 0x808000);
+ sColorNameMap.put("purple", 0x800080);
+ sColorNameMap.put("silver", 0xC0C0C0);
+ sColorNameMap.put("teal", 0x008080);
+
}
}
-
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 4170cfe..3285e51 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -553,7 +553,6 @@ public class Paint {
*
* @return true if the lineartext bit is set in the paint's flags
*/
- @Deprecated
public final boolean isLinearText() {
return (getFlags() & LINEAR_TEXT_FLAG) != 0;
}
@@ -564,7 +563,6 @@ public class Paint {
* @param linearText true to set the linearText bit in the paint's flags,
* false to clear it.
*/
- @Deprecated
public native void setLinearText(boolean linearText);
/**
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java
index 4beaecd..b919ba4 100644
--- a/graphics/java/android/graphics/SurfaceTexture.java
+++ b/graphics/java/android/graphics/SurfaceTexture.java
@@ -66,9 +66,10 @@ public class SurfaceTexture {
private OnFrameAvailableListener mOnFrameAvailableListener;
/**
- * This field is used by native code, do not access or modify.
+ * These fields are used by native code, do not access or modify.
*/
private int mSurfaceTexture;
+ private int mFrameAvailableListener;
/**
* Callback interface for being notified that a new stream frame is available.
@@ -196,7 +197,7 @@ public class SurfaceTexture {
public void attachToGLContext(int texName) {
int err = nativeAttachToGLContext(texName);
if (err != 0) {
- throw new RuntimeException("Error during detachFromGLContext (see logcat for details)");
+ throw new RuntimeException("Error during attachToGLContext (see logcat for details)");
}
}
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index e82ccd4..6e41d34 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -243,7 +243,7 @@ public class BitmapDrawable extends Drawable {
public int getGravity() {
return mBitmapState.mGravity;
}
-
+
/** Set the gravity used to position/stretch the bitmap within its bounds.
See android.view.Gravity
* @param gravity the gravity
@@ -257,16 +257,58 @@ public class BitmapDrawable extends Drawable {
}
/**
+ * Enables or disables the mipmap hint for this drawable's bitmap.
+ * See {@link Bitmap#setHasMipMap(boolean)} for more information.
+ *
+ * If the bitmap is null calling this method has no effect.
+ *
+ * @param mipMap True if the bitmap should use mipmaps, false otherwise.
+ *
+ * @see #hasMipMap()
+ */
+ public void setMipMap(boolean mipMap) {
+ if (mBitmapState.mBitmap != null) {
+ mBitmapState.mBitmap.setHasMipMap(mipMap);
+ invalidateSelf();
+ }
+ }
+
+ /**
+ * Indicates whether the mipmap hint is enabled on this drawable's bitmap.
+ *
+ * @return True if the mipmap hint is set, false otherwise. If the bitmap
+ * is null, this method always returns false.
+ *
+ * @see #setMipMap(boolean)
+ */
+ public boolean hasMipMap() {
+ return mBitmapState.mBitmap != null && mBitmapState.mBitmap.hasMipMap();
+ }
+
+ /**
* Enables or disables anti-aliasing for this drawable. Anti-aliasing affects
* the edges of the bitmap only so it applies only when the drawable is rotated.
*
* @param aa True if the bitmap should be anti-aliased, false otherwise.
+ *
+ * @see #hasAntiAlias()
*/
public void setAntiAlias(boolean aa) {
mBitmapState.mPaint.setAntiAlias(aa);
invalidateSelf();
}
-
+
+ /**
+ * Indicates whether anti-aliasing is enabled for this drawable.
+ *
+ * @return True if anti-aliasing is enabled, false otherwise.
+ *
+ * @see #setAntiAlias(boolean)
+ */
+ public boolean hasAntiAlias() {
+ return mBitmapState.mPaint.isAntiAlias();
+ }
+
@Override
public void setFilterBitmap(boolean filter) {
mBitmapState.mPaint.setFilterBitmap(filter);
@@ -451,6 +493,8 @@ public class BitmapDrawable extends Drawable {
mBitmapState.mBitmap = bitmap;
setBitmap(bitmap);
setTargetDensity(r.getDisplayMetrics());
+ setMipMap(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_mipMap,
+ bitmap.hasMipMap()));
final Paint paint = mBitmapState.mPaint;
paint.setAntiAlias(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_antialias,
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index f9392e4..54d1bf5 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -715,7 +715,7 @@ public abstract class Drawable {
*
* @hide
*/
- public Insets getLayoutInsets() {
+ public Insets getOpticalInsets() {
return Insets.NONE;
}
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index 8280d2d..a0c9701 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -95,8 +95,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
* @hide
*/
@Override
- public Insets getLayoutInsets() {
- return (mCurrDrawable == null) ? Insets.NONE : mCurrDrawable.getLayoutInsets();
+ public Insets getOpticalInsets() {
+ return (mCurrDrawable == null) ? Insets.NONE : mCurrDrawable.getOpticalInsets();
}
@Override
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index 2ee6233..a9dc22b 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -56,7 +56,7 @@ public class NinePatchDrawable extends Drawable {
private NinePatchState mNinePatchState;
private NinePatch mNinePatch;
private Rect mPadding;
- private Insets mLayoutInsets = Insets.NONE;
+ private Insets mOpticalInsets = Insets.NONE;
private Paint mPaint;
private boolean mMutated;
@@ -96,8 +96,8 @@ public class NinePatchDrawable extends Drawable {
* @hide
*/
public NinePatchDrawable(Resources res, Bitmap bitmap, byte[] chunk,
- Rect padding, Rect layoutInsets, String srcName) {
- this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding, layoutInsets), res);
+ Rect padding, Rect opticalInsets, String srcName) {
+ this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding, opticalInsets), res);
mNinePatchState.mTargetDensity = mTargetDensity;
}
@@ -195,7 +195,7 @@ public class NinePatchDrawable extends Drawable {
if (sdensity == tdensity) {
mBitmapWidth = mNinePatch.getWidth();
mBitmapHeight = mNinePatch.getHeight();
- mLayoutInsets = mNinePatchState.mLayoutInsets;
+ mOpticalInsets = mNinePatchState.mOpticalInsets;
} else {
mBitmapWidth = Bitmap.scaleFromDensity(mNinePatch.getWidth(),
sdensity, tdensity);
@@ -212,7 +212,7 @@ public class NinePatchDrawable extends Drawable {
dest.right = Bitmap.scaleFromDensity(src.right, sdensity, tdensity);
dest.bottom = Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity);
}
- mLayoutInsets = scaleFromDensity(mNinePatchState.mLayoutInsets, sdensity, tdensity);
+ mOpticalInsets = scaleFromDensity(mNinePatchState.mOpticalInsets, sdensity, tdensity);
}
}
@@ -236,8 +236,8 @@ public class NinePatchDrawable extends Drawable {
* @hide
*/
@Override
- public Insets getLayoutInsets() {
- return mLayoutInsets;
+ public Insets getOpticalInsets() {
+ return mOpticalInsets;
}
@Override
@@ -299,7 +299,7 @@ public class NinePatchDrawable extends Drawable {
options.inScreenDensity = r.getDisplayMetrics().noncompatDensityDpi;
final Rect padding = new Rect();
- final Rect layoutInsets = new Rect();
+ final Rect opticalInsets = new Rect();
Bitmap bitmap = null;
try {
@@ -323,7 +323,7 @@ public class NinePatchDrawable extends Drawable {
setNinePatchState(new NinePatchState(
new NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"),
- padding, layoutInsets, dither), r);
+ padding, opticalInsets, dither), r);
mNinePatchState.mTargetDensity = mTargetDensity;
a.recycle();
@@ -397,7 +397,7 @@ public class NinePatchDrawable extends Drawable {
private final static class NinePatchState extends ConstantState {
final NinePatch mNinePatch;
final Rect mPadding;
- final Insets mLayoutInsets;
+ final Insets mOpticalInsets;
final boolean mDither;
int mChangingConfigurations;
int mTargetDensity = DisplayMetrics.DENSITY_DEFAULT;
@@ -406,14 +406,14 @@ public class NinePatchDrawable extends Drawable {
this(ninePatch, padding, new Rect(), DEFAULT_DITHER);
}
- NinePatchState(NinePatch ninePatch, Rect padding, Rect layoutInsets) {
- this(ninePatch, padding, layoutInsets, DEFAULT_DITHER);
+ NinePatchState(NinePatch ninePatch, Rect padding, Rect opticalInsets) {
+ this(ninePatch, padding, opticalInsets, DEFAULT_DITHER);
}
- NinePatchState(NinePatch ninePatch, Rect rect, Rect layoutInsets, boolean dither) {
+ NinePatchState(NinePatch ninePatch, Rect rect, Rect opticalInsets, boolean dither) {
mNinePatch = ninePatch;
mPadding = rect;
- mLayoutInsets = Insets.of(layoutInsets);
+ mOpticalInsets = Insets.of(opticalInsets);
mDither = dither;
}
@@ -423,7 +423,7 @@ public class NinePatchDrawable extends Drawable {
mNinePatch = new NinePatch(state.mNinePatch);
// Note we don't copy the padding because it is immutable.
mPadding = state.mPadding;
- mLayoutInsets = state.mLayoutInsets;
+ mOpticalInsets = state.mOpticalInsets;
mDither = state.mDither;
mChangingConfigurations = state.mChangingConfigurations;
mTargetDensity = state.mTargetDensity;
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 10ccb87..e44a3ef 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -568,6 +568,21 @@ public class Allocation extends BaseObj {
}
/**
+ * Copy an allocation from an allocation. The types of both allocations
+ * must be identical.
+ *
+ * @param a the source allocation
+ */
+ public void copyFrom(Allocation a) {
+ mRS.validate();
+ if (!mType.equals(a.getType())) {
+ throw new RSIllegalArgumentException("Types of allocations must match.");
+ }
+ copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, a, 0, 0);
+ }
+
+
+ /**
* This is only intended to be used by auto-generate code reflected from the
* renderscript script files.
*
@@ -971,11 +986,10 @@ public class Allocation extends BaseObj {
*
* A new type will be created with the new dimension.
*
- * @hide
* @param dimX The new size of the allocation.
* @param dimY The new size of the allocation.
*/
- public void resize(int dimX, int dimY) {
+ public synchronized void resize(int dimX, int dimY) {
if ((mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
throw new RSInvalidStateException(
"Resize only support for 2D allocations at this time.");
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java b/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
index 11164e3..7ffd1e7 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
@@ -46,7 +46,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic {
* @return ScriptIntrinsicBlur
*/
public static ScriptIntrinsicBlur create(RenderScript rs, Element e) {
- if (e != Element.U8_4(rs)) {
+ if ((e != Element.U8_4(rs)) && e != (Element.U8(rs))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
int id = rs.nScriptIntrinsicCreate(5, e.getID(rs));
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 3f642e8..eddd3c0 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -567,7 +567,7 @@ nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc
const void* ptr = bitmap.getPixels();
rsAllocation2DData(con, (RsAllocation)alloc, 0, 0,
0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- w, h, ptr, bitmap.getSize());
+ w, h, ptr, bitmap.getSize(), 0);
bitmap.unlockPixels();
}
@@ -650,7 +650,7 @@ nAllocationData2D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_s, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jshort *ptr = _env->GetShortArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
}
@@ -661,7 +661,7 @@ nAllocationData2D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_b, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
}
@@ -672,7 +672,7 @@ nAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
}
@@ -683,7 +683,7 @@ nAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
}