# 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
class SurfaceWrapper
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/activity/renderer/surface/SurfaceWrapper#SurfaceWrapper(android.os.IBinder,int,int,int,int,android.view.Surface)( hostToken: https://developer.android.com/reference/android/os/IBinder.html?, width: @https://developer.android.com/reference/kotlin/androidx/annotation/Dimension https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: @https://developer.android.com/reference/kotlin/androidx/annotation/Dimension https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, displayId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, densityDpi: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, surface: https://developer.android.com/reference/android/view/Surface.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/car/app/activity/renderer/surface/SurfaceWrapper`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/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`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/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/kotlin/androidx/annotation/Dimension https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/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://developer.android.com/reference/android/os/IBinder.html?` | `https://developer.android.com/reference/kotlin/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://developer.android.com/reference/android/view/Surface.html` | `https://developer.android.com/reference/kotlin/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/kotlin/androidx/annotation/Dimension https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/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)

```
SurfaceWrapper(
    hostToken: IBinder?,
    width: @Dimension Int,
    height: @Dimension Int,
    displayId: Int,
    densityDpi: Int,
    surface: Surface
)
```

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

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

## Public functions

### getDensityDpi

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

```
fun getDensityDpi(): Int
```

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)

```
fun getDisplayId(): Int
```

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)

```
fun getHeight(): @Dimension Int
```

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)

```
fun getHostToken(): IBinder?
```

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)

```
fun getSurface(): Surface
```

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)

```
fun getWidth(): @Dimension Int
```

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