Package icyllis.arc3d.sketch
Class Device
java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.sketch.Device
- All Implemented Interfaces:
RefCounted
- Direct Known Subclasses:
GraniteDevice,NoPixelsDevice,RasterDevice
Base class for drawing devices.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidprotected @Nullable DevicecreateDevice(ImageInfo info, @Nullable Paint paint) Create a new device based on CreateInfo.protected voidOverride this method to invoke de-allocation of the underlying resource.abstract voiddrawArc(float cx, float cy, float radius, float startAngle, float sweepAngle, int cap, float width, Paint paint) booleandrawBlurredRRect(RRect rr, Paint paint, float blurRadius, float noiseAlpha) abstract voidvoiddrawEdgeAAQuad(Rect2fc r, float[] clip, int flags, Paint paint) abstract voiddrawEllipse(float cx, float cy, float rx, float ry, Paint paint) final voiddrawGlyphRunList(Canvas canvas, GlyphRunList glyphRunList, Paint paint) abstract voiddrawImageRect(@RawPtr Image image, Rect2fc src, Rect2fc dst, SamplingOptions sampling, Paint paint, int constraint) abstract voidabstract voidabstract voidabstract voiddrawPoints(int mode, float[] pts, int offset, int count, Paint paint) abstract voidabstract voidabstract voiddrawVertices(Vertices vertices, Blender blender, Paint paint) final Rect2icfinal voidReturn the bounds of the device in the coordinate space of this device.protected abstract Rect2icabstract voidgetClipBounds(@NonNull Rect2i bounds) Returns the bounding box of the current clip, in this device's coordinate space.@Nullable Contextfinal @NonNull Matrix4cReturn the device's coordinate space transform: this maps from the device's coordinate space into the global canvas' space (or root device space).final voidgetGlobalBounds(@NonNull Rect2i bounds) Return the bounds of the device in the coordinate space of the root canvas.final @NonNull Matrix4cReturn the inverse of getDeviceToGlobal(), mapping from the global canvas' space (or root device space) into this device's coordinate space.final intfinal @NonNull ImageInfoReturn image info for this device.final @NonNull Matrix4cReturns the transformation that maps from the local space to the device's coordinate space.final @NonNull MatrixcReturns the transformation that maps from the local space to the device's coordinate space.final voidgetRelativeTransform(@NonNull Device device, @NonNull Matrix4 dest) Get the transformation from this device's coordinate system to the provided device space.final intgetWidth()abstract booleanisClipAA()abstract booleanabstract booleanabstract booleanfinal booleanReturns 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.protected @Nullable SurfacemakeSurface(ImageInfo info) protected abstract voidonDrawGlyphRunList(Canvas canvas, GlyphRunList glyphRunList, Paint paint) abstract voidabstract voidprotected final voidsetDeviceCoordinateSystem(@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.final voidsetGlobalCTM(@NonNull Matrix4c ctm) final voidsetLocalToDevice(@NonNull Matrix4c localToDevice)
-
Constructor Details
-
Device
-
-
Method Details
-
deallocate
protected void deallocate()Description copied from class:RefCntOverride this method to invoke de-allocation of the underlying resource.- Specified by:
deallocatein classRefCnt
-
getImageInfo
Return image info for this device. -
getWidth
public final int getWidth() -
getHeight
public final int getHeight() -
getBounds
- Returns:
- read-only bounds
-
getBounds
Return the bounds of the device in the coordinate space of this device. -
getGlobalBounds
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
Returns the transformation that maps from the local space to the device's coordinate space. -
getLocalToDevice33
Returns the transformation that maps from the local space to the device's coordinate space. -
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
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
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
-
setLocalToDevice
-
getCommandContext
-
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
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
-
clipRect
-
isClipAA
public abstract boolean isClipAA() -
isClipEmpty
public abstract boolean isClipEmpty() -
isClipRect
public abstract boolean isClipRect() -
isClipWideOpen
public abstract boolean isClipWideOpen() -
drawPaint
-
drawPoints
-
drawLine
public abstract void drawLine(float x0, float y0, float x1, float y1, int cap, float width, Paint paint) -
drawRect
-
drawRRect
-
drawEllipse
-
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
-
drawGlyphRunList
-
onDrawGlyphRunList
-
drawVertices
-
drawEdgeAAQuad
-
drawBlurredRRect
-
makeSurface
-
createDevice
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.
-