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

Commit 7f3526ec authored by Jorge Betancourt's avatar Jorge Betancourt Committed by Android (Google) Code Review
Browse files

Merge "add child setters to RuntimeEffects" into main

parents 43abf80f 9a3d35e9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -17474,6 +17474,7 @@ package android.graphics {
    method public void setFloatUniform(@NonNull String, @NonNull float[]);
    method public void setInputColorFilter(@NonNull String, @NonNull android.graphics.ColorFilter);
    method public void setInputShader(@NonNull String, @NonNull android.graphics.Shader);
    method public void setInputXfermode(@NonNull String, @NonNull android.graphics.RuntimeXfermode);
    method public void setIntUniform(@NonNull String, int);
    method public void setIntUniform(@NonNull String, int, int);
    method public void setIntUniform(@NonNull String, int, int, int);
@@ -17492,7 +17493,9 @@ package android.graphics {
    method public void setFloatUniform(@NonNull String, float, float, float, float);
    method public void setFloatUniform(@NonNull String, @NonNull float[]);
    method public void setInputBuffer(@NonNull String, @NonNull android.graphics.BitmapShader);
    method @FlaggedApi("com.android.graphics.hwui.flags.runtime_color_filters_blenders") public void setInputColorFilter(@NonNull String, @NonNull android.graphics.ColorFilter);
    method public void setInputShader(@NonNull String, @NonNull android.graphics.Shader);
    method @FlaggedApi("com.android.graphics.hwui.flags.runtime_color_filters_blenders") public void setInputXfermode(@NonNull String, @NonNull android.graphics.RuntimeXfermode);
    method public void setIntUniform(@NonNull String, int);
    method public void setIntUniform(@NonNull String, int, int);
    method public void setIntUniform(@NonNull String, int, int, int);
@@ -17512,6 +17515,7 @@ package android.graphics {
    method public void setFloatUniform(@NonNull String, @NonNull float[]);
    method public void setInputColorFilter(@NonNull String, @NonNull android.graphics.ColorFilter);
    method public void setInputShader(@NonNull String, @NonNull android.graphics.Shader);
    method public void setInputXfermode(@NonNull String, @NonNull android.graphics.RuntimeXfermode);
    method public void setIntUniform(@NonNull String, int);
    method public void setIntUniform(@NonNull String, int, int);
    method public void setIntUniform(@NonNull String, int, int, int);
+17 −0
Original line number Diff line number Diff line
@@ -283,6 +283,23 @@ public class RuntimeColorFilter extends ColorFilter {
        nativeUpdateChild(getNativeInstance(), filterName, colorFilter.getNativeInstance());
    }

    /**
     * Assigns the uniform xfermode to the provided xfermode parameter.  If the shader program does
     * not have a uniform xfermode with that name then an IllegalArgumentException is thrown.
     *
     * @param xfermodeName name matching the uniform declared in the AGSL program
     * @param xfermode filter passed into the AGSL program for sampling
     */
    public void setInputXfermode(@NonNull String xfermodeName, @NonNull RuntimeXfermode xfermode) {
        if (xfermodeName == null) {
            throw new NullPointerException("The xfermodeName parameter must not be null");
        }
        if (xfermode == null) {
            throw new NullPointerException("The xfermode parameter must not be null");
        }
        nativeUpdateChild(getNativeInstance(), xfermodeName, xfermode.createNativeInstance());
    }

    /** @hide */
    @Override
    protected long createNativeInstance() {
+44 −0
Original line number Diff line number Diff line
@@ -18,10 +18,13 @@ package android.graphics;

import android.annotation.ColorInt;
import android.annotation.ColorLong;
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.util.ArrayMap;
import android.view.Window;

import com.android.graphics.hwui.flags.Flags;

import libcore.util.NativeAllocationRegistry;

/**
@@ -525,6 +528,45 @@ public class RuntimeShader extends Shader {
        discardNativeInstance();
    }

    /**
     * Assigns the uniform color filter to the provided color filter parameter.  If the shader
     * program does not have a uniform color filter with that name then an IllegalArgumentException
     * is thrown.
     *
     * @param filterName name matching the uniform declared in the AGSL program
     * @param colorFilter filter passed into the AGSL program for sampling
     */
    @FlaggedApi(Flags.FLAG_RUNTIME_COLOR_FILTERS_BLENDERS)
    public void setInputColorFilter(@NonNull String filterName, @NonNull ColorFilter colorFilter) {
        if (filterName == null) {
            throw new NullPointerException("The filterName parameter must not be null");
        }
        if (colorFilter == null) {
            throw new NullPointerException("The colorFilter parameter must not be null");
        }
        nativeUpdateChild(mNativeInstanceRuntimeShaderBuilder, filterName,
                colorFilter.getNativeInstance());
    }

    /**
     * Assigns the uniform xfermode to the provided xfermode parameter.  If the shader program does
     * not have a uniform xfermode with that name then an IllegalArgumentException is thrown.
     *
     * @param xfermodeName name matching the uniform declared in the AGSL program
     * @param xfermode filter passed into the AGSL program for sampling
     */
    @FlaggedApi(Flags.FLAG_RUNTIME_COLOR_FILTERS_BLENDERS)
    public void setInputXfermode(@NonNull String xfermodeName, @NonNull RuntimeXfermode xfermode) {
        if (xfermodeName == null) {
            throw new NullPointerException("The xfermodeName parameter must not be null");
        }
        if (xfermode == null) {
            throw new NullPointerException("The xfermode parameter must not be null");
        }
        nativeUpdateChild(mNativeInstanceRuntimeShaderBuilder, xfermodeName,
                xfermode.createNativeInstance());
    }


    /** @hide */
    @Override
@@ -552,5 +594,7 @@ public class RuntimeShader extends Shader {
            int value4, int count);
    private static native void nativeUpdateShader(
            long shaderBuilder, String shaderName, long shader);
    private static native void nativeUpdateChild(
            long shaderBuilder, String childName, long child);
}
+17 −0
Original line number Diff line number Diff line
@@ -288,6 +288,23 @@ public class RuntimeXfermode extends Xfermode {
        nativeUpdateChild(mBuilderNativeInstance, filterName, colorFilter.getNativeInstance());
    }

    /**
     * Assigns the uniform xfermode to the provided xfermode parameter.  If the shader program does
     * not have a uniform xfermode with that name then an IllegalArgumentException is thrown.
     *
     * @param xfermodeName name matching the uniform declared in the AGSL program
     * @param xfermode xfermode function passed into the AGSL program for sampling
     */
    public void setInputXfermode(@NonNull String xfermodeName, @NonNull RuntimeXfermode xfermode) {
        if (xfermodeName == null) {
            throw new NullPointerException("The xfermodeName parameter must not be null");
        }
        if (xfermode == null) {
            throw new NullPointerException("The xfermode parameter must not be null");
        }
        nativeUpdateChild(mBuilderNativeInstance, xfermodeName, xfermode.createNativeInstance());
    }

    /** @hide */
    public long createNativeInstance() {
        return nativeCreateNativeInstance(mBuilderNativeInstance);
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ void UpdateChild(JNIEnv* env, SkRuntimeEffectBuilder* builder, const char* child
                 SkFlattenable* childEffect) {
    SkRuntimeShaderBuilder::BuilderChild builderChild = builder->child(childName);
    if (builderChild.fChild == nullptr) {
        ThrowIAEFmt(env, "unable to find shader named %s", childName);
        ThrowIAEFmt(env, "unable to find child named %s", childName);
        return;
    }

Loading