Gles2WatchFaceService.Engine

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实现。

Summary

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)

surfaceHolder创建并返回一个新的EGL窗口表面。

EGLDisplay initializeEglDisplay()

初始化显示。

final void invalidate()

计划拨打 onDraw()以绘制下一帧。

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()

发布消息安排电话 onDraw()绘制下一帧。

Inherited methods

From class android.support.wearable.watchface.WatchFaceService.Engine
From class android.service.wallpaper.WallpaperService.Engine
From class java.lang.Object

Public constructors

Gles2WatchFaceService.Engine

Gles2WatchFaceService.Engine ()

Public methods

chooseEglConfig

EGLConfig chooseEglConfig (EGLDisplay eglDisplay)

返回需要使用的EGL配置。 默认情况下,使用一个配置:

If there are multiple matches, the one with the most bits for red, green, blue, and alpha is chosen.

手表可以覆盖此方法以调用具有不同属性的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

createEglContext

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

createWindowSurface

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

initializeEglDisplay

EGLDisplay initializeEglDisplay ()

初始化显示。 致电eglGetDisplay(int)eglInitialize(EGLDisplay, int[], int, int[], int)

Returns
EGLDisplay the initialized EGLDisplay to use

invalidate

void invalidate ()

计划拨打onDraw()以绘制下一帧。 必须在主线程中调用。

onApplyWindowInsets

void onApplyWindowInsets (WindowInsets insets)

Parameters
insets WindowInsets

onCreate

void onCreate (SurfaceHolder surfaceHolder)

Parameters
surfaceHolder SurfaceHolder

onDestroy

void onDestroy ()

onDraw

void onDraw ()

绘制表盘。 在这种方法中使用GL API是安全的。

onGlContextCreated

void onGlContextCreated ()

在创建新的GL上下文时调用。 在这种方法中使用GL API是安全的。

onGlSurfaceCreated

void onGlSurfaceCreated (int width,
                int height)

在创建新的GL表面时调用。 在这种方法中使用GL API是安全的。

Parameters
width int: width of surface in pixels
height int: height of surface in pixels

onSurfaceChanged

void onSurfaceChanged (SurfaceHolder holder,
                int format,
                int width,
                int height)

Parameters
holder SurfaceHolder
format int
width int
height int

onSurfaceDestroyed

void onSurfaceDestroyed (SurfaceHolder holder)

Parameters
holder SurfaceHolder

onSurfaceRedrawNeeded

void onSurfaceRedrawNeeded (SurfaceHolder holder)

Parameters
holder SurfaceHolder

postInvalidate

void postInvalidate ()

onDraw()消息安排电话onDraw()绘制下一帧。 invalidate()不同,此方法是线程安全的,可以在任何线程上调用。