Class Picture

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Picture
    extends RefCnt
    • Constructor Detail

      • Picture

        @Internal
        public Picture​(long ptr)
    • 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,
                                @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 commands
        abort - 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
      • 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
      • 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 tiles
        localMatrix - 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 tiles
        localMatrix - Optional matrix used when sampling
        tileRect - 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)