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

Commit 2c35b46e authored by Chris Craik's avatar Chris Craik Committed by Android Git Automerger
Browse files

am 264ace0b: Merge "Add outline alpha" into lmp-dev

* commit '264ace0be65505e0dc56928cb9eff5411814646e':
  Add outline alpha
parents 9623f888 8e554924
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -355,9 +355,10 @@ public class RenderNode {
            return nSetOutlineEmpty(mNativeRenderNode);
        } else if (outline.mRect != null) {
            return nSetOutlineRoundRect(mNativeRenderNode, outline.mRect.left, outline.mRect.top,
                    outline.mRect.right, outline.mRect.bottom, outline.mRadius);
                    outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha);
        } else if (outline.mPath != null) {
            return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath);
            return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath,
                    outline.mAlpha);
        }
        throw new IllegalArgumentException("Unrecognized outline?");
    }
@@ -849,8 +850,9 @@ public class RenderNode {
    private static native boolean nSetProjectBackwards(long renderNode, boolean shouldProject);
    private static native boolean nSetProjectionReceiver(long renderNode, boolean shouldRecieve);
    private static native boolean nSetOutlineRoundRect(long renderNode, int left, int top,
            int right, int bottom, float radius);
    private static native boolean nSetOutlineConvexPath(long renderNode, long nativePath);
            int right, int bottom, float radius, float alpha);
    private static native boolean nSetOutlineConvexPath(long renderNode, long nativePath,
            float alpha);
    private static native boolean nSetOutlineEmpty(long renderNode);
    private static native boolean nSetOutlineNone(long renderNode);
    private static native boolean nSetClipToOutline(long renderNode, boolean clipToOutline);
+6 −1
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ import android.graphics.drawable.Drawable;
public abstract class ViewOutlineProvider {
    /**
     * Default outline provider for Views, which queries the Outline from the View's background,
     * or returns <code>false</code> if the View does not have a background.
     * or generates a 0 alpha, rectangular Outline the size of the View if a background
     * isn't present.
     *
     * @see Drawable#getOutline(Outline)
     */
@@ -35,6 +36,10 @@ public abstract class ViewOutlineProvider {
            Drawable background = view.getBackground();
            if (background != null) {
                background.getOutline(outline);
            } else {

                outline.setRect(0, 0, view.getWidth(), view.getHeight());
                outline.setAlpha(0.0f);
            }
        }
    };
+25 −5
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@

package com.android.internal.widget;

import android.annotation.NonNull;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
@@ -324,17 +326,35 @@ public class ActionBarContainer extends FrameLayout {
     * projection surfaces.
     */
    private class ActionBarBackgroundDrawable extends Drawable {
        @Override
        public void draw(Canvas canvas) {
        private Drawable getDrawable() {
            if (mIsSplit) {
                if (mSplitBackground != null) mSplitBackground.draw(canvas);
                if (mSplitBackground != null) {
                    return mSplitBackground;
                }
            } else {
                if (mBackground != null) {
                    mBackground.draw(canvas);
                    return mBackground;
                }
                if (mStackedBackground != null && mIsStacked) {
                    mStackedBackground.draw(canvas);
                    return mStackedBackground;
                }
            }
            return null;
        }

        @Override
        public void draw(Canvas canvas) {
            final Drawable drawable = getDrawable();
            if (drawable != null) {
                drawable.draw(canvas);
            }
        }

        @Override
        public void getOutline(@NonNull Outline outline) {
            final Drawable drawable = getDrawable();
            if (drawable != null) {
                drawable.getOutline(outline);
            }
        }

+2 −2
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
        ninePatchInsets = env->NewObject(gInsetStruct_class, gInsetStruct_constructorMethodID,
                peeker.mOpticalInsets[0], peeker.mOpticalInsets[1], peeker.mOpticalInsets[2], peeker.mOpticalInsets[3],
                peeker.mOutlineInsets[0], peeker.mOutlineInsets[1], peeker.mOutlineInsets[2], peeker.mOutlineInsets[3],
                peeker.mOutlineRadius, peeker.mOutlineFilled, scale);
                peeker.mOutlineRadius, peeker.mOutlineAlpha, scale);
        if (javaBitmap != NULL) {
            env->SetObjectField(javaBitmap, gBitmap_ninePatchInsetsFieldID, ninePatchInsets);
        }
@@ -589,7 +589,7 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) {
            "Landroid/graphics/NinePatch$InsetStruct;");

    gInsetStruct_class = (jclass) env->NewGlobalRef(env->FindClass("android/graphics/NinePatch$InsetStruct"));
    gInsetStruct_constructorMethodID = env->GetMethodID(gInsetStruct_class, "<init>", "(IIIIIIIIFZF)V");
    gInsetStruct_constructorMethodID = env->GetMethodID(gInsetStruct_class, "<init>", "(IIIIIIIIFIF)V");

    int ret = AndroidRuntime::registerNativeMethods(env,
                                    "android/graphics/BitmapFactory$Options",
+2 −2
Original line number Diff line number Diff line
@@ -48,11 +48,11 @@ bool NinePatchPeeker::peek(const char tag[], const void* data, size_t length) {
    } else if (!strcmp("npLb", tag) && length == sizeof(int32_t) * 4) {
        mHasInsets = true;
        memcpy(&mOpticalInsets, data, sizeof(int32_t) * 4);
    } else if (!strcmp("npOl", tag) && length == 24) { // 4 int32_ts, 1 float, 1 int32_t sized bool
    } else if (!strcmp("npOl", tag) && length == 24) { // 4 int32_ts, 1 float, 1 int32_t sized byte
        mHasInsets = true;
        memcpy(&mOutlineInsets, data, sizeof(int32_t) * 4);
        mOutlineRadius = ((const float*)data)[4];
        mOutlineFilled = ((const int32_t*)data)[5] & 0x01;
        mOutlineAlpha = ((const int32_t*)data)[5] & 0xff;
    }
    return true;    // keep on decoding
}
Loading