Idea from: * Codes of Android source code under package com.android.gallery3d.glrenderer * GPUImage * grafika Thanks to them!
Used by: * AndroidInstantVideo
Provides GLViews that using GLSurfaceView and TextureView.
The GLContinuousView can provide high performance continuous rendering animation because it uses openGL to draw in its own thread. (If you just need this feature, I recommend you extend View instead.)

Compare to GPUImage: * Provide the continuous rendering Thread in GLContinuousView and GLContinuousTextureView. * Using TextureView has this benefit: TextureView does not create a separate window but behaves as a regular View. This key difference allows a TextureView to be moved, transformed, animated, etc. For instance, you can make a TextureView semi-translucent by calling myView.setAlpha(0.5f) * Canvas is provided. Not only the image processing but drawing thing what you want.
sample:
// in root build.gradle
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
// module build.gradle
dependencies {
implementation 'com.github.ChillingVan:android-openGL-canvas:v1.5.4.0'
}
public class MyGLView extends GLView {
public MyGLView(Context context) {
super(context);
}
public MyGLView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onGLDraw(ICanvasGL canvas) {
// draw things with canvas here
}
}

The Usage of GLContinuouslyView, GLTextureView, GLContinuousTextureView, GLMultiTexProducerView and GLMultiTexConsumerView is similar.
Using canvas to draw
canvas.drawBitmap(textBitmap, left, top);
// transform
canvas.save();
canvas.rotate(rotateDegree, x, y);
canvas.drawBitmap(bitmap, left, top);
canvas.restore();
// or
CanvasGL.BitmapMatrix matrix = new CanvasGL.BitmapMatrix();
matrix.postScale(2.1f, 2.1f);
matrix.postRotate(90);
canvas.drawBitmap(bitmap, matrix);
// apply filter to the bitmap
textureFilter = new ContrastFilter(2.8f);
canvas.drawBitmap(bitmap, left, top, textureFilter);


If you do not want to use GLView, you can use MultiTexOffScreenCanvas to draw things and fetch it by getDrawingBitmap.
MediaPlayer
You can use MediaPlayer to decode video and draw it on the TextureView. If you use GLSurfaceTextureProducerView, then you can process the video frames and provide the texture to MediaCodec to create a new Video. Use this sample and the stream publisher sample of AndroidInstantVideo. You can implement this.
This GLCanvas cannot draw text. You can use AndroidCanvasHelper to draw what you want and turn it to bitmap for GLCanvas. It has sync and async modes.
You can use canvasGL.invalidateTextureContent(bitmap) to rebind the bitmap to texture. This is kind of heavy so I do not update call this for every drawn. * The CanvasGL doesn't support drawPath or drawText. You can try IAndroidCanvasHelper but this just uses Android canvas to generate a Bitmap. So heed the performance.
Copyright 2016 ChillingVan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
$ claude mcp add android-openGL-canvas \
-- python -m otcore.mcp_server <graph>