public class GPUImageRenderer extends java.lang.Object implements android.opengl.GLSurfaceView.Renderer, GLTextureView.Renderer, android.hardware.Camera.PreviewCallback
| Modifier and Type | Field and Description |
|---|---|
static float[] |
CUBE |
java.lang.Object |
surfaceChangedWaiter |
| Constructor and Description |
|---|
GPUImageRenderer(GPUImageFilter filter) |
| Modifier and Type | Method and Description |
|---|---|
void |
deleteImage() |
protected int |
getFrameHeight() |
protected int |
getFrameWidth() |
Rotation |
getRotation() |
boolean |
isFlippedHorizontally() |
boolean |
isFlippedVertically() |
void |
onDrawFrame(javax.microedition.khronos.opengles.GL10 gl)
Called to draw the current frame.
|
void |
onPreviewFrame(byte[] data,
android.hardware.Camera camera) |
void |
onPreviewFrame(byte[] data,
int width,
int height) |
void |
onSurfaceChanged(javax.microedition.khronos.opengles.GL10 gl,
int width,
int height)
Called when the surface changed size.
|
void |
onSurfaceCreated(javax.microedition.khronos.opengles.GL10 unused,
javax.microedition.khronos.egl.EGLConfig config)
Called when the surface is created or recreated.
|
protected void |
runOnDraw(java.lang.Runnable runnable) |
protected void |
runOnDrawEnd(java.lang.Runnable runnable) |
void |
setBackgroundColor(float red,
float green,
float blue)
Sets the background color
|
void |
setFilter(GPUImageFilter filter) |
void |
setImageBitmap(android.graphics.Bitmap bitmap) |
void |
setImageBitmap(android.graphics.Bitmap bitmap,
boolean recycle) |
void |
setRotation(Rotation rotation) |
void |
setRotation(Rotation rotation,
boolean flipHorizontal,
boolean flipVertical) |
void |
setRotationCamera(Rotation rotation,
boolean flipHorizontal,
boolean flipVertical) |
void |
setScaleType(GPUImage.ScaleType scaleType) |
void |
setUpSurfaceTexture(android.hardware.Camera camera) |
public static final float[] CUBE
public final java.lang.Object surfaceChangedWaiter
public GPUImageRenderer(GPUImageFilter filter)
public void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 unused,
javax.microedition.khronos.egl.EGLConfig config)
GLTextureView.RendererCalled when the rendering thread starts and whenever the EGL context is lost. The EGL context will typically be lost when the Android device awakes after going to sleep.
Since this method is called at the beginning of rendering, as well as every time the EGL context is lost, this method is a convenient place to put code to create resources that need to be created when the rendering starts, and that need to be recreated when the EGL context is lost. Textures are an example of a resource that you might want to create here.
Note that when the EGL context is lost, all OpenGL resources associated with that context will be automatically deleted. You do not need to call the corresponding "glDelete" methods such as glDeleteTextures to manually delete these lost resources.
onSurfaceCreated in interface android.opengl.GLSurfaceView.RendereronSurfaceCreated in interface GLTextureView.Rendererunused - the GL interface. Use instanceof to
test if the interface supports GL11 or higher interfaces.config - the EGLConfig of the created surface. Can be used
to create matching pbuffers.public void onSurfaceChanged(javax.microedition.khronos.opengles.GL10 gl,
int width,
int height)
GLTextureView.RendererCalled after the surface is created and whenever the OpenGL ES surface size changes.
Typically you will set your viewport here. If your camera is fixed then you could also set your projection matrix here:
void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
// for a fixed camera, set the projection too
float ratio = (float) width / height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
}
onSurfaceChanged in interface android.opengl.GLSurfaceView.RendereronSurfaceChanged in interface GLTextureView.Renderergl - the GL interface. Use instanceof to
test if the interface supports GL11 or higher interfaces.public void onDrawFrame(javax.microedition.khronos.opengles.GL10 gl)
GLTextureView.RendererThis method is responsible for drawing the current frame.
The implementation of this method typically looks like this:
void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
//... other gl calls to render the scene ...
}
onDrawFrame in interface android.opengl.GLSurfaceView.RendereronDrawFrame in interface GLTextureView.Renderergl - the GL interface. Use instanceof to
test if the interface supports GL11 or higher interfaces.public void setBackgroundColor(float red,
float green,
float blue)
red - red color valuegreen - green color valueblue - red color valuepublic void onPreviewFrame(byte[] data,
android.hardware.Camera camera)
onPreviewFrame in interface android.hardware.Camera.PreviewCallbackpublic void onPreviewFrame(byte[] data,
int width,
int height)
public void setUpSurfaceTexture(android.hardware.Camera camera)
public void setFilter(GPUImageFilter filter)
public void deleteImage()
public void setImageBitmap(android.graphics.Bitmap bitmap)
public void setImageBitmap(android.graphics.Bitmap bitmap,
boolean recycle)
public void setScaleType(GPUImage.ScaleType scaleType)
protected int getFrameWidth()
protected int getFrameHeight()
public void setRotationCamera(Rotation rotation, boolean flipHorizontal, boolean flipVertical)
public void setRotation(Rotation rotation)
public void setRotation(Rotation rotation, boolean flipHorizontal, boolean flipVertical)
public Rotation getRotation()
public boolean isFlippedHorizontally()
public boolean isFlippedVertically()
protected void runOnDraw(java.lang.Runnable runnable)
protected void runOnDrawEnd(java.lang.Runnable runnable)