Skip to content
  • Ell's avatar
    buffer: don't use cached sampler for gegl_buffer_sample[_at_level]() · 26f13cbf
    Ell authored
    The use of a per-buffer cached sampler is problematic, especially
    since the cached sampler may cache stale data after the buffer is
    modified.  Avoiding this requires careful use of
    gegl_buffer_sample_cleanup().  On the one hand, when using
    gegl_buffer_sample[_at_level]() for one-off samples in loosely-
    coupled code, this effectively means calling
    gegl_buffer_sample_cleanup() before/after each sample, defeating
    the purpose of caching the sampler in the first place.  On the
    other hand, when performing multiple samples in performance-
    critical code, using a sampler object is much more efficient
    anyway.
    
    Remove the per-buffer cached sampler, and simply use a per-call
    temporary sampler in gegl_buffer_sample[_at_level]().  Advise users
    to use gegl_buffer_sampler_new[_at_level]() to create a sampler
    object instead when performance is a concern.
    
    Deprecate gegl_buffer_sample_cleanup(), which is not necessary
    anymore, and keep it as a NOP for now.
    26f13cbf