public class Gles2WatchFaceService.Engine
extends WatchFaceService.Engine
java.lang.Object | |||
↳ | android.service.wallpaper.WallpaperService.Engine | ||
↳ | android.support.wearable.watchface.WatchFaceService.Engine | ||
↳ | android.support.wearable.watchface.Gles2WatchFaceService.Engine |
使用OpenGL ES 2.0绘制的表盘的实际实现。 您必须实现onCreateEngine()
才能返回具体的Engine实现。
Public constructors |
|
---|---|
Gles2WatchFaceService.Engine() |
Public methods |
|
---|---|
EGLConfig |
chooseEglConfig(EGLDisplay eglDisplay) 返回需要使用的EGL配置。 |
EGLContext |
createEglContext(EGLDisplay eglDisplay, EGLConfig eglConfig) 创建EGL上下文并返回它。 |
EGLSurface |
createWindowSurface(EGLDisplay eglDisplay, EGLConfig eglConfig, SurfaceHolder surfaceHolder) 为 |
EGLDisplay |
initializeEglDisplay() 初始化显示。 |
final void |
invalidate() 计划拨打 |
void |
onApplyWindowInsets(WindowInsets insets) |
void |
onCreate(SurfaceHolder surfaceHolder) |
void |
onDestroy() |
void |
onDraw() 绘制表盘。 |
void |
onGlContextCreated() 在创建新的GL上下文时调用。 |
void |
onGlSurfaceCreated(int width, int height) 在创建新的GL表面时调用。 |
final void |
onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) |
final void |
onSurfaceDestroyed(SurfaceHolder holder) |
final void |
onSurfaceRedrawNeeded(SurfaceHolder holder) |
final void |
postInvalidate() 发布消息安排电话 |
Inherited methods |
|
---|---|
From class android.support.wearable.watchface.WatchFaceService.Engine
|
|
From class android.service.wallpaper.WallpaperService.Engine
|
|
From class java.lang.Object
|
Gles2WatchFaceService.Engine ()
EGLConfig chooseEglConfig (EGLDisplay eglDisplay)
返回需要使用的EGL配置。 默认情况下,使用一个配置:
手表可以覆盖此方法以调用具有不同属性的eglChooseConfig(EGLDisplay, int[], int, EGLConfig[], int, int, int[], int)
。 通过传递大数组, eglChooseConfig
可以返回多个匹配配置,并且表盘可以通过使用eglGetConfigAttrib(EGLDisplay, EGLConfig, int, int[], int)
来获取其属性来选择它们。
Parameters | |
---|---|
eglDisplay |
EGLDisplay : the EGL display to use |
Returns | |
---|---|
EGLConfig |
the EGL config to use |
EGLContext createEglContext (EGLDisplay eglDisplay, EGLConfig eglConfig)
创建EGL上下文并返回它。 默认情况下,使用eglCreateContext(EGLDisplay, EGLConfig, EGLContext, int[], int)
创建EGL 2.0上下文。
手表可以覆盖此方法以调用具有不同属性的 eglCreateContext(EGLDisplay, EGLConfig, EGLContext, int[], int)
。
Parameters | |
---|---|
eglDisplay |
EGLDisplay
|
eglConfig |
EGLConfig
|
Returns | |
---|---|
EGLContext |
EGLSurface createWindowSurface (EGLDisplay eglDisplay, EGLConfig eglConfig, SurfaceHolder surfaceHolder)
为surfaceHolder
创建并返回一个新的EGL窗口表面。 默认情况下,该曲面没有属性。
手表可以覆盖此方法以调用具有不同属性的 eglCreateWindowSurface(EGLDisplay, EGLConfig, Object, int[], int)
。
Parameters | |
---|---|
eglDisplay |
EGLDisplay
|
eglConfig |
EGLConfig
|
surfaceHolder |
SurfaceHolder
|
Returns | |
---|---|
EGLSurface |
EGLDisplay initializeEglDisplay ()
初始化显示。 致电eglGetDisplay(int)
和eglInitialize(EGLDisplay, int[], int, int[], int)
。
Returns | |
---|---|
EGLDisplay |
the initialized EGLDisplay to use |
void onApplyWindowInsets (WindowInsets insets)
Parameters | |
---|---|
insets |
WindowInsets
|
void onCreate (SurfaceHolder surfaceHolder)
Parameters | |
---|---|
surfaceHolder |
SurfaceHolder
|
void onDestroy ()
void onDraw ()
绘制表盘。 在这种方法中使用GL API是安全的。
void onGlContextCreated ()
在创建新的GL上下文时调用。 在这种方法中使用GL API是安全的。
void onGlSurfaceCreated (int width, int height)
在创建新的GL表面时调用。 在这种方法中使用GL API是安全的。
Parameters | |
---|---|
width |
int : width of surface in pixels |
height |
int : height of surface in pixels |
void onSurfaceChanged (SurfaceHolder holder, int format, int width, int height)
Parameters | |
---|---|
holder |
SurfaceHolder
|
format |
int
|
width |
int
|
height |
int
|
void onSurfaceDestroyed (SurfaceHolder holder)
Parameters | |
---|---|
holder |
SurfaceHolder
|
void onSurfaceRedrawNeeded (SurfaceHolder holder)
Parameters | |
---|---|
holder |
SurfaceHolder
|
void postInvalidate ()
onDraw()
消息安排电话onDraw()
绘制下一帧。 与invalidate()
不同,此方法是线程安全的,可以在任何线程上调用。