renderObject method

void renderObject (
  1. RenderObject renderObject
)

Implementation

void renderObject(RenderObject renderObject) {
  var matrix = renderObject.transformationMatrix;
  var blendMode = renderObject.blendMode;
  var alpha = renderObject.alpha;
  var filters = renderObject.filters;
  var cache = renderObject.cache;
  var mask = renderObject.mask;

  var cs1 = _currentContextState;
  var cs2 = _currentContextState.nextContextState;
  var maskBefore = mask != null && mask.relativeToParent == true;
  var maskAfter = mask != null && mask.relativeToParent == false;

  //-----------

  if (maskBefore) renderContext.beginRenderMask(this, mask);

  cs2.matrix.copyFromAndConcat(matrix, cs1.matrix);
  cs2.blendMode = (blendMode is BlendMode) ? blendMode : cs1.blendMode;
  cs2.alpha = alpha * cs1.alpha;

  if (renderObject is RenderObject3D && renderContext is RenderContextWebGL) {
    var renderObject3D = renderObject;
    var renderContextWebGL = renderContext as RenderContextWebGL;
    cs1.matrix3D.copyFrom(renderContextWebGL.activeProjectionMatrix);
    cs2.matrix3D.copyFrom2DAndConcat(cs2.matrix, cs1.matrix3D);
    cs2.matrix3D.prepend(renderObject3D.projectionMatrix3D);
    cs2.matrix3D.prependInverse2D(cs2.matrix);
    renderContextWebGL.activateProjectionMatrix(cs2.matrix3D);
  }

  _currentContextState = cs2;

  //-----------

  if (maskAfter) renderContext.beginRenderMask(this, mask);

  if (cache != null) {
    renderTextureQuad(cache);
  } else if (filters.isNotEmpty) {
    renderObject.renderFiltered(this);
  } else {
    renderObject.render(this);
  }

  if (maskAfter) renderContext.endRenderMask(this, mask);

  //-----------

  _currentContextState = cs1;

  if (renderObject is RenderObject3D && renderContext is RenderContextWebGL) {
    var renderContextWebGL = renderContext as RenderContextWebGL;
    renderContextWebGL.activateProjectionMatrix(cs1.matrix3D);
  }

  if (maskBefore) renderContext.endRenderMask(this, mask);
}