Class Picture
- java.lang.Object
-
- io.github.humbleui.skija.impl.Native
-
- io.github.humbleui.skija.impl.Managed
-
- io.github.humbleui.skija.impl.RefCnt
-
- io.github.humbleui.skija.Picture
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Picture extends RefCnt
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.RefCnt
RefCnt._FinalizerHolder
-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.Managed
Managed.CleanerThunk
-
-
Field Summary
-
Fields inherited from class io.github.humbleui.skija.impl.Managed
_cleanable
-
-
Constructor Summary
Constructors Constructor Description Picture(long ptr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static long_nGetApproximateBytesUsed(long ptr)static int_nGetApproximateOpCount(long ptr)static io.github.humbleui.types.Rect_nGetCullRect(long ptr)static int_nGetUniqueId(long ptr)static long_nMakeFromData(long dataPtr)static long_nMakePlaceholder(float left, float top, float right, float bottom)static long_nMakeShader(long ptr, int tmx, int tmy, int filterMode, float[] localMatrix, io.github.humbleui.types.Rect tileRect)static void_nPlayback(long ptr, long canvasPtr, @Nullable java.util.function.BooleanSupplier abort)static long_nSerializeToData(long ptr)longgetApproximateBytesUsed()Returns the approximate byte size of Picture.intgetApproximateOpCount()Returns the approximate number of operations in SkPicture.io.github.humbleui.types.RectgetCullRect()Returns cull Rect for this picture, passed in when Picture was created.intgetUniqueId()Returns a non-zero value unique among Picture in Skia process.static @Nullable PicturemakeFromData(Data data)Recreates Picture that was serialized into data.static PicturemakePlaceholder(@NotNull io.github.humbleui.types.Rect cull)Returns a placeholder Picture.@NotNull ShadermakeShader(@NotNull FilterTileMode tmx, @NotNull FilterTileMode tmy, @NotNull FilterMode mode)Return a new shader that will draw with this picture.@NotNull ShadermakeShader(@NotNull FilterTileMode tmx, @NotNull FilterTileMode tmy, @NotNull FilterMode mode, @Nullable Matrix33 localMatrix)Return a new shader that will draw with this picture.@NotNull ShadermakeShader(@NotNull FilterTileMode tmx, @NotNull FilterTileMode tmy, @NotNull FilterMode mode, @Nullable Matrix33 localMatrix, @Nullable io.github.humbleui.types.Rect tileRect)Return a new shader that will draw with this picture.Pictureplayback(Canvas canvas)Replays the drawing commands on the specified canvas.Pictureplayback(Canvas canvas, @Nullable java.util.function.BooleanSupplier abort)Replays the drawing commands on the specified canvas.DataserializeToData()-
Methods inherited from class io.github.humbleui.skija.impl.RefCnt
_nGetFinalizer, _nGetRefCount, getRefCount, toString
-
Methods inherited from class io.github.humbleui.skija.impl.Managed
_nInvokeFinalizer, close, isClosed
-
Methods inherited from class io.github.humbleui.skija.impl.Native
_nativeEquals, equals, getPtr, hashCode
-
-
-
-
Method Detail
-
makeFromData
@Nullable public static @Nullable Picture makeFromData(Data data)
Recreates Picture that was serialized into data. Returns constructed Picture if successful; otherwise, returns null. Fails if data does not permit constructing valid Picture.
-
playback
public Picture playback(Canvas canvas)
Replays the drawing commands on the specified canvas. In the case that the commands are recorded, each command in the Picture is sent separately to canvas.
To add a single command to draw Picture to recording canvas, call
Canvas.drawPicture(io.github.humbleui.skija.Picture)instead.- Parameters:
canvas- receiver of drawing commands- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Picture_playback
-
playback
public Picture playback(Canvas canvas, @Nullable @Nullable java.util.function.BooleanSupplier abort)
Replays the drawing commands on the specified canvas. In the case that the commands are recorded, each command in the Picture is sent separately to canvas.
To add a single command to draw Picture to recording canvas, call
Canvas.drawPicture(io.github.humbleui.skija.Picture)instead.- Parameters:
canvas- receiver of drawing commandsabort- return true to interrupt the playback- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Picture_playback
-
getCullRect
public io.github.humbleui.types.Rect getCullRect()
Returns cull Rect for this picture, passed in when Picture was created. Returned Rect does not specify clipping Rect for Picture; cull is hint of Picture bounds.
Picture is free to discard recorded drawing commands that fall outside cull.
- Returns:
- bounds passed when Picture was created
- See Also:
- https://fiddle.skia.org/c/@Picture_cullRect
-
getUniqueId
public int getUniqueId()
Returns a non-zero value unique among Picture in Skia process.- Returns:
- identifier for Picture
-
serializeToData
public Data serializeToData()
- Returns:
- storage containing Data describing Picture.
- See Also:
- https://fiddle.skia.org/c/@Picture_serialize
-
makePlaceholder
public static Picture makePlaceholder(@NotNull @NotNull io.github.humbleui.types.Rect cull)
Returns a placeholder Picture. Result does not draw, and contains only cull Rect, a hint of its bounds. Result is immutable; it cannot be changed later. Result identifier is unique.
Returned placeholder can be intercepted during playback to insert other commands into Canvas draw stream.
- Parameters:
cull- placeholder dimensions- Returns:
- placeholder with unique identifier
- See Also:
- https://fiddle.skia.org/c/@Picture_MakePlaceholder
-
getApproximateOpCount
public int getApproximateOpCount()
Returns the approximate number of operations in SkPicture. Returned value may be greater or less than the number of SkCanvas calls recorded: some calls may be recorded as more than one operation, other calls may be optimized away.- Returns:
- approximate operation count
- See Also:
- https://fiddle.skia.org/c/@Picture_approximateOpCount
-
getApproximateBytesUsed
public long getApproximateBytesUsed()
Returns the approximate byte size of Picture. Does not include large objects referenced by Picture.- Returns:
- approximate size
- See Also:
- https://fiddle.skia.org/c/@Picture_approximateBytesUsed
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tmx, @NotNull @NotNull FilterTileMode tmy, @NotNull @NotNull FilterMode mode)
Return a new shader that will draw with this picture. The tile rect is considered equal to the picture bounds.- Parameters:
tmx- The tiling mode to use when sampling in the x-direction.tmy- The tiling mode to use when sampling in the y-direction.mode- How to filter the tiles- Returns:
- Returns a new shader object. Note: this function never returns null.
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tmx, @NotNull @NotNull FilterTileMode tmy, @NotNull @NotNull FilterMode mode, @Nullable @Nullable Matrix33 localMatrix)
Return a new shader that will draw with this picture. The tile rect is considered equal to the picture bounds.- Parameters:
tmx- The tiling mode to use when sampling in the x-direction.tmy- The tiling mode to use when sampling in the y-direction.mode- How to filter the tileslocalMatrix- Optional matrix used when sampling- Returns:
- Returns a new shader object. Note: this function never returns null.
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tmx, @NotNull @NotNull FilterTileMode tmy, @NotNull @NotNull FilterMode mode, @Nullable @Nullable Matrix33 localMatrix, @Nullable @Nullable io.github.humbleui.types.Rect tileRect)
Return a new shader that will draw with this picture.- Parameters:
tmx- The tiling mode to use when sampling in the x-direction.tmy- The tiling mode to use when sampling in the y-direction.mode- How to filter the tileslocalMatrix- Optional matrix used when samplingtileRect- The tile rectangle in picture coordinates: this represents the subset (or superset) of the picture used when building a tile. It is not affected by localMatrix and does not imply scaling (only translation and cropping). If null, the tile rect is considered equal to the picture bounds.- Returns:
- Returns a new shader object. Note: this function never returns null.
-
_nMakeFromData
@Internal public static long _nMakeFromData(long dataPtr)
-
_nPlayback
@Internal public static void _nPlayback(long ptr, long canvasPtr, @Nullable @Nullable java.util.function.BooleanSupplier abort)
-
_nGetCullRect
@Internal public static io.github.humbleui.types.Rect _nGetCullRect(long ptr)
-
_nGetUniqueId
@Internal public static int _nGetUniqueId(long ptr)
-
_nSerializeToData
@Internal public static long _nSerializeToData(long ptr)
-
_nMakePlaceholder
@Internal public static long _nMakePlaceholder(float left, float top, float right, float bottom)
-
_nGetApproximateOpCount
@Internal public static int _nGetApproximateOpCount(long ptr)
-
_nGetApproximateBytesUsed
@Internal public static long _nGetApproximateBytesUsed(long ptr)
-
_nMakeShader
@Internal public static long _nMakeShader(long ptr, int tmx, int tmy, int filterMode, float[] localMatrix, io.github.humbleui.types.Rect tileRect)
-
-