/** Ensures that the canvas image is at least the specified dimensions and cleared to all
* transparent pixels. Also creates and adds the image layer to the parent layer if
* needed. */
public void prepare (float width, float height) {
// recreate our canvas if we need more room than we have (TODO: should we ever shrink it?)
ImageLayer layer = _layer.get();
if (_image == null || _image.width() < width || _image.height() < height) {
_image = PlayN.graphics().createImage(width, height);
if (layer != null) layer.setImage(_image);
} else {
_image.canvas().clear();
}
if (layer == null) {
layer = _layer.set(PlayN.graphics().createImageLayer(_image));
if (_depth != null) layer.setDepth(_depth);
_parent.add(layer);
}
_preparedWidth = width;
_preparedHeight = height;
}