Class Texture.PixelBufferDescriptor

    • Field Detail

      • storage

        public java.nio.Buffer storage
      • alignment

        public int alignment
      • left

        public int left
      • top

        public int top
      • stride

        public int stride
      • compressedSizeInBytes

        public int compressedSizeInBytes
      • handler

        @Nullable
        public java.lang.Object handler
      • callback

        @Nullable
        public java.lang.Runnable callback
        Callback used to destroy the buffer data.

        Guarantees:

        • Called on the main filament thread.

        Limitations:

        • Must be lightweight.
        • Must not call filament APIs.

    • Constructor Detail

      • PixelBufferDescriptor

        public PixelBufferDescriptor​(@NonNull
                                     java.nio.Buffer storage,
                                     @NonNull
                                     Texture.Format format,
                                     @NonNull
                                     Texture.Type type,
                                     @IntRange(from=1L,to=8L)
                                     int alignment,
                                     @IntRange(from=0L)
                                     int left,
                                     @IntRange(from=0L)
                                     int top,
                                     @IntRange(from=0L)
                                     int stride,
                                     @Nullable
                                     java.lang.Object handler,
                                     @Nullable
                                     java.lang.Runnable callback)
        Creates a PixelBufferDescriptor
        Parameters:
        storage - CPU-side buffer containing the image data to upload into the texture
        format - Pixel format of the CPU-side image
        type - Pixel data type of the CPU-side image
        alignment - Row-alignment in bytes of the CPU-side image (1 to 8 bytes)
        left - Left coordinate in pixels of the CPU-side image
        top - Top coordinate in pixels of the CPU-side image
        stride - Stride in pixels of the CPU-side image (i.e. distance in pixels to the next row)
        handler - An Executor. On Android this can also be a Handler.
        callback - A callback executed by handler when storage is no longer needed.
      • PixelBufferDescriptor

        public PixelBufferDescriptor​(@NonNull
                                     java.nio.Buffer storage,
                                     @NonNull
                                     Texture.Format format,
                                     @NonNull
                                     Texture.Type type)
        Creates a PixelBufferDescriptor with some default values and no callback.
        Parameters:
        storage - CPU-side buffer containing the image data to upload into the texture
        format - Pixel format of the CPU-side image
        type - Pixel data type of the CPU-side image
        See Also:
        setCallback(java.lang.Object, java.lang.Runnable)
      • PixelBufferDescriptor

        public PixelBufferDescriptor​(@NonNull
                                     java.nio.Buffer storage,
                                     @NonNull
                                     Texture.Format format,
                                     @NonNull
                                     Texture.Type type,
                                     @IntRange(from=1L,to=8L)
                                     int alignment)
        Creates a PixelBufferDescriptor with some default values and no callback.
        Parameters:
        storage - CPU-side buffer containing the image data to upload into the texture
        format - Pixel format of the CPU-side image
        type - Pixel data type of the CPU-side image
        alignment - Row-alignment in bytes of the CPU-side image (1 to 8 bytes)
        See Also:
        setCallback(java.lang.Object, java.lang.Runnable)
      • PixelBufferDescriptor

        public PixelBufferDescriptor​(@NonNull
                                     java.nio.Buffer storage,
                                     @NonNull
                                     Texture.Format format,
                                     @NonNull
                                     Texture.Type type,
                                     @IntRange(from=1L,to=8L)
                                     int alignment,
                                     @IntRange(from=0L)
                                     int left,
                                     @IntRange(from=0L)
                                     int top)
        Creates a PixelBufferDescriptor with some default values and no callback.
        Parameters:
        storage - CPU-side buffer containing the image data to upload into the texture
        format - Pixel format of the CPU-side image
        type - Pixel data type of the CPU-side image
        alignment - Row-alignment in bytes of the CPU-side image (1 to 8 bytes)
        left - Left coordinate in pixels of the CPU-side image
        top - Top coordinate in pixels of the CPU-side image
        See Also:
        setCallback(java.lang.Object, java.lang.Runnable)
      • PixelBufferDescriptor

        public PixelBufferDescriptor​(@NonNull
                                     java.nio.ByteBuffer storage,
                                     @NonNull
                                     Texture.CompressedFormat format,
                                     @IntRange(from=0L)
                                     int compressedSizeInBytes)
        Parameters:
        storage - CPU-side buffer containing the image data to upload into the texture
        format - Compressed pixel format of the CPU-side image
        compressedSizeInBytes - Size of the compressed data in bytes
        See Also:
        setCallback(java.lang.Object, java.lang.Runnable)
    • Method Detail

      • setCallback

        public void setCallback​(@Nullable
                                java.lang.Object handler,
                                @Nullable
                                java.lang.Runnable callback)
        Set or replace the callback called when the CPU-side data is no longer needed.
        Parameters:
        handler - An Executor. On Android this can also be a Handler.
        callback - A callback executed by handler when storage is no longer needed.
      • computeDataSize

        public static int computeDataSize​(@NonNull
                                          Texture.Format format,
                                          @NonNull
                                          Texture.Type type,
                                          int stride,
                                          int height,
                                          @IntRange(from=1L,to=8L)
                                          int alignment)
        Helper to calculate the buffer size (in byte) needed for given parameters
        Parameters:
        format - Pixel data format.
        type - Pixel data type. Can't be Texture.Type.COMPRESSED.
        stride - Stride in pixels.
        height - Height in pixels.
        alignment - Alignment in bytes.
        Returns:
        Size of the buffer in bytes.