2

As stated in https://stackoverflow.com/a/16257100/3286489, in order for drawVertices to draw something in Android Canvas, it need to disable Hardware acceleration using

setLayerType(View.LAYER_TYPE_SOFTWARE, null);

I check the underlying code, it has this check

    public void drawVertices(@NonNull VertexMode mode, int vertexCount, @NonNull float[] verts,
            int vertOffset, @Nullable float[] texs, int texOffset, @Nullable int[] colors,
            int colorOffset, @Nullable short[] indices, int indexOffset, int indexCount,
            @NonNull Paint paint) {
        checkRange(verts.length, vertOffset, vertexCount);
        if (isHardwareAccelerated()) {
            return;
        }
        // ... codes that perform the drawing
   }

Why can't we use hardware acceleration on it?

It is not mentioned in the Android doc

Elye
  • 53,639
  • 54
  • 212
  • 474
  • 1
    `drawVertices` is listed as unsupported here: https://developer.android.com/guide/topics/graphics/hardware-accel#unsupported – Morrison Chang Apr 07 '19 at 04:48
  • Also if you are using `drawVertices()` you should probably be considering `TextureView`/`GLSurfaceView` and doing full OpenGL ES calls as `Canvas.VertexMode` matches OpenGL ES drawing modes. – Morrison Chang Apr 07 '19 at 05:24

0 Answers0