I have implemented the AGSL code written in the documentation:
@Language("AGSL")
private static final String COLOR_SHADER_SRC =
"half4 main(float2 fragCoord) {\n" +
"return half4(1.0,0.0,0.0,1.0);\n" +
"}";
private static final RuntimeShader fixedColorShader = new RuntimeShader(COLOR_SHADER_SRC);
private static final Paint shaderPaint = new Paint();
and in the constructor:
shaderPaint.setShader(fixedColorShader)
But when I call with some canvas:
this.canvas.drawPaint(shaderPaint);
I get:
[SurfaceView[com.example.mandebrotset/com.example.mandebrotset.MainActivity]#1(BLAST Consumer
eglCreateWindowSurface: native_window_api_connect (win=0xb400007d4d1f56d0) failed (0xffffffea
eglCreateWindowSurfaceTmpl:689 error 3003 (EGL_BAD_ALLOC)
Exception dispatching input event.
Exception in MessageQueue callback: handleReceiveCallback
java.lang.IllegalArgumentException: Software rendering doesn't support RuntimeShader
at android.graphics.BaseCanvas.throwIfHasHwFeaturesInSwMode(BaseCanvas.java:745)
at android.graphics.BaseCanvas.throwIfHasHwFeaturesInSwMode(BaseCanvas.java:735)
at android.graphics.BaseCanvas.drawPaint(BaseCanvas.java:307)
at android.graphics.Canvas.drawPaint(Canvas.java:1832)
I tried moving from API 33 to Android version 14 with SDK API 34 but nothing changed.
I enabled
android:hardwareAccelerated="true"
at the manifest in the whole Application, still no change.The canvas from
SurfaceHolder
is given by thesurfHolder.lockHardwareCanvas()
. No change.