Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64dd5be5 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Ia78b0a2d into eclair

* changes:
  add (hidden) setHasAlpha() to allow clients like the view's cache to hint that a bitmap is opaque.
parents e4b6639d a78b0a2d
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -317,6 +317,11 @@ static jboolean Bitmap_hasAlpha(JNIEnv* env, jobject, SkBitmap* bitmap) {
    return !bitmap->isOpaque();
    return !bitmap->isOpaque();
}
}


static void Bitmap_setHasAlpha(JNIEnv* env, jobject, SkBitmap* bitmap,
                               jboolean hasAlpha) {
    bitmap->setIsOpaque(!hasAlpha);
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////


static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
@@ -546,6 +551,7 @@ static JNINativeMethod gBitmapMethods[] = {
    {   "nativeRowBytes",           "(I)I", (void*)Bitmap_rowBytes },
    {   "nativeRowBytes",           "(I)I", (void*)Bitmap_rowBytes },
    {   "nativeConfig",             "(I)I", (void*)Bitmap_config },
    {   "nativeConfig",             "(I)I", (void*)Bitmap_config },
    {   "nativeHasAlpha",           "(I)Z", (void*)Bitmap_hasAlpha },
    {   "nativeHasAlpha",           "(I)Z", (void*)Bitmap_hasAlpha },
    {   "nativeSetHasAlpha",        "(IZ)V", (void*)Bitmap_setHasAlpha },
    {   "nativeCreateFromParcel",
    {   "nativeCreateFromParcel",
        "(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
        "(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
        (void*)Bitmap_createFromParcel },
        (void*)Bitmap_createFromParcel },
+25 −1
Original line number Original line Diff line number Diff line
@@ -684,11 +684,34 @@ public final class Bitmap implements Parcelable {
        return Config.nativeToConfig(nativeConfig(mNativeBitmap));
        return Config.nativeToConfig(nativeConfig(mNativeBitmap));
    }
    }


    /** Returns true if the bitmap's pixels support levels of alpha */
    /** Returns true if the bitmap's config supports per-pixel alpha, and
     * if the pixels may contain non-opaque alpha values. For some configs,
     * this is always false (e.g. RGB_565), since they do not support per-pixel
     * alpha. However, for configs that do, the bitmap may be flagged to be
     * known that all of its pixels are opaque. In this case hasAlpha() will
     * also return false. If a config such as ARGB_8888 is not so flagged,
     * it will return true by default.
     */
    public final boolean hasAlpha() {
    public final boolean hasAlpha() {
        return nativeHasAlpha(mNativeBitmap);
        return nativeHasAlpha(mNativeBitmap);
    }
    }


    /**
     * Tell the bitmap if all of the pixels are known to be opaque (false)
     * or if some of the pixels may contain non-opaque alpha values (true).
     * Note, for some configs (e.g. RGB_565) this call is ignore, since it does
     * not support per-pixel alpha values.
     *
     * This is meant as a drawing hint, as in some cases a bitmap that is known
     * to be opaque can take a faster drawing case than one that may have
     * non-opaque per-pixel alpha values.
     *
     * @hide
     */
    public void setHasAlpha(boolean hasAlpha) {
        nativeSetHasAlpha(mNativeBitmap, hasAlpha);
    }

    /**
    /**
     * Fills the bitmap's pixels with the specified {@link Color}.
     * Fills the bitmap's pixels with the specified {@link Color}.
     *
     *
@@ -1018,6 +1041,7 @@ public final class Bitmap implements Parcelable {
                                                    int[] offsetXY);
                                                    int[] offsetXY);


    private static native void nativePrepareToDraw(int nativeBitmap);
    private static native void nativePrepareToDraw(int nativeBitmap);
    private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha);


    /* package */ final int ni() {
    /* package */ final int ni() {
        return mNativeBitmap;
        return mNativeBitmap;