Class Pixels

java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.core.Pixels
All Implemented Interfaces:
RefCounted

public class Pixels extends RefCnt
This class is the smart container for pixel memory.
This class may be shared/accessed between multiple threads.
  • Field Details

    • mWidth

      protected final int mWidth
    • mHeight

      protected final int mHeight
    • mBase

      protected final Object mBase
    • mAddress

      protected final long mAddress
    • mRowBytes

      protected final int mRowBytes
    • mFreeFn

      protected final LongConsumer mFreeFn
    • mImmutable

      protected boolean mImmutable
  • Constructor Details

    • Pixels

      public Pixels(int width, int height, @Nullable Object base, long address, int rowBytes, @Nullable LongConsumer freeFn)
      Creates Pixels from width, height. rowBytes should be width times bpp, or larger. freeFn is used to free the address.
      Parameters:
      base - array if heap buffer; may be null
      address - address if native buffer, or array base offset; may be NULL
      rowBytes - size of one row of buffer; width times bpp, or larger
      freeFn - free function for native buffer; may be null
  • Method Details

    • deallocate

      protected void deallocate()
      Description copied from class: RefCnt
      Override this method to invoke de-allocation of the underlying resource.
      Specified by:
      deallocate in class RefCnt
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getBase

      @Nullable public Object getBase()
      The array if heap buffer; may be null.
    • getAddress

      public long getAddress()
      The address if native buffer, or array base offset; may be NULL.
    • getRowBytes

      public int getRowBytes()
      The size, in bytes, between the start of one pixel row/scanline and the next in buffer, including any unused padding between them. This value must be at least the width multiplied by the bytes-per-pixel, where the bytes-per-pixel depends on the color type.
    • isImmutable

      public boolean isImmutable()
      Returns true if this container is marked as immutable, meaning that the contents of its pixels will not change for the lifetime of the container.
    • setImmutable

      public void setImmutable()
      Marks this container is immutable, meaning that the contents of its pixels will not change for the lifetime of the container. This state can be set on a container, but it cannot be cleared once it is set.
    • toString

      public String toString()
      Overrides:
      toString in class Object