summaryrefslogtreecommitdiff
path: root/graphics/java
diff options
context:
space:
mode:
author Derek Sollenberger <djsollen@google.com> 2021-11-05 19:25:05 +0000
committer Derek Sollenberger <djsollen@google.com> 2021-12-17 02:44:46 +0000
commit56c079839121da5d368d4aadeaceeff558ee106b (patch)
tree1f2134ea697ca6d689cc9942759724b76108c00b /graphics/java
parent1cac926292f5e6e7144add5ab1ba646112f27749 (diff)
Add RuntimeShader API to RenderEffect
Bug: 201546136 Test: atest CtsUiRenderingTestCases:RuntimeShaderTests Change-Id: I96ad4fcfc0486f340653878519efcc4a793191a2
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/RenderEffect.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/RenderEffect.java b/graphics/java/android/graphics/RenderEffect.java
index ad4c3fe86175..b8a46856601e 100644
--- a/graphics/java/android/graphics/RenderEffect.java
+++ b/graphics/java/android/graphics/RenderEffect.java
@@ -290,6 +290,22 @@ public final class RenderEffect {
return new RenderEffect(nativeCreateShaderEffect(shader.getNativeInstance()));
}
+ /**
+ * Create a {@link RenderEffect} that executes the provided {@link RuntimeShader} and passes
+ * the contents of the {@link android.graphics.RenderNode} that this RenderEffect is installed
+ * on as an input to the shader.
+ * @param shader the runtime shader that will bind the inputShaderName to the RenderEffect input
+ * @param uniformShaderName the uniform name defined in the RuntimeShader's program to which
+ * the contents of the RenderNode will be bound
+ */
+ @NonNull
+ public static RenderEffect createRuntimeShaderEffect(
+ @NonNull RuntimeShader shader, @NonNull String uniformShaderName) {
+ return new RenderEffect(
+ nativeCreateRuntimeShaderEffect(shader.getNativeShaderBuilder(),
+ uniformShaderName));
+ }
+
private final long mNativeRenderEffect;
/* only constructed from static factory methods */
@@ -318,5 +334,7 @@ public final class RenderEffect {
private static native long nativeCreateBlendModeEffect(long dst, long src, int blendmode);
private static native long nativeCreateChainEffect(long outer, long inner);
private static native long nativeCreateShaderEffect(long shader);
+ private static native long nativeCreateRuntimeShaderEffect(
+ long shaderBuilder, String inputShaderName);
private static native long nativeGetFinalizer();
}