Class Device

java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.core.Device
All Implemented Interfaces:
RefCounted
Direct Known Subclasses:
GraniteDevice, NoPixelsDevice, RasterDevice

public abstract class Device extends RefCnt
Base class for drawing devices.
  • Constructor Details

  • Method Details

    • deallocate

      protected void deallocate()
      Description copied from class: RefCnt
      Override this method to invoke de-allocation of the underlying resource.
      Specified by:
      deallocate in class RefCnt
    • getImageInfo

      @Nonnull public final ImageInfo getImageInfo()
      Return image info for this device.
    • getWidth

      public final int getWidth()
    • getHeight

      public final int getHeight()
    • getBounds

      public final Rect2ic getBounds()
      Returns:
      read-only bounds
    • getBounds

      public final void getBounds(@Nonnull Rect2i bounds)
      Return the bounds of the device in the coordinate space of this device.
    • getGlobalBounds

      public final void getGlobalBounds(@Nonnull Rect2i bounds)
      Return the bounds of the device in the coordinate space of the root canvas. The root device will have its top-left at 0,0, but other devices such as those associated with saveLayer may have a non-zero origin.
    • getLocalToDevice

      @Nonnull public final Matrix4c getLocalToDevice()
      Returns the transformation that maps from the local space to the device's coordinate space.
    • getLocalToDevice33

      @Nonnull public final Matrixc getLocalToDevice33()
      Returns the transformation that maps from the local space to the device's coordinate space.
    • getDeviceToGlobal

      @Nonnull public final Matrix4c getDeviceToGlobal()
      Return the device's coordinate space transform: this maps from the device's coordinate space into the global canvas' space (or root device space). This includes the translation necessary to account for the device's origin.
    • getGlobalToDevice

      @Nonnull public final Matrix4c getGlobalToDevice()
      Return the inverse of getDeviceToGlobal(), mapping from the global canvas' space (or root device space) into this device's coordinate space.
    • isPixelAlignedToGlobal

      public final boolean isPixelAlignedToGlobal()
      Returns true when this device's pixel grid is axis aligned with the global coordinate space, and any relative translation between the two spaces is in integer pixel units.
    • getRelativeTransform

      public final void getRelativeTransform(@Nonnull Device device, @Nonnull Matrix4 dest)
      Get the transformation from this device's coordinate system to the provided device space. This transform can be used to draw this device into the provided device, such that once that device is drawn to the root device, the net effect will be that this device's contents have been transformed by the global transform.
    • setGlobalCTM

      public final void setGlobalCTM(@Nonnull Matrix4c ctm)
    • setLocalToDevice

      public final void setLocalToDevice(@Nonnull Matrix4c localToDevice)
    • getRecordingContext

      @Nullable public RecordingContext getRecordingContext()
    • setDeviceCoordinateSystem

      protected final void setDeviceCoordinateSystem(@Nullable Matrix4c deviceToGlobal, @Nullable Matrix4c globalToDevice, @Nullable Matrix4c localToDevice, int bufferOriginX, int bufferOriginY)
      Configure the device's coordinate spaces, specifying both how its device image maps back to the global space (via 'deviceToGlobal') and the initial transform of the device (via 'localToDevice', i.e. what geometry drawn into this device will be transformed with).

      (bufferOriginX, bufferOriginY) defines where the (0,0) pixel the device's backing buffer is anchored in the device space. The final device-to-global matrix stored by the Device will include a pre-translation by T(deviceOriginX, deviceOriginY), and the final local-to-device matrix will have a post-translation of T(-deviceOriginX, -deviceOriginY).

    • pushClipStack

      public abstract void pushClipStack()
    • popClipStack

      public abstract void popClipStack()
    • getClipBounds

      public abstract void getClipBounds(@Nonnull Rect2i bounds)
      Returns the bounding box of the current clip, in this device's coordinate space. No pixels outside these bounds will be touched by draws unless the clip is further modified (at which point this will return the updated bounds).
    • getClipBounds

      protected abstract Rect2ic getClipBounds()
    • clipRect

      public abstract void clipRect(Rect2fc rect, int clipOp, boolean doAA)
    • isClipAA

      public abstract boolean isClipAA()
    • isClipEmpty

      public abstract boolean isClipEmpty()
    • isClipRect

      public abstract boolean isClipRect()
    • isClipWideOpen

      public abstract boolean isClipWideOpen()
    • drawPaint

      public abstract void drawPaint(Paint paint)
    • drawPoints

      public abstract void drawPoints(int mode, float[] pts, int offset, int count, Paint paint)
    • drawLine

      public abstract void drawLine(float x0, float y0, float x1, float y1, int cap, float width, Paint paint)
    • drawRect

      public abstract void drawRect(Rect2fc r, Paint paint)
    • drawRoundRect

      public abstract void drawRoundRect(RoundRect rr, Paint paint)
    • drawCircle

      public abstract void drawCircle(float cx, float cy, float radius, Paint paint)
    • drawArc

      public abstract void drawArc(float cx, float cy, float radius, float startAngle, float sweepAngle, int cap, float width, Paint paint)
    • drawPie

      public abstract void drawPie(float cx, float cy, float radius, float startAngle, float sweepAngle, Paint paint)
    • drawChord

      public abstract void drawChord(float cx, float cy, float radius, float startAngle, float sweepAngle, Paint paint)
    • drawImageRect

      public abstract void drawImageRect(@RawPtr @RawPtr Image image, Rect2fc src, Rect2fc dst, SamplingOptions sampling, Paint paint, int constraint)
    • drawGlyphRunList

      public final void drawGlyphRunList(Canvas canvas, GlyphRunList glyphRunList, Paint paint)
    • onDrawGlyphRunList

      protected abstract void onDrawGlyphRunList(Canvas canvas, GlyphRunList glyphRunList, Paint paint)
    • drawVertices

      public abstract void drawVertices(Vertices vertices, @SharedPtr @SharedPtr Blender blender, Paint paint)
    • makeSurface

      @Nullable protected Surface makeSurface(ImageInfo info)
    • createDevice

      @Nullable protected Device createDevice(ImageInfo info, @Nullable Paint paint)
      Create a new device based on CreateInfo. If the paint is not null, then it represents a preview of how the new device will be composed with its creator device (this).

      The subclass may be handed this device in drawDevice(), so it must always return a device that it knows how to draw, and that it knows how to identify if it is not of the same subclass (since drawDevice is passed a BaseDevice). If the subclass cannot fulfill that contract it should return null.