I have had that problem in both sailboat cushions & an old sofa I owned for a long time. I discarded the fabric & reupholstered both the boat and sofa cushions. I'm just today completing the foam replacement for my sailboat cushions.
I use www.sailrite.com
for my supplies. They have a good selection of fabrics and supplies needed in making cushions. Additionally, you'll find lots of "how to" videos on their site demonstrating very clearly the steps in completing projects using their products.
Upholstering cushions is much easier than sewing clothing. The old cushion covers have to be seam ripped into individual pieces. Those pieces provide the pattern for cutting the new covers. If the foam is still in good condition, I add a layer of polyester batting to give "loft" and restuff the new cushions into the old foam. Covering the foam & batting with a drycleaner's plastiac bag or upholstery help to slip the cushion into the new cushion.