Use MIN(WIDTH - 1, dirtyX + startOffset) to avoid hitting assertion in setDirtyFromX:Y:toX:Y:.