Package com.google.android.filament
Class Texture.PixelBufferDescriptor
- java.lang.Object
-
- com.google.android.filament.Texture.PixelBufferDescriptor
-
- Enclosing class:
- Texture
public static class Texture.PixelBufferDescriptor extends java.lang.ObjectA descriptor to an image in main memory, typically used to transfer image data from the CPU to the GPU.A
PixelBufferDescriptorowns the memory buffer it references, thereforePixelBufferDescriptorcannot be copied, but can be moved.PixelBufferDescriptorreleases ownership of the memory-buffer when it's destroyed.
-
-
Field Summary
Fields Modifier and Type Field Description intalignmentjava.lang.RunnablecallbackCallback used to destroy the buffer data.Texture.CompressedFormatcompressedFormatintcompressedSizeInBytesTexture.Formatformatjava.lang.Objecthandlerintleftjava.nio.BufferstorageintstrideinttopTexture.Typetype
-
Constructor Summary
Constructors Constructor Description PixelBufferDescriptor(java.nio.Buffer storage, Texture.Format format, Texture.Type type)Creates aPixelBufferDescriptorwith some default values and no callback.PixelBufferDescriptor(java.nio.Buffer storage, Texture.Format format, Texture.Type type, int alignment)Creates aPixelBufferDescriptorwith some default values and no callback.PixelBufferDescriptor(java.nio.Buffer storage, Texture.Format format, Texture.Type type, int alignment, int left, int top)Creates aPixelBufferDescriptorwith some default values and no callback.PixelBufferDescriptor(java.nio.Buffer storage, Texture.Format format, Texture.Type type, int alignment, int left, int top, int stride, java.lang.Object handler, java.lang.Runnable callback)Creates aPixelBufferDescriptorPixelBufferDescriptor(java.nio.ByteBuffer storage, Texture.CompressedFormat format, int compressedSizeInBytes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcomputeDataSize(Texture.Format format, Texture.Type type, int stride, int height, int alignment)Helper to calculate the buffer size (in byte) needed for given parametersvoidsetCallback(java.lang.Object handler, java.lang.Runnable callback)Set or replace the callback called when the CPU-side data is no longer needed.
-
-
-
Field Detail
-
storage
public java.nio.Buffer storage
-
type
public Texture.Type type
-
alignment
public int alignment
-
left
public int left
-
top
public int top
-
stride
public int stride
-
format
public Texture.Format format
-
compressedSizeInBytes
public int compressedSizeInBytes
-
compressedFormat
public Texture.CompressedFormat compressedFormat
-
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 aPixelBufferDescriptor- Parameters:
storage- CPU-side buffer containing the image data to upload into the textureformat- Pixelformatof the CPU-side imagetype- Pixel datatypeof the CPU-side imagealignment- Row-alignment in bytes of the CPU-side image (1 to 8 bytes)left- Left coordinate in pixels of the CPU-side imagetop- Top coordinate in pixels of the CPU-side imagestride- Stride in pixels of the CPU-side image (i.e. distance in pixels to the next row)handler- AnExecutor. On Android this can also be aHandler.callback- A callback executed byhandlerwhenstorageis no longer needed.
-
PixelBufferDescriptor
public PixelBufferDescriptor(@NonNull java.nio.Buffer storage, @NonNull Texture.Format format, @NonNull Texture.Type type)Creates aPixelBufferDescriptorwith some default values and no callback.- Parameters:
storage- CPU-side buffer containing the image data to upload into the textureformat- Pixelformatof the CPU-side imagetype- Pixel datatypeof 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 aPixelBufferDescriptorwith some default values and no callback.- Parameters:
storage- CPU-side buffer containing the image data to upload into the textureformat- Pixelformatof the CPU-side imagetype- Pixel datatypeof the CPU-side imagealignment- 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 aPixelBufferDescriptorwith some default values and no callback.- Parameters:
storage- CPU-side buffer containing the image data to upload into the textureformat- Pixelformatof the CPU-side imagetype- Pixel datatypeof the CPU-side imagealignment- Row-alignment in bytes of the CPU-side image (1 to 8 bytes)left- Left coordinate in pixels of the CPU-side imagetop- 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 textureformat- Compressed pixelformatof the CPU-side imagecompressedSizeInBytes- 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- AnExecutor. On Android this can also be aHandler.callback- A callback executed byhandlerwhenstorageis 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 beTexture.Type.COMPRESSED.stride- Stride in pixels.height- Height in pixels.alignment- Alignment in bytes.- Returns:
- Size of the buffer in bytes.
-
-