forked from AcademySoftwareFoundation/OpenImageIO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: start using optional keyword/value params for ImageBufAlgo (Acad…
…emySoftwareFoundation#4149) Many IBA functions take lots of optional parameters, which are from time to time augmented, leaving us with a clutter of semi-deprecated versions. This PR prototypes a new approach, which is to make IBA functions have explicit parameters for their core/necessary controls, and the minor optional behavioral control parameters are passed as keyword/value argument lists. I think this has a few really big advantages over explicit parameter lists with ever-growing optional parameters: 1. It makes the call sites very readable, since the keywords document what the parameters do. 2. It allows us to add (or deprecate) optional parameters without ABI breaking changes, and without proliferation of many versions of each function. A new class is added: ParamValueSpan, which as the name implies, is simply a `span` of ParamValue structs (actually, it's a subclass that inherits from `span<const ParamValue>`, and adds a bunch of helper methods). Within the IBA namespace, this is aliased to KWArgs, to make a short and self-documenting name to pass this collection of optional parameters. This leads to IBA declarations that look like this: ImageBuf OIIO_API resize(const ImageBuf &src, KWArgs options = {}, ROI roi = {}, int nthreads = 0); and calls that looks like this: resize(dst, src, { { "filtername", "lanczos3" }, { "filterwidth", 6.0f } }); In this first stab, I have converted IBA::resize(), fit(), and warp(). That seems like enough to evaluate whether we like the direction this is going. If so, we'll tackle more IBA functions over time. I believe I've done this all in a way that preserves API and ABI compatibility for now A few other odds and ends that come along for the ride: * Filter1D and Filter2D have a new create_shared static method that returns a shared_ptr instead of raw pointer. * Make all filter ctrs ok with 0 default filter width value, which means to use the natural default width for that filter. * IBA::make_kernel is extended so that if you pass 0 for width or hight, it selects the a resolution using the default size for the named filter kernel. This way, the caller doesn't need to know the correct extents of the kernel, just the name. --------- Signed-off-by: Larry Gritz <lg@larrygritz.com> Co-authored-by: Thiago Ize <ThiagoIze@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
1,452 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.