# GPUTexture

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/GPUTexture.kt+class:androidx.webgpu.GPUTexture) Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

*** ** * ** ***


```
public final class GPUTexture implements AutoCloseable
```

<br />

*** ** * ** ***

A GPU texture object.

## Summary

| ### Public methods |
|---|---|
| `external void` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#close()()` Decrements the reference count of the object and frees resources when the count reaches zero. |
| `final external @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTextureView` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#createView(androidx.webgpu.GPUTextureViewDescriptor)(https://developer.android.com/reference/androidx/webgpu/GPUTextureViewDescriptor descriptor)` Creates a new view of the texture. |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#depthOrArrayLayers()()` |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#destroy()()` Destroys the texture and releases its resources. |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#dimension()()` |
| `boolean` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#format()()` |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getDepthOrArrayLayers()()` Gets the depth or number of array layers of the texture. |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getDimension()()` Gets the dimension of the texture. |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getFormat()()` Gets the format of the texture. |
| `final long` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#getHandle()()` |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getHeight()()` Gets the height of the texture. |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getMipLevelCount()()` Gets the number of mipmap levels of the texture. |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getSampleCount()()` Gets the sample count of the texture. |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getTextureBindingViewDimension()()` |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getUsage()()` Gets the allowed usages of the texture. |
| `final external int` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#getWidth()()` Gets the width of the texture. |
| `int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#hashCode()()` |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#height()()` |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#mipLevelCount()()` |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#sampleCount()()` |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUTexture#setLabel(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html label)` Sets a human-readable label for debugging. |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#textureBindingViewDimension()()` |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#usage()()` |
| `final int` | `https://developer.android.com/reference/androidx/webgpu/GPUTexture#width()()` |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/androidx/webgpu/TexturesUtils.https://developer.android.com/reference/androidx/webgpu/GPUTexture#(androidx.webgpu.GPUTexture).createBitmap(androidx.webgpu.GPUDevice)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTexture receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUDevice device )` |

## Public methods

### close

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public external void close()
```

Decrements the reference count of the object and frees resources when the count reaches zero.

This is the standard way to manage object lifetimes and should be used in `use` blocks. After calling this, the object is no longer usable.

### createView

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external @NonNull GPUTextureView createView(GPUTextureViewDescriptor descriptor)
```

Creates a new view of the texture.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/webgpu/GPUTextureViewDescriptor descriptor` | The descriptor for the texture view. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTextureView` | The created texture view. |

### depthOrArrayLayers

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int depthOrArrayLayers()
```

### destroy

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external void destroy()
```

Destroys the texture and releases its resources.

### dimension

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int dimension()
```

### equals

```
public boolean equals(Object other)
```

### format

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int format()
```

### getDepthOrArrayLayers

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getDepthOrArrayLayers()
```

Gets the depth or number of array layers of the texture.

| Returns |
|---|---|
| `int` | The texture depth or layer count. |

### getDimension

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getDimension()
```

Gets the dimension of the texture.

Value is one of the following:

- `0`
- `1`
- `2`
- `3`

<br />

| Returns |
|---|---|
| `int` | The texture dimension. |

### getFormat

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getFormat()
```

Gets the format of the texture.

Value is one of the following:

- `0`
- `1`
- `2`
- `3`
- `4`
- `5`
- `6`
- `7`
- `8`
- `9`
- `10`
- `11`
- `12`
- `13`
- `14`
- `15`
- `16`
- `17`
- `18`
- `19`
- `20`
- `21`
- `22`
- `23`
- `24`
- `25`
- `26`
- `27`
- `28`
- `29`
- `30`
- `31`
- `32`
- `33`
- `34`
- `35`
- `36`
- `37`
- `38`
- `39`
- `40`
- `41`
- `42`
- `43`
- `44`
- `45`
- `46`
- `47`
- `48`
- `49`
- `50`
- `51`
- `52`
- `53`
- `54`
- `55`
- `56`
- `57`
- `58`
- `59`
- `60`
- `61`
- `62`
- `63`
- `64`
- `65`
- `66`
- `67`
- `68`
- `69`
- `70`
- `71`
- `72`
- `73`
- `74`
- `75`
- `76`
- `77`
- `78`
- `79`
- `80`
- `81`
- `82`
- `83`
- `84`
- `85`
- `86`
- `87`
- `88`
- `89`
- `90`
- `91`
- `92`
- `93`
- `94`
- `95`
- `96`
- `97`
- `98`
- `99`
- `100`
- `101`

<br />

| Returns |
|---|---|
| `int` | The texture format. |

### getHandle

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final long getHandle()
```

### getHeight

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getHeight()
```

Gets the height of the texture.

| Returns |
|---|---|
| `int` | The texture height. |

### getMipLevelCount

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getMipLevelCount()
```

Gets the number of mipmap levels of the texture.

| Returns |
|---|---|
| `int` | The mipmap level count. |

### getSampleCount

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getSampleCount()
```

Gets the sample count of the texture.

| Returns |
|---|---|
| `int` | The sample count. |

### getTextureBindingViewDimension

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getTextureBindingViewDimension()
```

Value is one of the following:

- `0`
- `1`
- `2`
- `3`
- `4`
- `5`
- `6`

<br />

### getUsage

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getUsage()
```

Gets the allowed usages of the texture.

Value is either `0` or a combination of the following:

- `0`
- `1`
- `2`
- `4`
- `8`
- `16`
- `32`

<br />

| Returns |
|---|---|
| `int` | The texture usage flags. |

### getWidth

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external int getWidth()
```

Gets the width of the texture.

| Returns |
|---|---|
| `int` | The texture width. |

### hashCode

```
public int hashCode()
```

### height

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int height()
```

### mipLevelCount

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int mipLevelCount()
```

### sampleCount

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int sampleCount()
```

### setLabel

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
public final external void setLabel(@NonNull String label)
```

Sets a human-readable label for debugging.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html label` | The label string. |

### textureBindingViewDimension

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int textureBindingViewDimension()
```

### usage

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int usage()
```

### width

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
public final int width()
```

## Extension functions

### TexturesUtils.createBitmap

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/helper/Textures.kt+function:createBitmap)

```
public final @NonNull Bitmap TexturesUtils.createBitmap(
    @NonNull GPUTexture receiver,
    @NonNull GPUDevice device
)
```