begin method

void begin(
  1. int width,
  2. int height
)

Starts a new page/batch: sets the device viewport (pixels) and clears the strip buffer. Scratch buffers are kept and only grow.

Implementation

void begin(int width, int height) {
  _width = width;
  _height = height;
  _rowCount = (height + 3) >> 2;
  _stride = width + 2;
  if (_accum.length < 4 * _stride) {
    _accum = Float32List(4 * _stride);
  } else {
    _accum.fillRange(0, 4 * _stride, 0); // defensive: restore invariant
  }
  if (_rowHead.length < _rowCount) {
    _rowHead = Int32List(_rowCount);
    _rowMinX = Int32List(_rowCount);
    _rowMaxX = Int32List(_rowCount);
  }
  _rowHead.fillRange(0, _rowCount, -1);
  _dirtyCount = 0;
  _nodeCount = 0;
  strips.reset();
}