# SurfaceWrapper

Artifact: [androidx.car.app:app-automotive](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/activity/renderer/surface/SurfaceWrapper.java+class:androidx.car.app.activity.renderer.surface.SurfaceWrapper) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

*** ** * ** ***


```
@CarProtocol
public final class SurfaceWrapper
```

<br />

*** ** * ** ***

A class holding the information needed to render the content on a surface.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#SurfaceWrapper(android.os.IBinder,int,int,int,int,android.view.Surface)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/IBinder.html hostToken, @https://developer.android.com/reference/androidx/annotation/Dimension int width, @https://developer.android.com/reference/androidx/annotation/Dimension int height, int displayId, int densityDpi, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Surface.html surface )` Creates a `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper`. |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#getDensityDpi()()` Returns the screen density expressed as dots-per-inch of the `https://developer.android.com/reference/android/view/Display.html` for the contained `https://developer.android.com/reference/android/view/SurfaceView.html`. |
| `int` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#getDisplayId()()` Returns the display id of the `https://developer.android.com/reference/android/view/Display.html` for the `https://developer.android.com/reference/android/view/SurfaceView.html` contained in this class. |
| `@https://developer.android.com/reference/androidx/annotation/Dimension int` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#getHeight()()` Returns the height of the contained `https://developer.android.com/reference/android/view/SurfaceView.html` in pixels. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/IBinder.html` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#getHostToken()()` Returns the host token corresponding to the `https://developer.android.com/reference/android/view/SurfaceView.html` contained in this class. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Surface.html` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#getSurface()()` Returns the `https://developer.android.com/reference/android/view/Surface.html` of the contained `https://developer.android.com/reference/android/view/SurfaceView.html`. |
| `@https://developer.android.com/reference/androidx/annotation/Dimension int` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper#getWidth()()` Returns the width of the contained `https://developer.android.com/reference/android/view/SurfaceView.html` in pixels. |

## Public constructors

### SurfaceWrapper

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public SurfaceWrapper(
    @Nullable IBinder hostToken,
    @Dimension int width,
    @Dimension int height,
    int displayId,
    int densityDpi,
    @NonNull Surface surface
)
```

Creates a `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/IBinder.html hostToken` | a token used for constructing SurfaceControlViewHost. see `https://developer.android.com/reference/android/view/SurfaceView.html` for more details |
| `@https://developer.android.com/reference/androidx/annotation/Dimension int width` | the width of the surface view in pixels |
| `@https://developer.android.com/reference/androidx/annotation/Dimension int height` | the height of the surface view in pixels |
| `int displayId` | the ID of the display showing the surface |
| `int densityDpi` | the density of the display showing the surface expressed as dots-per-inch |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Surface.html surface` | the surface for which the wrapper is created |

## Public methods

### getDensityDpi

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public int getDensityDpi()
```

Returns the screen density expressed as dots-per-inch of the `https://developer.android.com/reference/android/view/Display.html` for the contained `https://developer.android.com/reference/android/view/SurfaceView.html`.

### getDisplayId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public int getDisplayId()
```

Returns the display id of the `https://developer.android.com/reference/android/view/Display.html` for the `https://developer.android.com/reference/android/view/SurfaceView.html` contained in this class.

### getHeight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public @Dimension int getHeight()
```

Returns the height of the contained `https://developer.android.com/reference/android/view/SurfaceView.html` in pixels.

### getHostToken

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public @Nullable IBinder getHostToken()
```

Returns the host token corresponding to the `https://developer.android.com/reference/android/view/SurfaceView.html` contained in this class.

### getSurface

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public @NonNull Surface getSurface()
```

Returns the `https://developer.android.com/reference/android/view/Surface.html` of the contained `https://developer.android.com/reference/android/view/SurfaceView.html`.

### getWidth

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
public @Dimension int getWidth()
```

Returns the width of the contained `https://developer.android.com/reference/android/view/SurfaceView.html` in pixels.