Summary: Ctors | Methods | Inherited Methods | [Expand All]

# 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

The actual implementation of a watch face that draws using OpenGL ES 2.0. You must implement `onCreateEngine()` to return your concrete Engine implementation.

## Summary

### Public constructors
`Gles2WatchFaceService.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 `surfaceHolder`.
`EGLDisplay` | `initializeEglDisplay()` Initializes the display.
`final void` | `invalidate()` Schedules a call to `onDraw()` to draw the next frame.
`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 `onDraw()` to draw the next frame.

### Inherited methods
From class `android.support.wearable.watchface.WatchFaceService.Engine`
`final int` | `getInterruptionFilter()` Returns interruption filter selected by the user.
`final int` | `getNotificationCount()` Returns the total number of notification cards in the stream.
`final Rect` | `getPeekCardPosition()` Returns the location of the first peeking card.
`final int` | `getUnreadCount()` Returns the number of unread notification cards in the stream.
`final boolean` | `isInAmbientMode()` Returns whether the watch face is in ambient mode.
`void` | `onAmbientModeChanged(boolean inAmbientMode)` Called when the device enters or exits ambient mode.
`Bundle` | `onCommand(String action, int x, int y, int z, Bundle extras, boolean resultRequested)`
`void` | `onCreate(SurfaceHolder holder)`
`void` | `onDestroy()`
`void` | `onInterruptionFilterChanged(int interruptionFilter)` Called when the user changes interruption filter.
`void` | `onNotificationCountChanged(int count)` Called when the total number of notification cards in the stream has changed.
`void` | `onPeekCardPositionUpdate(Rect rect)` Called when the first, peeking card positions itself on the screen.
`void` | `onPropertiesChanged(Bundle properties)` Called when the properties of the device are determined.
`void` | `onTapCommand(int tapType, int x, int y, long eventTime)` Called when a tap or touch related event occurs.
`void` | `onTimeTick()` Called periodically to update the time shown by the watch face.
`void` | `onUnreadCountChanged(int count)` Called when the number of unread notification cards in the stream has changed.
`void` | `onVisibilityChanged(boolean visible)` Called to inform you of the watch face becoming visible or hidden.
`void` | `setWatchFaceStyle(WatchFaceStyle watchFaceStyle)` Sets the watch face style.
From class `android.service.wallpaper.WallpaperService.Engine`
`void` | `dump(String arg0, FileDescriptor arg1, PrintWriter arg2, String[] arg3)`
`int` | `getDesiredMinimumHeight()`
`int` | `getDesiredMinimumWidth()`
`SurfaceHolder` | `getSurfaceHolder()`
`boolean` | `isPreview()`
`boolean` | `isVisible()`
`void` | `onApplyWindowInsets(WindowInsets arg0)`
`Bundle` | `onCommand(String arg0, int arg1, int arg2, int arg3, Bundle arg4, boolean arg5)`
`void` | `onCreate(SurfaceHolder arg0)`
`void` | `onDesiredSizeChanged(int arg0, int arg1)`
`void` | `onDestroy()`
`void` | `onOffsetsChanged(float arg0, float arg1, float arg2, float arg3, int arg4, int arg5)`
`void` | `onSurfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3)`
`void` | `onSurfaceCreated(SurfaceHolder arg0)`
`void` | `onSurfaceDestroyed(SurfaceHolder arg0)`
`void` | `onSurfaceRedrawNeeded(SurfaceHolder arg0)`
`void` | `onTouchEvent(MotionEvent arg0)`
`void` | `onVisibilityChanged(boolean arg0)`
`void` | `setFixedSizeAllowed(boolean arg0)`
`void` | `setOffsetNotificationsEnabled(boolean arg0)`
`void` | `setTouchEventsEnabled(boolean arg0)`
From class `java.lang.Object`
`Object` | `clone()`
`boolean` | `equals(Object arg0)`
`void` | `finalize()`
`final Class<?>` | `getClass()`
`int` | `hashCode()`
`final void` | `notify()`
`final void` | `notifyAll()`
`String` | `toString()`
`final void` | `wait(long arg0, int arg1)`
`final void` | `wait(long arg0)`
`final void` | `wait()`

## Public constructors

### Gles2WatchFaceService.Engine

    Gles2WatchFaceService.Engine ()

## Public methods

### chooseEglConfig

    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

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

Watch faces can override this method to call `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 `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

    EGLContext createEglContext (EGLDisplay eglDisplay,
                    EGLConfig eglConfig)

Creates the EGL context and returns it. By default, creates an EGL 2.0 context using `eglCreateContext(EGLDisplay, EGLConfig, EGLContext, int[], int)`.

Watch faces can override this method to call `eglCreateContext(EGLDisplay, EGLConfig, EGLContext, int[], int)` with different attributes.

Parameters
`eglDisplay` | `EGLDisplay`
`eglConfig` | `EGLConfig`

Returns
`EGLContext` |

### createWindowSurface

    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 `eglCreateWindowSurface(EGLDisplay, EGLConfig, Object, int[], int)` with different attributes.

Parameters
`eglDisplay` | `EGLDisplay`
`eglConfig` | `EGLConfig`
`surfaceHolder` | `SurfaceHolder`

Returns
`EGLSurface` |

### initializeEglDisplay

    EGLDisplay initializeEglDisplay ()

Initializes the display. Calls `eglGetDisplay(int)` and `eglInitialize(EGLDisplay, int[], int, int[], int)`.

Returns
`EGLDisplay` | the initialized EGLDisplay to use

### invalidate

    void invalidate ()

Schedules a call to `onDraw()` to draw the next frame. Must be called on the main thread.

### onApplyWindowInsets

    void onApplyWindowInsets (WindowInsets insets)

Parameters
`insets` | `WindowInsets`

### onCreate

    void onCreate (SurfaceHolder surfaceHolder)

Parameters
`surfaceHolder` | `SurfaceHolder`

### onDestroy

    void onDestroy ()

### onDraw

    void onDraw ()

Draws the watch face. It's safe to use GL APIs in this method.

### onGlContextCreated

    void onGlContextCreated ()

Called when a new GL context is created. It's safe to use GL APIs in this method.

### onGlSurfaceCreated

    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

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

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.

- ## Annotations

  - WatchFaceService.TapType

- ## Classes

  - CanvasWatchFaceService
  - CanvasWatchFaceService.Engine
  - Gles2WatchFaceService
  - Gles2WatchFaceService.Engine
  - WatchFaceService
  - WatchFaceService.Engine
  - WatchFaceStyle
  - WatchFaceStyle.Builder