diff options
author | 2024-11-14 19:52:27 +0000 | |
---|---|---|
committer | 2024-11-15 04:09:37 +0000 | |
commit | 9a3d35e96bc8964e30cdd493fbe471226087b15a (patch) | |
tree | 0bce4ba7baf0875a581f45751d47969e17fc658d /graphics/java | |
parent | d0e4ee2fc64240bfeb8c4f1024ae3fe0e18fd976 (diff) |
add child setters to RuntimeEffects
Flag: com.android.graphics.hwui.flags.runtime_color_filters_blenders
Test: atest CtsUiRenderingTestCases:RuntimeShaderTests
Bug: b/358126864
API-Coverage-Bug: 379193391
Change-Id: I0e89e3880af12813935acd6ced817abff3f61084
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/graphics/RuntimeColorFilter.java | 17 | ||||
-rw-r--r-- | graphics/java/android/graphics/RuntimeShader.java | 44 | ||||
-rw-r--r-- | graphics/java/android/graphics/RuntimeXfermode.java | 17 |
3 files changed, 78 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/RuntimeColorFilter.java b/graphics/java/android/graphics/RuntimeColorFilter.java index 52724ceaf301..d112f7153fca 100644 --- a/graphics/java/android/graphics/RuntimeColorFilter.java +++ b/graphics/java/android/graphics/RuntimeColorFilter.java @@ -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() { diff --git a/graphics/java/android/graphics/RuntimeShader.java b/graphics/java/android/graphics/RuntimeShader.java index 78d257f86613..6316c1fb8b47 100644 --- a/graphics/java/android/graphics/RuntimeShader.java +++ b/graphics/java/android/graphics/RuntimeShader.java @@ -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); } diff --git a/graphics/java/android/graphics/RuntimeXfermode.java b/graphics/java/android/graphics/RuntimeXfermode.java index f5a656862bf9..51d97a4b7487 100644 --- a/graphics/java/android/graphics/RuntimeXfermode.java +++ b/graphics/java/android/graphics/RuntimeXfermode.java @@ -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); |