getCanvasPattern method

CanvasPattern getCanvasPattern(
  1. CanvasRenderingContext2D context
)

Implementation

CanvasPattern getCanvasPattern(CanvasRenderingContext2D context) {
  // try to get the canvasPattern from the cache
  if (_canvasPattern == null) {
    final cacheKey = _CanvasPatternKey(_renderTextureQuad, _type);
    _canvasPattern = _canvasPatternCache.getObject(cacheKey);
  }

  // create a canvasPattern and add it to the cache
  if (_canvasPattern == null) {
    final cacheKey = _CanvasPatternKey(_renderTextureQuad, _type);
    _canvasPattern =
        context.createPattern(patternTexture.source!, _type.value);
    _canvasPatternCache.addObject(cacheKey, _canvasPattern);
  }

  return _canvasPattern!;
}