public class CyberPlayerSurface
extends SurfaceView
Modifier and Type | Class and Description |
---|---|
static interface |
CPGLSurfaceView.EGLConfigChooser
An interface for choosing an EGLConfig configuration from a list of
potential configurations.
|
static interface |
CPGLSurfaceView.EGLContextFactory
An interface for customizing the eglCreateContext and eglDestroyContext
calls.
|
static interface |
CPGLSurfaceView.EGLWindowSurfaceFactory
An interface for customizing the eglCreateWindowSurface and
eglDestroySurface calls.
|
static interface |
CPGLSurfaceView.GLWrapper
An interface used to wrap a GL interface.
|
static interface |
CPGLSurfaceView.Renderer
A generic renderer interface.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG_CHECK_GL_ERROR
Check glError() after every GL call and throw an exception if glError
indicates that an error has occurred.
|
static int |
DEBUG_LOG_GL_CALLS
Log GL calls to the system log at "verbose" level with tag
"GLSurfaceView".
|
static int |
JellyBean |
boolean |
mGL20Support |
static int |
RENDERMODE_CONTINUOUSLY
The renderer is called continuously to re-render the scene.
|
static int |
RENDERMODE_WHEN_DIRTY
The renderer only renders when the surface is created, or when
requestRender() is called. |
static java.lang.String |
TAG |
Constructor and Description |
---|
CyberPlayerSurface(Context context) |
CyberPlayerSurface(Context context,
AttributeSet attrs) |
Modifier and Type | Method and Description |
---|---|
void |
checkShouldCreatTexture() |
void |
createVPTex(int width,
int height,
int format) |
void |
destroyByteBuffer() |
void |
destroyVPTex() |
int |
getDebugFlags()
Get the current value of the debug flags.
|
boolean |
getPreserveEGLContextOnPause() |
int |
getRenderMode()
Get the current rendering mode.
|
Surface |
getSurface() |
java.nio.ByteBuffer |
getVPBuf() |
void |
init() |
void |
onFrameUpdate() |
void |
onPause()
Inform the view that the activity is paused.
|
void |
onResume()
Inform the view that the activity is resumed.
|
void |
OnSurfaceDestroyed() |
void |
queueEvent(java.lang.Runnable r)
Queue a runnable to be run on the GL rendering thread.
|
void |
recycle() |
void |
requestRender()
Request that the renderer render a frame.
|
void |
setBackUpSnapShot(byte[] backUpSnapShot) |
void |
setCheckBackupSnapShot(byte[] backupSnapShot) |
void |
setDebugFlags(int debugFlags)
Set the debug flags to a new value.
|
void |
setDisplayMode(int mode) |
void |
setEGLConfigChooser(boolean needDepth)
Install a config chooser which will choose a config as close to 16-bit
RGB as possible, with or without an optional depth buffer as close to
16-bits as possible.
|
void |
setEGLConfigChooser(CPGLSurfaceView.EGLConfigChooser configChooser)
Install a custom EGLConfigChooser.
|
void |
setEGLConfigChooser(int redSize,
int greenSize,
int blueSize,
int alphaSize,
int depthSize,
int stencilSize)
Install a config chooser which will choose a config with at least the
specified depthSize and stencilSize, and exactly the specified redSize,
greenSize, blueSize and alphaSize.
|
void |
setEGLContextClientVersion(int version)
Inform the default EGLContextFactory and default EGLConfigChooser which
EGLContext client version to pick.
|
void |
setEGLContextFactory(CPGLSurfaceView.EGLContextFactory factory)
Install a custom EGLContextFactory.
|
void |
setEGLWindowSurfaceFactory(CPGLSurfaceView.EGLWindowSurfaceFactory factory)
Install a custom EGLWindowSurfaceFactory.
|
void |
setGLWrapper(CPGLSurfaceView.GLWrapper glWrapper)
Set the glWrapper.
|
void |
setPreserveEGLContextOnPause(boolean preserveOnPause)
Control whether the EGL context is preserved when the GLSurfaceView is
paused and resumed.
|
void |
setRenderer(CPGLSurfaceView.Renderer renderer)
Set the renderer associated with this view.
|
void |
setRenderMode(int renderMode)
Set the rendering mode.
|
void |
setVideoDims(int width,
int height,
int format,
java.nio.ByteBuffer byteBuffer) |
void |
surfaceChanged(SurfaceHolder holder,
int format,
int w,
int h)
This method is part of the SurfaceHolder.Callback interface, and is not
normally called or subclassed by clients of GLSurfaceView.
|
void |
surfaceCreated(SurfaceHolder holder)
This method is part of the SurfaceHolder.Callback interface, and is not
normally called or subclassed by clients of GLSurfaceView.
|
void |
surfaceDestroyed(SurfaceHolder holder)
This method is part of the SurfaceHolder.Callback interface, and is not
normally called or subclassed by clients of GLSurfaceView.
|
void |
updateVPTex(int offset) |
public static final java.lang.String TAG
public static final int JellyBean
public boolean mGL20Support
public static final int RENDERMODE_WHEN_DIRTY
requestRender()
is called.public static final int RENDERMODE_CONTINUOUSLY
getRenderMode()
,
setRenderMode(int)
,
Constant Field Valuespublic static final int DEBUG_CHECK_GL_ERROR
getDebugFlags()
,
setDebugFlags(int)
,
Constant Field Valuespublic static final int DEBUG_LOG_GL_CALLS
getDebugFlags()
,
setDebugFlags(int)
,
Constant Field Valuespublic CyberPlayerSurface(Context context)
public CyberPlayerSurface(Context context, AttributeSet attrs)
public Surface getSurface()
public void init()
public void destroyByteBuffer()
public void setVideoDims(int width, int height, int format, java.nio.ByteBuffer byteBuffer)
public void onFrameUpdate()
public void setDisplayMode(int mode)
public void createVPTex(int width, int height, int format)
public void destroyVPTex()
public void updateVPTex(int offset)
public java.nio.ByteBuffer getVPBuf()
public void onResume()
public void recycle()
public void OnSurfaceDestroyed()
public void checkShouldCreatTexture()
public void setBackUpSnapShot(byte[] backUpSnapShot)
public void setGLWrapper(CPGLSurfaceView.GLWrapper glWrapper)
CPGLSurfaceView.GLWrapper.wrap(GL)
method is called whenever a surface is
created. A GLWrapper can be used to wrap the GL object that's passed to
the renderer. Wrapping a GL object enables examining and modifying the
behavior of the GL calls made by the renderer.
Wrapping is typically used for debugging purposes.
The default value is null.
glWrapper
- the new GLWrapperpublic void setDebugFlags(int debugFlags)
debugFlags
- the new debug flagsDEBUG_CHECK_GL_ERROR
,
DEBUG_LOG_GL_CALLS
public int getDebugFlags()
public void setPreserveEGLContextOnPause(boolean preserveOnPause)
If set to true, then the EGL context may be preserved when the GLSurfaceView is paused. Whether the EGL context is actually preserved or not depends upon whether the Android device that the program is running on can support an arbitrary number of EGL contexts or not. Devices that can only support a limited number of EGL contexts must release the EGL context in order to allow multiple applications to share the GPU.
If set to false, the EGL context will be released when the GLSurfaceView is paused, and recreated when the GLSurfaceView is resumed.
The default is false.
preserveOnPause
- preserve the EGL context when pausedpublic boolean getPreserveEGLContextOnPause()
public void setRenderer(CPGLSurfaceView.Renderer renderer)
This method should be called once and only once in the life-cycle of a GLSurfaceView.
The following GLSurfaceView methods can only be called before setRenderer is called:
setEGLConfigChooser(boolean)
setEGLConfigChooser(EGLConfigChooser)
setEGLConfigChooser(int, int, int, int, int, int)
The following GLSurfaceView methods can only be called after setRenderer is called:
renderer
- the renderer to use to perform OpenGL drawing.public void setEGLContextFactory(CPGLSurfaceView.EGLContextFactory factory)
If this method is called, it must be called before
setRenderer(Renderer)
is called.
If this method is not called, then by default a context will be created with no shared context and with a null attribute list.
public void setEGLWindowSurfaceFactory(CPGLSurfaceView.EGLWindowSurfaceFactory factory)
If this method is called, it must be called before
setRenderer(Renderer)
is called.
If this method is not called, then by default a window surface will be created with a null attribute list.
public void setEGLConfigChooser(CPGLSurfaceView.EGLConfigChooser configChooser)
If this method is called, it must be called before
setRenderer(Renderer)
is called.
If no setEGLConfigChooser method is called, then by default the view will choose an EGLConfig that is compatible with the current android.view.Surface, with a depth buffer depth of at least 16 bits.
configChooser
- public void setEGLConfigChooser(boolean needDepth)
If this method is called, it must be called before
setRenderer(Renderer)
is called.
If no setEGLConfigChooser method is called, then by default the view will choose an RGB_888 surface with a depth buffer depth of at least 16 bits.
needDepth
- public void setEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
If this method is called, it must be called before
setRenderer(Renderer)
is called.
If no setEGLConfigChooser method is called, then by default the view will choose an RGB_888 surface with a depth buffer depth of at least 16 bits.
public void setEGLContextClientVersion(int version)
Use this method to create an OpenGL ES 2.0-compatible context. Example:
public MyView(Context context) { super(context); setEGLContextClientVersion(2); // Pick an OpenGL ES 2.0 context. setRenderer(new MyRenderer()); }
Note: Activities which require OpenGL ES 2.0 should indicate this by setting @lt;uses-feature android:glEsVersion="0x00020000" /> in the activity's AndroidManifest.xml file.
If this method is called, it must be called before
setRenderer(Renderer)
is called.
This method only affects the behavior of the default EGLContexFactory and
the default EGLConfigChooser. If
setEGLContextFactory(EGLContextFactory)
has been called, then
the supplied EGLContextFactory is responsible for creating an OpenGL ES
2.0-compatible context. If setEGLConfigChooser(EGLConfigChooser)
has been called, then the supplied EGLConfigChooser is responsible for
choosing an OpenGL ES 2.0-compatible config.
version
- The EGLContext client version to choose. Use 2 for OpenGL ES
2.0public void setRenderMode(int renderMode)
requestRender()
is called. Defaults to
RENDERMODE_CONTINUOUSLY.
Using RENDERMODE_WHEN_DIRTY can improve battery life and overall system performance by allowing the GPU and CPU to idle when the view does not need to be updated.
This method can only be called after setRenderer(Renderer)
renderMode
- one of the RENDERMODE_X constantsRENDERMODE_CONTINUOUSLY
,
RENDERMODE_WHEN_DIRTY
public int getRenderMode()
RENDERMODE_CONTINUOUSLY
,
RENDERMODE_WHEN_DIRTY
public void requestRender()
RENDERMODE_WHEN_DIRTY
, so
that frames are only rendered on demand. May be called from any thread.
Must not be called before a renderer has been set.public void setCheckBackupSnapShot(byte[] backupSnapShot)
public void surfaceCreated(SurfaceHolder holder)
public void surfaceDestroyed(SurfaceHolder holder)
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h)
public void onPause()
public void queueEvent(java.lang.Runnable r)
r
- the runnable to be run on the GL rendering thread.