Enum Class BlendMode

java.lang.Object
java.lang.Enum<BlendMode>
icyllis.arc3d.core.BlendMode
All Implemented Interfaces:
Blender, RefCounted, Serializable, Comparable<BlendMode>, Constable

public enum BlendMode extends Enum<BlendMode> implements Blender
Blend modes, all the blend equations apply to premultiplied colors. Source color refers to blend color or paint color, destination color refers to base color or canvas color (the color of the current render target).

Non-clamped blend modes ≤ MODULATE, plus SCREEN are Porter-Duff blend modes. They can be directly implemented by GPU hardware. The others are advanced blend equations, which need to be implemented in fragment shaders, or require an extension.

  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Destination pixels covered by the source are cleared to 0.
    Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.
    Makes destination darker to reflect source.
    Makes destination brighter to reflect source.
    Retains the smallest component of the source and destination pixels.
    Similar to DARKEN, but darkens on the composite channel, instead of separate RGB color channels.
    Subtracts darker from lighter with higher contrast.
    Divides the destination pixels by the source pixels and saturates the result.
    The source pixels are discarded, leaving the destination intact.
    Discards the destination pixels that are not covered by source pixels.
    Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.
    Keeps the destination pixels that are not covered by source pixels.
    The source pixels are drawn behind the destination pixels.
    Subtracts darker from lighter with lower contrast.
    Makes destination lighter or darker, depending on source.
    Adds two images together, setting each color channel value to either 0 or 1.
    Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.
    Retains the largest component of the source and destination pixel.
    Similar to LIGHTEN, but lightens on the composite channel, instead of separate RGB color channels.
    Darkens the destination pixels to reflect the source pixels while also increasing contrast.
    Lightens the destination pixels to reflect the source pixels while also increasing contrast.
    Burns or dodges colors by changing brightness, depending on the blend color.
    Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.
    Subtracts the source pixels from the destination pixels, without alpha blending.
    Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending.
    Multiplies the source and destination pixels, without alpha blending.
    Multiplies the source and destination pixels.
    Multiplies or screens the source and destination depending on the destination color.
    Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels.
    Adds the source pixels to the destination pixels, without alpha blending.
    Adds the source pixels to the destination pixels and saturates the result, without alpha blending.
    Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.
    Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.
    Makes destination lighter or darker, depending on source.
    The source pixels replace the destination pixels.
    Discards the source pixels that do not cover destination pixels.
    Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.
    Keeps the source pixels that do not cover destination pixels.
    The source pixels are drawn over the destination pixels.
    Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending.
    Burns or dodges colors by changing contrast, depending on the blend color.
    Discards the source and destination pixels where source pixels cover destination pixels.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BlendMode
    Name alias of LINEAR_DODGE.
    static final int
    Number of blend modes, runtime constant.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    apply(float[] src, float[] dst, float[] out)
    Applies this blend mode with RGBA colors.
    Returns the blender's BlendMode in 'mode' if this Blender represents any BlendMode.
    static void
    blend_color(float[] src, float[] dst, float[] out)
    Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.
    static void
    blend_color_burn(float[] src, float[] dst, float[] out)
    Makes destination darker to reflect source.
    static void
    blend_color_dodge(float[] src, float[] dst, float[] out)
    Makes destination brighter to reflect source.
    static void
    blend_darken(float[] src, float[] dst, float[] out)
    Retains the smallest component of the source and destination pixels.
    static void
    blend_darker_color(float[] src, float[] dst, float[] out)
    Similar to DARKEN, but darkens on the composite channel, instead of separate RGB color channels.
    static void
    blend_difference(float[] src, float[] dst, float[] out)
    Subtracts darker from lighter with higher contrast.
    static void
    blend_divide(float[] src, float[] dst, float[] out)
    Divides the destination pixels by the source pixels and saturates the result.
    static void
    blend_dst_atop(float[] src, float[] dst, float[] out)
     
    static void
    blend_dst_in(float[] src, float[] dst, float[] out)
     
    static void
    blend_dst_out(float[] src, float[] dst, float[] out)
     
    static void
    blend_dst_over(float[] src, float[] dst, float[] out)
     
    static void
    blend_exclusion(float[] src, float[] dst, float[] out)
    Subtracts darker from lighter with lower contrast.
    static void
    blend_hard_light(float[] src, float[] dst, float[] out)
    Makes destination lighter or darker, depending on source.
    static void
    blend_hard_mix(float[] src, float[] dst, float[] out)
    Adds two images together, setting each color channel value to either 0 or 1.
    static void
    blend_hue(float[] src, float[] dst, float[] out)
    Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.
    static void
    blend_lighten(float[] src, float[] dst, float[] out)
    Retains the largest component of the source and destination pixel.
    static void
    blend_lighter_color(float[] src, float[] dst, float[] out)
    Similar to LIGHTEN, but lightens on the composite channel, instead of separate RGB color channels.
    static void
    blend_linear_burn(float[] src, float[] dst, float[] out)
    Darkens the destination pixels to reflect the source pixels while also increasing contrast.
    static void
    blend_linear_dodge(float[] src, float[] dst, float[] out)
    Lightens the destination pixels to reflect the source pixels while also increasing contrast.
    static void
    blend_linear_light(float[] src, float[] dst, float[] out)
    Burns or dodges colors by changing brightness, depending on the blend color.
    static void
    blend_luminosity(float[] src, float[] dst, float[] out)
    Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.
    static void
    blend_minus(float[] src, float[] dst, float[] out)
    Subtracts the source pixels from the destination pixels, without alpha blending.
    static void
    blend_minus_clamped(float[] src, float[] dst, float[] out)
    Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending.
    static void
    blend_modulate(float[] src, float[] dst, float[] out)
    Multiplies the source and destination pixels, without alpha blending.
    static void
    blend_multiply(float[] src, float[] dst, float[] out)
    Multiplies the source and destination pixels.
    static void
    blend_overlay(float[] src, float[] dst, float[] out)
    Multiplies or screens the source and destination depending on the destination color.
    static void
    blend_pin_light(float[] src, float[] dst, float[] out)
    Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels.
    static void
    blend_plus(float[] src, float[] dst, float[] out)
    Adds the source pixels to the destination pixels, without alpha blending.
    static void
    blend_plus_clamped(float[] src, float[] dst, float[] out)
    Adds the source pixels to the destination pixels and saturates the result, without alpha blending.
    static void
    blend_saturation(float[] src, float[] dst, float[] out)
    Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.
    static void
    blend_screen(float[] src, float[] dst, float[] out)
    Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.
    static void
    blend_soft_light(float[] src, float[] dst, float[] out)
    Makes destination lighter or darker, depending on source.
    static void
    blend_src_atop(float[] src, float[] dst, float[] out)
     
    static void
    blend_src_in(float[] src, float[] dst, float[] out)
     
    static void
    blend_src_out(float[] src, float[] dst, float[] out)
     
    static void
    blend_src_over(float[] src, float[] dst, float[] out)
     
    static void
    blend_subtract(float[] src, float[] dst, float[] out)
    Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending.
    static void
    blend_vivid_light(float[] src, float[] dst, float[] out)
    Burns or dodges colors by changing contrast, depending on the blend color.
    static void
    blend_xor(float[] src, float[] dst, float[] out)
     
    Returns the name of blend function.
    boolean
    25 blend modes after MULTIPLY are advanced.
    static BlendMode
    modeAt(int index)
    Returns the value at the given index.
    void
    ref()
    Increases the reference count by 1.
    void
    Decreases the reference count by 1.
    static BlendMode
    Returns the enum constant of this class with the specified name.
    static BlendMode[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • CLEAR

      public static final BlendMode CLEAR

      Destination pixels covered by the source are cleared to 0.

      aout = 0

      Cout = 0

    • SRC

      public static final BlendMode SRC

      The source pixels replace the destination pixels.

      aout = asrc

      Cout = Csrc

    • DST

      public static final BlendMode DST

      The source pixels are discarded, leaving the destination intact.

      aout = adst

      Cout = Cdst

    • SRC_OVER

      public static final BlendMode SRC_OVER

      The source pixels are drawn over the destination pixels.

      aout = asrc + (1 - asrc) * adst

      Cout = Csrc + (1 - asrc) * Cdst

    • DST_OVER

      public static final BlendMode DST_OVER

      The source pixels are drawn behind the destination pixels.

      aout = adst + (1 - adst) * asrc

      Cout = Cdst + (1 - adst) * Csrc

    • SRC_IN

      public static final BlendMode SRC_IN

      Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.

      aout = asrc * adst

      Cout = Csrc * adst

    • DST_IN

      public static final BlendMode DST_IN

      Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.

      aout = adst * asrc

      Cout = Cdst * asrc

    • SRC_OUT

      public static final BlendMode SRC_OUT

      Keeps the source pixels that do not cover destination pixels. Discards source pixels that cover destination pixels. Discards all destination pixels.

      aout = (1 - adst) * asrc

      Cout = (1 - adst) * Csrc

    • DST_OUT

      public static final BlendMode DST_OUT

      Keeps the destination pixels that are not covered by source pixels. Discards destination pixels that are covered by source pixels. Discards all source pixels.

      aout = (1 - asrc) * adst

      Cout = (1 - asrc) * Cdst

    • SRC_ATOP

      public static final BlendMode SRC_ATOP

      Discards the source pixels that do not cover destination pixels. Draws remaining source pixels over destination pixels.

      aout = adst

      Cout = adst * Csrc + (1 - asrc) * Cdst

    • DST_ATOP

      public static final BlendMode DST_ATOP

      Discards the destination pixels that are not covered by source pixels. Draws remaining destination pixels over source pixels.

      aout = asrc

      Cout = asrc * Cdst + (1 - adst) * Csrc

    • XOR

      public static final BlendMode XOR

      Discards the source and destination pixels where source pixels cover destination pixels. Draws remaining source pixels.

      aout = (1 - adst) * asrc + (1 - asrc) * adst

      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    • PLUS

      public static final BlendMode PLUS

      Adds the source pixels to the destination pixels, without alpha blending. For floating-point textures, color components may be greater than 1.0.

      aout = asrc + adst

      Cout = Csrc + Cdst

      See Also:
    • PLUS_CLAMPED

      public static final BlendMode PLUS_CLAMPED

      Adds the source pixels to the destination pixels and saturates the result, without alpha blending. For unsigned fixed-point textures, this is the same as PLUS. This is a special blend equation.

      aout = max(0, min(asrc + adst, 1))

      Cout = max(0, min(Csrc + Cdst, 1))

      See Also:
    • MINUS

      public static final BlendMode MINUS

      Subtracts the source pixels from the destination pixels, without alpha blending. For floating-point textures, color components may be less than 0.0.

      aout = adst - asrc

      Cout = Cdst - Csrc

      See Also:
    • MINUS_CLAMPED

      public static final BlendMode MINUS_CLAMPED

      Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending. For unsigned fixed-point textures, this is the same as MINUS. This is a special blend equation.

      aout = max(0, min(adst - asrc, 1))

      Cout = max(0, min(Cdst - Csrc, 1))

      See Also:
    • MODULATE

      public static final BlendMode MODULATE

      Multiplies the source and destination pixels, without alpha blending.

      aout = asrc * adst

      Cout = Csrc * Cdst

      See Also:
    • MULTIPLY

      public static final BlendMode MULTIPLY

      Multiplies the source and destination pixels. This is MODULATE with alpha blending. If both the source and destination are opaque, then this is the same as MODULATE. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      See Also:
    • SCREEN

      public static final BlendMode SCREEN

      Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.

      aout = asrc + adst - asrc * adst

      Cout = Csrc + Cdst - Csrc * Cdst

    • OVERLAY

      public static final BlendMode OVERLAY

      Multiplies or screens the source and destination depending on the destination color. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst ≤ 0.5 * adst:
      Cout = 2 * Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * adst - 2 * (asrc - Csrc) * (adst - Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • DARKEN

      public static final BlendMode DARKEN

      Retains the smallest component of the source and destination pixels. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = min(Csrc / asrc, Cdst / adst) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • LIGHTEN

      public static final BlendMode LIGHTEN

      Retains the largest component of the source and destination pixel. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = max(Csrc / asrc, Cdst / adst) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • COLOR_DODGE

      public static final BlendMode COLOR_DODGE

      Makes destination brighter to reflect source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst ≤ 0:
      Cout = Csrc * (1 - adst)

      if Csrc ≥ asrc:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * min(adst, Cdst * asrc / (asrc - Csrc)) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • COLOR_BURN

      public static final BlendMode COLOR_BURN

      Makes destination darker to reflect source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst ≥ adst:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if Csrc ≤ 0:
      Cout = Cdst * (1 - asrc)

      otherwise:
      Cout = asrc * (adst - min(adst, (adst - Cdst) * asrc / Cdst)) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • HARD_LIGHT

      public static final BlendMode HARD_LIGHT

      Makes destination lighter or darker, depending on source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc ≤ 0.5 * asrc:
      Cout = 2 * Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * adst - 2 * (asrc - Csrc) * (adst - Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • SOFT_LIGHT

      public static final BlendMode SOFT_LIGHT

      Makes destination lighter or darker, depending on source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc ≤ 0.5 * asrc:
      Cout = Cdst * Cdst * (asrc - 2 * Csrc) / adst + (1 - adst) * Csrc + Cdst * (2 * Csrc + 1 - asrc)

      if Cdst ≤ 0.25 * adst:
      Cout = (adst * adst * (Csrc + Cdst * (6 * Csrc - 3 * asrc + 1)) + 12 * adst * Cdst * Cdst * (asrc - 2 * Csrc) - 16 * Cdst * Cdst * Cdst * (asrc - 2 * Csrc) - adst * adst * adst * Csrc) / adst * adst

      otherwise:
      Cout = Cdst * (asrc - 2 * Csrc + 1) + Csrc * (1 - adst) - sqrt(Cdst * adst) * (asrc - 2 * Csrc)

    • DIFFERENCE

      public static final BlendMode DIFFERENCE

      Subtracts darker from lighter with higher contrast. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = Csrc + Cdst - 2 * min(Csrc * adst, Cdst * asrc)

    • EXCLUSION

      public static final BlendMode EXCLUSION

      Subtracts darker from lighter with lower contrast. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = Csrc + Cdst - 2 * Csrc * Cdst

    • SUBTRACT

      public static final BlendMode SUBTRACT

      Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending. If both the source and destination are opaque, then this is the same as MINUS_CLAMPED. This is a custom blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst / adst - Csrc / asrc ≥ 0:
      Cout = Csrc + Cdst - 2 * Csrc * adst

      otherwise:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      See Also:
    • DIVIDE

      public static final BlendMode DIVIDE

      Divides the destination pixels by the source pixels and saturates the result. For negative and NaN values, the result color is black (XOR). This is a custom blend equation.

      aout = asrc + adst - asrc * adst

      Cout = pin((Cdst * asrc) / (Csrc * adst), 0, 1) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • LINEAR_DODGE

      public static final BlendMode LINEAR_DODGE

      Lightens the destination pixels to reflect the source pixels while also increasing contrast. This is PLUS_CLAMPED with alpha blending. If both the source and destination are opaque, then this is the same as PLUS_CLAMPED. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc / asrc + Cdst / adst ≤ 1:
      Cout = Csrc + Cdst

      otherwise:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      See Also:
    • LINEAR_BURN

      public static final BlendMode LINEAR_BURN

      Darkens the destination pixels to reflect the source pixels while also increasing contrast. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc / asrc + Cdst / adst > 1:
      Cout = Csrc + Cdst - asrc * adst

      otherwise:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    • VIVID_LIGHT

      public static final BlendMode VIVID_LIGHT

      Burns or dodges colors by changing contrast, depending on the blend color. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc ≤ 0:
      Cout = Cdst * (1 - asrc)

      if Csrc < 0.5 * asrc:
      Cout = asrc * (adst - min(adst, (adst - Cdst) * asrc / (2 * Cdst))) + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if Csrc ≥ asrc:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * min(adst, Cdst * asrc / (2 * (asrc - Csrc))) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • LINEAR_LIGHT

      public static final BlendMode LINEAR_LIGHT

      Burns or dodges colors by changing brightness, depending on the blend color. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if 2 * Csrc / asrc + Cdst / adst > 2:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if 2 * Csrc / asrc + Cdst / adst ≤ 1:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = 2 * Csrc * adst + Cdst * asrc - asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • PIN_LIGHT

      public static final BlendMode PIN_LIGHT

      Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if 2 * Csrc / asrc - Cdst / adst > 1 && Csrc < 0.5 * asrc:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      if 2 * Csrc / asrc - Cdst / adst > 1 && Csrc ≥ 0.5 * asrc:
      Cout = 2 * Csrc * adst - asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if 2 * Csrc / asrc - Cdst / adst ≤ 1 && Csrc * adst < 0.5 * Cdst * asrc:
      Cout = 2 * Csrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = Cdst * asrc + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • HARD_MIX

      public static final BlendMode HARD_MIX

      Adds two images together, setting each color channel value to either 0 or 1. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc / asrc + Cdst / adst < 1:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • DARKER_COLOR

      public static final BlendMode DARKER_COLOR

      Similar to DARKEN, but darkens on the composite channel, instead of separate RGB color channels. It compares the source and destination color, and keep the one with lower luminosity between the two.

      if lum(Csrc) ≤ lum(Cdst):
      Equivalent to SRC_OVER

      otherwise:
      Equivalent to DST_OVER

    • LIGHTER_COLOR

      public static final BlendMode LIGHTER_COLOR

      Similar to LIGHTEN, but lightens on the composite channel, instead of separate RGB color channels. It compares the source and destination color, and keep the one with higher luminosity between the two.

      if lum(Csrc) ≥ lum(Cdst):
      Equivalent to SRC_OVER

      otherwise:
      Equivalent to DST_OVER

    • HUE

      public static final BlendMode HUE

      Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged. This is an advanced blend equation.

    • SATURATION

      public static final BlendMode SATURATION

      Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged. This is an advanced blend equation.

    • COLOR

      public static final BlendMode COLOR

      Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged. This is an advanced blend equation.

    • LUMINOSITY

      public static final BlendMode LUMINOSITY

      Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged. This is an advanced blend equation.

  • Field Details

    • ADD

      public static final BlendMode ADD
      Name alias of LINEAR_DODGE.
    • COUNT

      public static final int COUNT
      Number of blend modes, runtime constant.
  • Method Details

    • values

      public static BlendMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BlendMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • modeAt

      @Nonnull public static BlendMode modeAt(int index)
      Returns the value at the given index. This method can only be used at runtime, the return value does not guarantee binary compatibility.
      Parameters:
      index - the Enum.ordinal()
      Returns:
      the blend mode
    • ref

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

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

      public BlendMode asBlendMode()
      Description copied from interface: Blender
      Returns the blender's BlendMode in 'mode' if this Blender represents any BlendMode. Returns null for other types of blends.
      Specified by:
      asBlendMode in interface Blender
    • isAdvanced

      public boolean isAdvanced()
      25 blend modes after MULTIPLY are advanced.

      Advanced blend modes are not directly supported by 3D API, they will be implemented with custom fragment shader code and DST read (via texture barrier, input attachment, or image copy). Advanced blend modes should be avoided for operations other than layer compositing. All advanced blend modes are SrcOver-like, then they are alpha conservative.

      1. MULTIPLY
      2. SCREEN
      3. OVERLAY
      4. DARKEN
      5. LIGHTEN
      6. COLOR_DODGE
      7. COLOR_BURN
      8. HARD_LIGHT
      9. SOFT_LIGHT
      10. DIFFERENCE
      11. EXCLUSION
      12. SUBTRACT
      13. DIVIDE
      14. LINEAR_DODGE
      15. LINEAR_BURN
      16. VIVID_LIGHT
      17. LINEAR_LIGHT
      18. PIN_LIGHT
      19. HARD_MIX
      20. DARKER_COLOR
      21. LIGHTER_COLOR
      22. HUE
      23. SATURATION
      24. COLOR
      25. LUMINOSITY
    • getBlendFuncName

      public String getBlendFuncName()
      Returns the name of blend function.

      Raster pipeline implementation and shader implementation must be consistent with this.

    • apply

      public final void apply(@Size(4L) float[] src, @Size(4L) float[] dst, @Size(4L) float[] out)
      Applies this blend mode with RGBA colors. src, dst and out store premultiplied R,G,B,A components from index 0 to 3. src, dst and out can be the same pointer. src and dst are read-only, out may be written multiple times.

      This method is mainly used for blending solid colors without using shader code.

      This method is final to avoid generating too many anonymous classes.

    • blend_src_over

      public static void blend_src_over(float[] src, float[] dst, float[] out)
    • blend_dst_over

      public static void blend_dst_over(float[] src, float[] dst, float[] out)
    • blend_src_in

      public static void blend_src_in(float[] src, float[] dst, float[] out)
    • blend_dst_in

      public static void blend_dst_in(float[] src, float[] dst, float[] out)
    • blend_src_out

      public static void blend_src_out(float[] src, float[] dst, float[] out)
    • blend_dst_out

      public static void blend_dst_out(float[] src, float[] dst, float[] out)
    • blend_src_atop

      public static void blend_src_atop(float[] src, float[] dst, float[] out)
    • blend_dst_atop

      public static void blend_dst_atop(float[] src, float[] dst, float[] out)
    • blend_xor

      public static void blend_xor(float[] src, float[] dst, float[] out)
    • blend_plus

      public static void blend_plus(float[] src, float[] dst, float[] out)

      Adds the source pixels to the destination pixels, without alpha blending. For floating-point textures, color components may be greater than 1.0.

      aout = asrc + adst

      Cout = Csrc + Cdst

    • blend_plus_clamped

      public static void blend_plus_clamped(float[] src, float[] dst, float[] out)

      Adds the source pixels to the destination pixels and saturates the result, without alpha blending. For unsigned fixed-point textures, this is the same as PLUS. This is a special blend equation.

      aout = max(0, min(asrc + adst, 1))

      Cout = max(0, min(Csrc + Cdst, 1))

    • blend_minus

      public static void blend_minus(float[] src, float[] dst, float[] out)

      Subtracts the source pixels from the destination pixels, without alpha blending. For floating-point textures, color components may be less than 0.0.

      aout = adst - asrc

      Cout = Cdst - Csrc

    • blend_minus_clamped

      public static void blend_minus_clamped(float[] src, float[] dst, float[] out)

      Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending. For unsigned fixed-point textures, this is the same as MINUS. This is a special blend equation.

      aout = max(0, min(adst - asrc, 1))

      Cout = max(0, min(Cdst - Csrc, 1))

    • blend_modulate

      public static void blend_modulate(float[] src, float[] dst, float[] out)

      Multiplies the source and destination pixels, without alpha blending.

      aout = asrc * adst

      Cout = Csrc * Cdst

    • blend_multiply

      public static void blend_multiply(float[] src, float[] dst, float[] out)

      Multiplies the source and destination pixels. This is MODULATE with alpha blending. If both the source and destination are opaque, then this is the same as MODULATE. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_screen

      public static void blend_screen(float[] src, float[] dst, float[] out)

      Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.

      aout = asrc + adst - asrc * adst

      Cout = Csrc + Cdst - Csrc * Cdst

    • blend_overlay

      public static void blend_overlay(float[] src, float[] dst, float[] out)

      Multiplies or screens the source and destination depending on the destination color. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst ≤ 0.5 * adst:
      Cout = 2 * Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * adst - 2 * (asrc - Csrc) * (adst - Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_darken

      public static void blend_darken(float[] src, float[] dst, float[] out)

      Retains the smallest component of the source and destination pixels. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = min(Csrc / asrc, Cdst / adst) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_lighten

      public static void blend_lighten(float[] src, float[] dst, float[] out)

      Retains the largest component of the source and destination pixel. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = max(Csrc / asrc, Cdst / adst) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_color_dodge

      public static void blend_color_dodge(float[] src, float[] dst, float[] out)

      Makes destination brighter to reflect source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst ≤ 0:
      Cout = Csrc * (1 - adst)

      if Csrc ≥ asrc:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * min(adst, Cdst * asrc / (asrc - Csrc)) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_color_burn

      public static void blend_color_burn(float[] src, float[] dst, float[] out)

      Makes destination darker to reflect source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst ≥ adst:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if Csrc ≤ 0:
      Cout = Cdst * (1 - asrc)

      otherwise:
      Cout = asrc * (adst - min(adst, (adst - Cdst) * asrc / Cdst)) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_hard_light

      public static void blend_hard_light(float[] src, float[] dst, float[] out)

      Makes destination lighter or darker, depending on source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc ≤ 0.5 * asrc:
      Cout = 2 * Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * adst - 2 * (asrc - Csrc) * (adst - Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_soft_light

      public static void blend_soft_light(float[] src, float[] dst, float[] out)

      Makes destination lighter or darker, depending on source. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc ≤ 0.5 * asrc:
      Cout = Cdst * Cdst * (asrc - 2 * Csrc) / adst + (1 - adst) * Csrc + Cdst * (2 * Csrc + 1 - asrc)

      if Cdst ≤ 0.25 * adst:
      Cout = (adst * adst * (Csrc + Cdst * (6 * Csrc - 3 * asrc + 1)) + 12 * adst * Cdst * Cdst * (asrc - 2 * Csrc) - 16 * Cdst * Cdst * Cdst * (asrc - 2 * Csrc) - adst * adst * adst * Csrc) / adst * adst

      otherwise:
      Cout = Cdst * (asrc - 2 * Csrc + 1) + Csrc * (1 - adst) - sqrt(Cdst * adst) * (asrc - 2 * Csrc)

    • blend_difference

      public static void blend_difference(float[] src, float[] dst, float[] out)

      Subtracts darker from lighter with higher contrast. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = Csrc + Cdst - 2 * min(Csrc * adst, Cdst * asrc)

    • blend_exclusion

      public static void blend_exclusion(float[] src, float[] dst, float[] out)

      Subtracts darker from lighter with lower contrast. This is an advanced blend equation.

      aout = asrc + adst - asrc * adst

      Cout = Csrc + Cdst - 2 * Csrc * Cdst

    • blend_subtract

      public static void blend_subtract(float[] src, float[] dst, float[] out)

      Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending. If both the source and destination are opaque, then this is the same as MINUS_CLAMPED. This is a custom blend equation.

      aout = asrc + adst - asrc * adst

      if Cdst / adst - Csrc / asrc ≥ 0:
      Cout = Csrc + Cdst - 2 * Csrc * adst

      otherwise:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_divide

      public static void blend_divide(float[] src, float[] dst, float[] out)

      Divides the destination pixels by the source pixels and saturates the result. For negative and NaN values, the result color is black (XOR). This is a custom blend equation.

      aout = asrc + adst - asrc * adst

      Cout = pin((Cdst * asrc) / (Csrc * adst), 0, 1) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_linear_dodge

      public static void blend_linear_dodge(float[] src, float[] dst, float[] out)

      Lightens the destination pixels to reflect the source pixels while also increasing contrast. This is PLUS_CLAMPED with alpha blending. If both the source and destination are opaque, then this is the same as PLUS_CLAMPED. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc / asrc + Cdst / adst ≤ 1:
      Cout = Csrc + Cdst

      otherwise:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_linear_burn

      public static void blend_linear_burn(float[] src, float[] dst, float[] out)

      Darkens the destination pixels to reflect the source pixels while also increasing contrast. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc / asrc + Cdst / adst > 1:
      Cout = Csrc + Cdst - asrc * adst

      otherwise:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_vivid_light

      public static void blend_vivid_light(float[] src, float[] dst, float[] out)

      Burns or dodges colors by changing contrast, depending on the blend color. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc ≤ 0:
      Cout = Cdst * (1 - asrc)

      if Csrc < 0.5 * asrc:
      Cout = asrc * (adst - min(adst, (adst - Cdst) * asrc / (2 * Cdst))) + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if Csrc ≥ asrc:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * min(adst, Cdst * asrc / (2 * (asrc - Csrc))) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_linear_light

      public static void blend_linear_light(float[] src, float[] dst, float[] out)

      Burns or dodges colors by changing brightness, depending on the blend color. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if 2 * Csrc / asrc + Cdst / adst > 2:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if 2 * Csrc / asrc + Cdst / adst ≤ 1:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = 2 * Csrc * adst + Cdst * asrc - asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_pin_light

      public static void blend_pin_light(float[] src, float[] dst, float[] out)

      Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if 2 * Csrc / asrc - Cdst / adst > 1 && Csrc < 0.5 * asrc:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      if 2 * Csrc / asrc - Cdst / adst > 1 && Csrc ≥ 0.5 * asrc:
      Cout = 2 * Csrc * adst - asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      if 2 * Csrc / asrc - Cdst / adst ≤ 1 && Csrc * adst < 0.5 * Cdst * asrc:
      Cout = 2 * Csrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = Cdst * asrc + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_hard_mix

      public static void blend_hard_mix(float[] src, float[] dst, float[] out)

      Adds two images together, setting each color channel value to either 0 or 1. This is an extended advanced blend equation.

      aout = asrc + adst - asrc * adst

      if Csrc / asrc + Cdst / adst < 1:
      Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

      otherwise:
      Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    • blend_darker_color

      public static void blend_darker_color(float[] src, float[] dst, float[] out)

      Similar to DARKEN, but darkens on the composite channel, instead of separate RGB color channels. It compares the source and destination color, and keep the one with lower luminosity between the two.

      if lum(Csrc) ≤ lum(Cdst):
      Equivalent to SRC_OVER

      otherwise:
      Equivalent to DST_OVER

    • blend_lighter_color

      public static void blend_lighter_color(float[] src, float[] dst, float[] out)

      Similar to LIGHTEN, but lightens on the composite channel, instead of separate RGB color channels. It compares the source and destination color, and keep the one with higher luminosity between the two.

      if lum(Csrc) ≥ lum(Cdst):
      Equivalent to SRC_OVER

      otherwise:
      Equivalent to DST_OVER

    • blend_hue

      public static void blend_hue(float[] src, float[] dst, float[] out)

      Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged. This is an advanced blend equation.

    • blend_saturation

      public static void blend_saturation(float[] src, float[] dst, float[] out)

      Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged. This is an advanced blend equation.

    • blend_color

      public static void blend_color(float[] src, float[] dst, float[] out)

      Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged. This is an advanced blend equation.

    • blend_luminosity

      public static void blend_luminosity(float[] src, float[] dst, float[] out)

      Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged. This is an advanced blend equation.