Package 

Class OffscreenLayer


  • 
    public class OffscreenLayer
    
                        

    An OffscreenLayer encapsulates a "child surface" onto which canvas draw calls can be issued. At the end, the result of these draw calls will be composited onto the parent surface, with user-provided alpha, blend mode, color filter, and drop shadow.

    To use the OffscreenLayer, call its start() method with the necessary parameters, draw to the returned canvas, and then call finish() to composite the result onto the main canvas.

    In this sense, using an OffscreenLayer is very similar to the Canvas.saveLayer() family of functions, and in fact forwards to Canvas.saveLayer() when appropriate.

    Unlike Canvas.saveLayer(), an OffscreenLayer also supports compositing with a drop-shadow, and uses a hardware-accelerated target when available. It attempts to choose the fastest approach to render and composite the contents, up to and including simply rendering directly, if possible.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class OffscreenLayer.ComposeOp

      Encapsulates configuration for compositing the layer contents on the parent. Similar toPaint, but only includes operations that the OffscreenLayer can support.

    • Constructor Summary

      Constructors 
      Constructor Description
      OffscreenLayer()
    • Method Summary

      Modifier and Type Method Description
      Canvas start(Canvas parentCanvas, RectF bounds, OffscreenLayer.ComposeOp op)
      void finish()
      boolean finishDecrementsCanvasSaveCount() Whether calling finish() will decrement the save count of the [Canvas] returned by [start()].
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait