Interface CustomDrawable.DrawHandler

All Superinterfaces:
AutoCloseable
Enclosing interface:
CustomDrawable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface CustomDrawable.DrawHandler extends AutoCloseable
The engine backend is deferred so the handler will be given access to the 3D API at the correct point in the drawing stream as the engine backend flushes. Since the drawable may mutate, each time it is drawn to a Canvas a new handler is snapped, representing the drawable's state at the time of the snap.

When the engine backend flushes to the 3D API it will call the draw(icyllis.arc3d.engine.ImmediateContext, icyllis.arc3d.engine.DrawableInfo) on the DrawHandler. At this time the drawable may add commands to the stream of commands for the underlying 3D API. The draw function takes a DirectContext and a DrawableInfo which contains information about the current state of 3D API which the caller must respect. See DrawableInfo subclasses for more specific details on what information is sent and the requirements for different 3D APIs.

Additionally there may be a slight delay from when the drawable adds its commands to when those commands are actually submitted to the GPU. Thus the drawable or DrawHandler is required to keep any resources that are used by its added commands alive and valid until those commands are submitted to the driver. The DrawHandler will be kept alive and then closed once the commands are submitted to the driver. The close() of the DrawHandler is the signal to the drawable that the commands have all been submitted. Different 3D APIs may have additional requirements for certain resources which require waiting for the driver to finish all work on those resources before reusing or deleting them. In this case, the drawable can use the close call of the DrawHandler to add a fence to the GPU to track when the GPU work has completed.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    This is called when the draw call is submitted, used to clean up backend resources created along with this object.
    void
    The direct context may be used to invalidate backend context states.
  • Method Details

    • draw

      void draw(ImmediateContext dc, DrawableInfo info)
      The direct context may be used to invalidate backend context states.
      Parameters:
      dc - the direct context
      info - the backend specified info used to draw the drawable
    • close

      default void close()
      This is called when the draw call is submitted, used to clean up backend resources created along with this object.
      Specified by:
      close in interface AutoCloseable