---
url: https://cri-middleware.github.io/SSPlayerForReactNative/api/classes/SsTextureRegistry.md
---
# Class: SsTextureRegistry

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:62](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L62)

`cellmap.name_hash` → the `SkPaint` its batches draw with.

The hash is what `DrawBatch.texture_hash` carries, so this is the whole of
texture resolution. Hashes come
from the Brain via `SsRuntime.hashString`; **never** re-implement FNV-1a here,
because a second implementation that disagrees shows up as a texture that
silently never resolves.

A paint rather than an image, because a paint is what `drawInto` needs and
building one per frame would allocate on the hot path.

## Ownership

The registry owns the paints and shaders it builds, not the `SkImage`s handed
to it: those usually come from a React hook that manages their lifetime, and
disposing one out from under a picture that has been recorded but not yet
rasterised would draw from freed memory. `dispose()` therefore drops the
paints and leaves the images alone.

## Constructors

### Constructor

> **new SsTextureRegistry**(): `SsTextureRegistry`

#### Returns

`SsTextureRegistry`

## Accessors

### size

#### Get Signature

> **get** **size**(): `number`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:177](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L177)

##### Returns

`number`

## Methods

### bindings()

> **bindings**(): [`SsTextureBinding`](../interfaces/SsTextureBinding.md)\[]

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:189](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L189)

The texture table for `SsContext.drawInto`, cached until the registry
changes.

Order does not matter: `drawInto` resolves each batch against this by hash,
so the Brain's batch order — which is the whole of the depth sorting —
survives regardless.

#### Returns

[`SsTextureBinding`](../interfaces/SsTextureBinding.md)\[]

***

### dispose()

> **dispose**(): `void`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:219](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L219)

Drops every paint. The images stay alive — see the class comment.

#### Returns

`void`

***

### has()

> **has**(`textureHash`): `boolean`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:98](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L98)

Whether something is already registered.

#### Parameters

##### textureHash

`number`

#### Returns

`boolean`

***

### hasBase()

> **hasBase**(`textureHash`): `boolean`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:107](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L107)

Whether the texture [restore](#restore) would bring back is in, so a loader can
skip a re-decode. An [override](#override) alone does not count: the pack's own
atlas still has to go underneath it.

#### Parameters

##### textureHash

`number`

#### Returns

`boolean`

***

### isOverridden()

> **isOverridden**(`textureHash`): `boolean`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:158](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L158)

Whether `textureHash` currently carries a runtime [override](#override).

#### Parameters

##### textureHash

`number`

#### Returns

`boolean`

***

### override()

> **override**(`textureHash`, `image`, `options?`): `void`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:142](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L142)

Replaces the paint for `textureHash` with a runtime `image`, remembering the
paint it displaced so [restore](#restore) can bring it back.

This is the runtime texture-replacement seam — a costume change or a dynamic
expression driven from code rather than the authoring data. It
is keyed by the same hash `DrawBatch.texture_hash` carries, so the swap takes
effect on the next `drawInto` with nothing else to do.

Distinct from [registerByHash](#registerbyhash) only in that it captures the base: a
plain re-register (what a loader does) is not an override and leaves nothing
to restore to.

#### Parameters

##### textureHash

`number`

##### image

[`SkImage`](https://wcandillon.github.io/react-native-skia/)

##### options?

[`SsTextureOptions`](../interfaces/SsTextureOptions.md)

#### Returns

`void`

***

### register()

> **register**(`cellmapName`, `image`, `options?`): `void`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:79](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L79)

Registers `image` under the cellmap called `cellmapName` — the name as the
`.ssab` carries it, with no `.ssce` extension.

#### Parameters

##### cellmapName

`string`

##### image

[`SkImage`](https://wcandillon.github.io/react-native-skia/)

##### options?

[`SsTextureOptions`](../interfaces/SsTextureOptions.md)

#### Returns

`void`

***

### registerBase()

> **registerBase**(`textureHash`, `image`, `options?`): `void`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:117](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L117)

As [registerByHash](#registerbyhash), for what a pack loads. Under an [override](#override)
it goes where [restore](#restore) looks, and the override keeps drawing.

#### Parameters

##### textureHash

`number`

##### image

[`SkImage`](https://wcandillon.github.io/react-native-skia/)

##### options?

[`SsTextureOptions`](../interfaces/SsTextureOptions.md)

#### Returns

`void`

***

### registerByHash()

> **registerByHash**(`textureHash`, `image`, `options?`): `void`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:88](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L88)

As `register`, for a hash already obtained from the Brain.

#### Parameters

##### textureHash

`number`

##### image

[`SkImage`](https://wcandillon.github.io/react-native-skia/)

##### options?

[`SsTextureOptions`](../interfaces/SsTextureOptions.md)

#### Returns

`void`

***

### restore()

> **restore**(`textureHash`): `boolean`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:167](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L167)

Undoes an [override](#override), putting back the paint the pack had loaded — or
dropping the entry when the override went on before any paint was there.
Returns whether an override was actually in effect.

#### Parameters

##### textureHash

`number`

#### Returns

`boolean`

***

### unregister()

> **unregister**(`textureHash`): `boolean`

Defined in: [packages/react-native-spritestudio/src/core/SsTextureRegistry.ts:207](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/core/SsTextureRegistry.ts#L207)

Drops one paint, if it is registered. Returns whether it was.

For an owner replacing what it put in rather than emptying the registry: a
player reloading a different pack has to take its own entries out, and a
registry it shares with the caller may hold entries that are not its to
drop.

#### Parameters

##### textureHash

`number`

#### Returns

`boolean`
