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 | ||
      This class is deprecated.
      Use Watch Face Format APIs instead.
  
The actual implementation of a watch face that draws using OpenGL ES 2.0. You must implement
 Gles2WatchFaceService.onCreateEngine() to return your concrete Engine implementation.
Summary
| Public constructors | |
|---|---|
| 
      Engine()
       | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        EGLConfig | 
      chooseEglConfig(EGLDisplay eglDisplay)
      Returns the desired EGL config to use. | 
| 
        
        
        
        
        
        EGLContext | 
      createEglContext(EGLDisplay eglDisplay, EGLConfig eglConfig)
      Creates the EGL context and returns it. | 
| 
        
        
        
        
        
        EGLSurface | 
      createWindowSurface(EGLDisplay eglDisplay, EGLConfig eglConfig, SurfaceHolder surfaceHolder)
      Creates and returns a new EGL window surface for  | 
| 
        
        
        
        
        
        EGLDisplay | 
      initializeEglDisplay()
      Initializes the display. | 
| 
        
        
        
        final
        
        void | 
      invalidate()
      Schedules a call to  | 
| 
        
        
        
        
        
        void | 
      onApplyWindowInsets(WindowInsets insets)
       | 
| 
        
        
        
        
        
        void | 
      onCreate(SurfaceHolder surfaceHolder)
       | 
| 
        
        
        
        
        
        void | 
      onDestroy()
       | 
| 
        
        
        
        
        
        void | 
      onDraw()
      Draws the watch face. | 
| 
        
        
        
        
        
        void | 
      onGlContextCreated()
      Called when a new GL context is created. | 
| 
        
        
        
        
        
        void | 
      onGlSurfaceCreated(int width, int height)
      Called when a new GL surface is created. | 
| 
        
        
        
        final
        
        void | 
      onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)
       | 
| 
        
        
        
        final
        
        void | 
      onSurfaceDestroyed(SurfaceHolder holder)
       | 
| 
        
        
        
        final
        
        void | 
      onSurfaceRedrawNeeded(SurfaceHolder holder)
       | 
| 
        
        
        
        final
        
        void | 
      postInvalidate()
      Posts a message to schedule a call to  | 
| Inherited methods | |
|---|---|
Public constructors
Engine
public Engine ()
Public methods
chooseEglConfig
public EGLConfig chooseEglConfig (EGLDisplay eglDisplay)
Returns the desired EGL config to use. By default, uses a config that:
- supports OpenGL ES 2.0 contexts
- has at least 8 bits for each of red, green, blue, and alpha
Watch faces can override this method to call EGL14.eglChooseConfig(EGLDisplay, int[], int, EGLConfig[], int, int, int[], int) with different
 attributes. By passing in a large array, eglChooseConfig can return multiple matching
 configs and the watch face can choose among them by using EGL14.eglGetConfigAttrib(EGLDisplay, EGLConfig, int, int[], int) to
 fetch their attributes.
| Parameters | |
|---|---|
| eglDisplay | EGLDisplay: the EGL display to use | 
| Returns | |
|---|---|
| EGLConfig | the EGL config to use | 
createEglContext
public EGLContext createEglContext (EGLDisplay eglDisplay, EGLConfig eglConfig)
Creates the EGL context and returns it. By default, creates an EGL 2.0 context using EGL14.eglCreateContext(EGLDisplay, EGLConfig, EGLContext, int[], int).
 
Watch faces can override this method to call EGL14.eglCreateContext(EGLDisplay, EGLConfig, EGLContext, int[], int) with different
 attributes.
| Parameters | |
|---|---|
| eglDisplay | EGLDisplay | 
| eglConfig | EGLConfig | 
| Returns | |
|---|---|
| EGLContext | |
createWindowSurface
public EGLSurface createWindowSurface (EGLDisplay eglDisplay, EGLConfig eglConfig, SurfaceHolder surfaceHolder)
Creates and returns a new EGL window surface for surfaceHolder. By default, this
 surface has no attributes.
 
Watch faces can override this method to call EGL14.eglCreateWindowSurface(EGLDisplay, EGLConfig, Object, int[], int) with
 different attributes.
| Parameters | |
|---|---|
| eglDisplay | EGLDisplay | 
| eglConfig | EGLConfig | 
| surfaceHolder | SurfaceHolder | 
| Returns | |
|---|---|
| EGLSurface | |
initializeEglDisplay
public EGLDisplay initializeEglDisplay ()
Initializes the display. Calls EGL14.eglGetDisplay(int) and EGL14.eglInitialize(EGLDisplay, int[], int, int[], int).
| Returns | |
|---|---|
| EGLDisplay | the initialized EGLDisplay to use | 
invalidate
public final void invalidate ()
Schedules a call to onDraw() to draw the next frame. Must be called on the main
 thread.
onApplyWindowInsets
public void onApplyWindowInsets (WindowInsets insets)
| Parameters | |
|---|---|
| insets | WindowInsets | 
onDestroy
public void onDestroy ()
onDraw
public void onDraw ()
Draws the watch face. It's safe to use GL APIs in this method.
onGlContextCreated
public void onGlContextCreated ()
Called when a new GL context is created. It's safe to use GL APIs in this method.
onGlSurfaceCreated
public void onGlSurfaceCreated (int width, 
                int height)Called when a new GL surface is created. It's safe to use GL APIs in this method.
| Parameters | |
|---|---|
| width | int: width of surface in pixels | 
| height | int: height of surface in pixels | 
onSurfaceChanged
public final void onSurfaceChanged (SurfaceHolder holder, int format, int width, int height)
| Parameters | |
|---|---|
| holder | SurfaceHolder | 
| format | int | 
| width | int | 
| height | int | 
onSurfaceDestroyed
public final void onSurfaceDestroyed (SurfaceHolder holder)
| Parameters | |
|---|---|
| holder | SurfaceHolder | 
onSurfaceRedrawNeeded
public final void onSurfaceRedrawNeeded (SurfaceHolder holder)
| Parameters | |
|---|---|
| holder | SurfaceHolder | 
postInvalidate
public final void postInvalidate ()
Posts a message to schedule a call to onDraw() to draw the next frame. Unlike invalidate(), this method is thread-safe and may be called on any thread.
