Class: CanvasPrepare

PIXI. CanvasPrepare

The prepare manager provides functionality to upload content to the GPU
This cannot be done directly for Canvas like in WebGL, but the effect can be achieved by drawing
textures to an offline canvas.
This draw call will force the texture to be moved onto the GPU.

new PIXI.CanvasPrepare(renderer)

Name Type Description
renderer PIXI.CanvasRenderer

A reference to the current renderer

Members

staticPIXI.CanvasPrepare.UPLOADS_PER_FRAMEnumber

The number of graphics or textures to upload to the GPU.

Default Value:
  • 4

Methods

Manually add an item to the uploading queue.

Name Type Description
item PIXI.DisplayObject | PIXI.Container | *

Object to add to the queue

Returns:
Type Description
PIXI.CanvasPrepare Instance of plugin for chaining.

Destroys the plugin, don't use after this.

Adds hooks for finding and uploading items.

Name Type Description
addHook function optional

Function call that takes two parameters: item:*, queue:Array
function must return true if it was able to add item to the queue.

uploadHook function optional

Function call that takes two parameters: prepare:CanvasPrepare, item:* and
function must return true if it was able to handle upload of item.

Returns:
Type Description
PIXI.CanvasPrepare Instance of plugin for chaining.

Upload all the textures and graphics to the GPU.

Name Type Description
item function | PIXI.DisplayObject | PIXI.Container

Either
the container or display object to search for items to upload or
the callback function, if items have been added using prepare.add.

done function optional

Optional callback when all queued uploads have completed