Class TrimbleMapsGLSurface

java.lang.Object
com.trimblemaps.mapsdk.maps.renderer.glsurfaceview.TrimbleMapsGLSurface

public class TrimbleMapsGLSurface extends Object
GLSurfaceView extension that notifies a listener when the view is detached from window, which is the point of destruction of the GL thread.
  • Field Details

    • glThread

      public com.trimblemaps.mapsdk.maps.renderer.glsurfaceview.TrimbleMapsGLSurface.GLThread glThread
    • mSurface

      public static android.view.Surface mSurface
  • Constructor Details

    • TrimbleMapsGLSurface

      public TrimbleMapsGLSurface(android.content.Context context)
      Standard View constructor. In order to render something, you must call setRenderer(android.opengl.GLSurfaceView.Renderer) to register a renderer.
    • TrimbleMapsGLSurface

      public TrimbleMapsGLSurface(android.content.Context context, android.view.Surface surface)
    • TrimbleMapsGLSurface

      public TrimbleMapsGLSurface(android.content.Context context, android.util.AttributeSet attrs)
      Standard View constructor. In order to render something, you must call setRenderer(android.opengl.GLSurfaceView.Renderer) to register a renderer.
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • setDetachedListener

      public void setDetachedListener(@NonNull TrimbleMapsGLSurface.OnGLSurfaceViewDetachedListener detachedListener)
      Set a listener that gets notified when the view is detached from window.
      Parameters:
      detachedListener - listener
    • setPreserveEGLContextOnPause

      public void setPreserveEGLContextOnPause(boolean preserveOnPause)
      Control whether the EGL context is preserved when the GLSurfaceView is paused and resumed.

      If set to true, then the EGL context may be preserved when the GLSurfaceView is paused.

      Prior to API level 11, whether the EGL context is actually preserved or not depends upon whether the Android device 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.

      Parameters:
      preserveOnPause - preserve the EGL context when paused
    • getPreserveEGLContextOnPause

      public boolean getPreserveEGLContextOnPause()
      Returns:
      true if the EGL context will be preserved when paused
    • setRenderer

      public void setRenderer(android.opengl.GLSurfaceView.Renderer renderer)
      Set the renderer associated with this view. Also starts the thread that will call the renderer, which in turn causes the rendering to start.

      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:

      The following GLSurfaceView methods can only be called after setRenderer is called:

      Parameters:
      renderer - the renderer to use to perform OpenGL drawing.
    • setEGLContextFactory

      public void setEGLContextFactory(android.opengl.GLSurfaceView.EGLContextFactory factory)
      Install a custom EGLContextFactory.

      If this method is called, it must be called before setRenderer(GLSurfaceView.Renderer) is called.

    • setEGLWindowSurfaceFactory

      public void setEGLWindowSurfaceFactory(android.opengl.GLSurfaceView.EGLWindowSurfaceFactory factory)
      Install a custom EGLWindowSurfaceFactory.

      If this method is called, it must be called before setRenderer(GLSurfaceView.Renderer) is called.

    • setEGLConfigChooser

      public void setEGLConfigChooser(android.opengl.GLSurfaceView.EGLConfigChooser configChooser)
      Install a custom EGLConfigChooser.

      If this method is called, it must be called before setRenderer(GLSurfaceView.Renderer) is called.

    • setRenderMode

      public void setRenderMode(int renderMode)
      Set the rendering mode. When renderMode is RENDERMODE_CONTINUOUSLY, the renderer is called repeatedly to re-render the scene. When renderMode is RENDERMODE_WHEN_DIRTY, the renderer only rendered when the surface is created, or when 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(GLSurfaceView.Renderer)

      Parameters:
      renderMode - one of the RENDERMODE_X constants
    • getRenderMode

      public int getRenderMode()
      Get the current rendering mode. May be called from any thread. Must not be called before a renderer has been set.
      Returns:
      the current rendering mode.
    • requestRender

      public void requestRender()
      Request that the renderer render a frame. This method is typically used when the render mode has been set to 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.
    • surfaceCreated

      public void surfaceCreated(android.view.SurfaceHolder holder)
      This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.
    • surfaceCreated

      public void surfaceCreated()
    • surfaceDestroyed

      public void surfaceDestroyed(android.view.SurfaceHolder holder)
      This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.
    • surfaceChanged

      public void surfaceChanged(android.view.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.
    • surfaceChanged

      public void surfaceChanged(int w, int h)
    • surfaceRedrawNeededAsync

      public void surfaceRedrawNeededAsync(android.view.SurfaceHolder holder, Runnable finishDrawing)
    • onPause

      public void onPause()
      Pause the rendering thread, optionally tearing down the EGL context depending upon the value of setPreserveEGLContextOnPause(boolean).

      Must not be called before a renderer has been set.

    • onResume

      public void onResume()
      Resumes the rendering thread, re-creating the OpenGL context if necessary. It is the counterpart to onPause().

      Must not be called before a renderer has been set.

    • queueEvent

      public void queueEvent(Runnable r)
      Queue a runnable to be run on the GL rendering thread. This can be used to communicate with the Renderer on the rendering thread. Must not be called before a renderer has been set.
      Parameters:
      r - the runnable to be run on the GL rendering thread.
    • waitForEmpty

      public long waitForEmpty(long timeoutMillis)
      Wait for the queue to become empty
      Parameters:
      timeoutMillis - Timeout in milliseconds
      Returns:
      Number of queue items remaining