Interface Shader

All Superinterfaces:
RefCounted
All Known Implementing Classes:
AngularGradient, BilinearGradient, BlendShader, ColorShader, EmptyShader, Gradient1DShader, Gradient2DShader, GradientShader, ImageShader, LinearGradient, LocalMatrixShader, RadialGradient, RRectShader

Shaders specify the source color(s) for what is being drawn. If a paint has no shader, then the paint's color is used. If the paint has a shader, then the shader's color(s) are use instead, but they are modulated by the paint's alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency w/o having to modify the original shader... only the paint's alpha needs to be modified.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Accepted by makeWithLocalMatrix(Matrixc, int), whether the specified matrix will be applied AFTER or BEFORE any matrix associated with this shader, or replace the matrix associated with this shader with the specified matrix.
    static final int
    Accepted by makeWithLocalMatrix(Matrixc, int), whether the specified matrix will be applied AFTER or BEFORE any matrix associated with this shader, or replace the matrix associated with this shader with the specified matrix.
    static final int
    Accepted by makeWithLocalMatrix(Matrixc, int), whether the specified matrix will be applied AFTER or BEFORE any matrix associated with this shader, or replace the matrix associated with this shader with the specified matrix.
    static final int
    Replicate the edge color if the shader draws outside of its original bounds.
    static final int
    Only draw within the original domain, return transparent-black everywhere else.
    static final int
    Repeat the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
    static final int
    Repeat the shader's image horizontally and vertically.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Returns true if the shader is guaranteed to produce only opaque colors, subject to the Paint using the shader to apply an opaque alpha value.
    default boolean
    A return value of true means that its ref/unref is unnecessary, for example, they are just no op.
    default @NonNull @SharedPtr Shader
    makeWithLocalMatrix(@NonNull Matrixc localMatrix, int mode)
    Creates a new shader that will apply the specified localMatrix to this shader.
    default void
    ref()
    Increases the reference count by 1.
    default void
    Decreases the reference count by 1.
  • Field Details

    • TILE_MODE_REPEAT

      static final int TILE_MODE_REPEAT
      Repeat the shader's image horizontally and vertically.
      See Also:
    • TILE_MODE_MIRROR

      static final int TILE_MODE_MIRROR
      Repeat the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
      See Also:
    • TILE_MODE_CLAMP

      static final int TILE_MODE_CLAMP
      Replicate the edge color if the shader draws outside of its original bounds.
      See Also:
    • TILE_MODE_DECAL

      static final int TILE_MODE_DECAL
      Only draw within the original domain, return transparent-black everywhere else.
      See Also:
    • LOCAL_MATRIX_AFTER

      static final int LOCAL_MATRIX_AFTER
      Accepted by makeWithLocalMatrix(Matrixc, int), whether the specified matrix will be applied AFTER or BEFORE any matrix associated with this shader, or replace the matrix associated with this shader with the specified matrix.
      See Also:
    • LOCAL_MATRIX_BEFORE

      static final int LOCAL_MATRIX_BEFORE
      Accepted by makeWithLocalMatrix(Matrixc, int), whether the specified matrix will be applied AFTER or BEFORE any matrix associated with this shader, or replace the matrix associated with this shader with the specified matrix.
      See Also:
    • LOCAL_MATRIX_REPLACE

      static final int LOCAL_MATRIX_REPLACE
      Accepted by makeWithLocalMatrix(Matrixc, int), whether the specified matrix will be applied AFTER or BEFORE any matrix associated with this shader, or replace the matrix associated with this shader with the specified matrix.
      See Also:
  • Method Details

    • isOpaque

      default boolean isOpaque()
      Returns true if the shader is guaranteed to produce only opaque colors, subject to the Paint using the shader to apply an opaque alpha value. Subclasses should override this to allow some optimizations.
    • makeWithLocalMatrix

      @SharedPtr default @NonNull @SharedPtr Shader makeWithLocalMatrix(@NonNull Matrixc localMatrix, int mode)
      Creates a new shader that will apply the specified localMatrix to this shader.
    • ref

      default void ref()
      Description copied from interface: RefCounted
      Increases the reference count by 1.
      Specified by:
      ref in interface RefCounted
    • unref

      default void unref()
      Description copied from interface: RefCounted
      Decreases the reference count by 1.
      Specified by:
      unref in interface RefCounted
    • isTriviallyCounted

      default boolean isTriviallyCounted()
      A return value of true means that its ref/unref is unnecessary, for example, they are just no op. So callers can perform some optimizations. Subclass can override this method to indicate that an instance is trivially counted. For the same instance, the return value of this method must remain unchanged.