Interface CarSurfaceCallback


public interface CarSurfaceCallback

The drawing surface callback for a CarNavigationTemplate. Navigation is the one in-car category that grants a pixel surface (for the moving map): on Android Auto an androidx.car.app.SurfaceCallback backed Surface, on CarPlay the CPMapTemplate's window. Codename One adapts that native surface to a com.codename1.ui.Graphics so the map can be drawn with the normal CN1 drawing primitives.

Only navigation apps holding the platform navigation entitlement (ios.carplay.navigation build hint on iOS; the androidx.car.app.category.NAVIGATION intent filter the builder injects on Android) receive these callbacks.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    renderSurface(Graphics g, int width, int height)
    Invoked when the surface should be (re)drawn.
    void
    surfaceAvailable(int width, int height)
    Invoked when the map surface becomes available or is resized.
    void
    Invoked when the surface is torn down (head unit disconnect, navigation ended).
    void
    visibleAreaChanged(int x, int y, int width, int height)
    Invoked when the visible (non-occluded) region of the surface changes, e.g.
  • Method Details

    • surfaceAvailable

      void surfaceAvailable(int width, int height)

      Invoked when the map surface becomes available or is resized. Cache the dimensions; the next renderSurface(Graphics, int, int) reflects them.

      Parameters
      • width: the surface width in pixels

      • height: the surface height in pixels

    • renderSurface

      void renderSurface(Graphics g, int width, int height)

      Invoked when the surface should be (re)drawn. Draw the map into the supplied graphics; the bridge blits the result to the native head-unit surface. Keep drawing cheap -- this is the car display refresh path.

      Parameters
      • g: graphics targeting an off-screen buffer the size of the surface

      • width: the surface width in pixels

      • height: the surface height in pixels

    • visibleAreaChanged

      void visibleAreaChanged(int x, int y, int width, int height)

      Invoked when the visible (non-occluded) region of the surface changes, e.g. when the head unit overlays panels. Centre critical map content (current position, next manoeuvre) within this rectangle.

      Parameters
      • x: left edge of the visible area, in pixels

      • y: top edge of the visible area, in pixels

      • width: width of the visible area, in pixels

      • height: height of the visible area, in pixels

    • surfaceDestroyed

      void surfaceDestroyed()
      Invoked when the surface is torn down (head unit disconnect, navigation ended). Release any cached buffers.