High CPU usage on macOS using COffscreenContext

I am not sure if it will be 100% relevant, but for my vst plugin, I use a COfffScreenContext to generate a bitmap (which is then cached) and the bitmap is drawn into the view. I have no performance problems (on macOS).

Here is the code (source: vst-sam-spl-64/SampleDisplayView.cpp at v1.4.0 · pongasoft/vst-sam-spl-64 · GitHub)

void SampleDisplayView::generateBitmap(SampleData const &iSampleData)
{
  // TODO: optimization: load -> mono -> compute summary at the same time

  auto buffers = iSampleData.load(*fSampleRate);
  if(buffers && buffers->hasSamples())
  {
    //buffers = buffers->toMono();

    auto context = COffscreenContext::create(getFrame(), getWidth(), getHeight(), getFrame()->getScaleFactor());

    fBitmap = Waveform::createBitmap(context,
                                     buffers.get(),
                                     {getWaveformColor(), getWaveformAxisColor(), 2, getMargin()});
  }
  else
    fBitmap = nullptr;
}

The content is pretty complicated because it is the waveform of a sample

Yan