applyCache method

void applyCache(
  1. num x,
  2. num y,
  3. num width,
  4. num height,
  5. {bool debugBorder = false,
  6. num pixelRatio = 1.0}
)

Draws the specified area of this display object to an internal render texture and the engine will use this texture to optimize performance.

This is useful when the display object contains many static children or a Graphics vector object. If the cached area changes, the cache must be refreshed using refreshCache or removed using removeCache.

Implementation

void applyCache(num x, num y, num width, num height,
    {bool debugBorder = false, num pixelRatio = 1.0}) {
  final cache = _cache ??= _DisplayObjectCache(this);
  cache.debugBorder = debugBorder;
  cache.pixelRatio = pixelRatio;
  cache.bounds = Rectangle<num>(x, y, width, height);
  cache.update();
}